The
IlpEquipment allows you to associate behavior
with the equipment view as a whole and with the business objects it
contains.
JViews TGO
provides predefined view interactors to manage the behavior of the
equipment view. See
View interactors. These interactors allow you
to change the zoom factor, to move and resize objects, and to
change the relationship between objects. See
Configuring the equipment component for
details on how to enable the interactors.
The predefined interactors available in the
equipment view are the following:
Select
interactor
Allows you to select any object displayed in the equipment
component and to move root objects. When a root object is moved,
its
position
property value is updated to reflect the new user-defined
position. Multiple selection is also possible.
Edit
interactor
Like the select interactor, this
interactor allows you to select any object displayed in the
equipment component, and to move root objects.
This interactor also allows you to
reshape selected objects or to change their relationship. Root
objects such as cards, shelves, and card carriers can be
reshaped or moved around in the view. Cards and card carriers
can be moved from the view to a shelf item container (shelf or
card carrier) and vice versa; the same action can be performed
on LEDs and ports, moving them from the view to a card item
container (card). A child object can have its position updated
or its relationships changed when it is moved from one container
to another or to the view.
By default, this interactor is not
enabled. You can enable it either through a button in the CSS
configuration file, as follows:
ToolBar {
button[4]: @+button4;
}
Subobject#button4 {
actionType: "EditObject";
}
or through the API, as follows:
IlpEquipment equipment = new IlpEquipment();
equipment.setDefaultViewInteractor(new IlpEditEquipmentObjectInteractor());
Pan
interactor
Allows you to recenter the equipment
view, without changing the position of the objects.
Zoom In
interactor
Increases the zoom factor. Depending on
the zoom configuration, the result may vary.
Zoom Out
interactor
Decreases the zoom factor. Depending on
the zoom configuration, the result may vary.
Reset
Zoom interactor
Sets the current zoom factor back to its
default value, regardless of the zoom configuration.
Fit to
Contents interactor
Adjusts the zoom factor so that all the
objects fit in the view. This setting may change the scale of
the objects. However, the position and shape of the objects are
not affected.
Zoom on
a Rectangle interactor
Allows you to select a rectangular area
and to zoom on the objects it contains, so that they fit in the
view.
Zoom
Back interactor
Allows you to zoom back to the last zoom
level.
Each view interactor works with one
equipment view only and is managed by the equipment controller. An
equipment view can have several interactors, but only one
interactor is active at a time.
With the default view interactors, you can:
associate
actions with mouse events and focus events
associate
actions with keyboard events
define a
pop-up menu factory to build a pop-up menu that displays in the
view
View interactors have two modes of
operation:
In transient mode, the view interactor
removes itself from the equipment view when it has performed its
action.
In permanent mode, the view interactor
remains in the view until the controller removes it.
By default, view interactors are permanent.
View interactors can display a pop-up menu.
How to wrap a predefined view interactor
when Installing It
IlvManagerViewInteractor iltInteractor = new Ilt...Interactor();
IlpViewInteractor ilpInteractor =
new IlpViewsViewInteractor(iltInteractor);
controller.setViewInteractor(ilpInteractor);
Setting the view interactor
The method
setViewInteractor allows you to set the
view interactor, that is, the object-independent interactor,
which is active at a given moment in the view. This interactor is
replaced whenever the end user activates a different interactor.
Such activation occurs, for example, when the user clicks a
toolbar button.
Some interactors are one-shot interactors, that is, they have the
attribute
permanent:false
in CSS. When such an interactor finishes its interaction, it is
replaced by the default view interactor.
View interactor and default view
interactor
When you use the
setViewInteractor
method you are attaching the specified interactor directly to
the view. On the other hand,
setDefaultViewInteractor allows you to
define the interactor that will be attached when the current
interactor is detached from the view and no other interactor is
attached. The default interactor is not attached automatically
to the view, so it will not be available immediately.
The following example combines both
methods:
// Configuring the default view interactor and making
// it active
IltSelectInteractor selInteractor = new IltSelectInteractor();
selInteractor.setEditingAllowed(true);
IlpViewsViewInteractor viewsInteractor =
new IlpViewsViewInteractor(selInteractor);
equipment.setDefaultViewInteractor(viewsInteractor);
equipment.setViewInteractor(viewsInteractor);
How to associate an action with a mouse
event and modifier in the equipment view
You can associate actions with mouse
events, with or without modifiers, by using either CSS or the
API.
The following extract shows how to
customize the default view interactor in CSS:
Equipment {
interactor: true;
}
Interactor {
viewInteractor: @+viewInt;
}
Subobject#viewInt {
class: 'ilog.cpl.graphic.views.IlpViewsViewInteractor';
action[0]: @+viewAction0;
}
Subobject#viewAction0 {
class: 'ilog.cpl.interactor.IlpGestureAction';
gesture: BUTTON3_CLICKED;
modifiers: shift;
action: @+myAction;
}
Subobject#myAction {
class: 'my.custom.ActionImplementation';
}
The same configuration can be achieved
through the API, as follows:
IlpEquipment equipment = // ...
// Retrieve the view interactor
IlpViewInteractor viewInteractor = equipment.getDefaultViewInteractor();
// Create an actionAction
myAction = new MyAction();
// Clicking the 3rd mouse button will trigger myAction
viewInteractor.setGestureAction(IlpGesture.BUTTON3_CLICKED,
InputEvent.SHIFT_DOWN_MASK,myAction);
You can also customize the actions that
are associated with the interactors defined in the equipment
component toolbar. This configuration is done with the toolbar
button definition. The following CSS extract illustrates how
this can be achieved:
How to associate an action with a mouse
event for an equipment Toolbar button interactor
You can associate actions with mouse
events when one of the interactors defined in the equipment
component toolbar is active. The following CSS extract
illustrates this configuration:
Equipment {
toolbar: true;
}
ToolBar {
enabled: true;
button[0]: @+SelectButton;
}
Subobject#SelectButton {
actionType: "Select";
usingObjectInteractor: true;
opaqueMove: true;
action[0]: @+action0;
}
Subobject#action0 {
gesture: BUTTON1_DOUBLE_CLICKED;
class: 'my.custom.ActionImplementation';
}
In this configuration, the action
ActionImplementation
is triggered when a double-click event occurs while the
selection interactor is set in the equipment view. You can
define any list of actions associated with gestures by using
the indexed property
action
. To be accepted by the CSS customization, the action class
must be a JavaBean™.
The CSS to associate an action with a
mouse event and a modifier is slightly different:
Subobject#SelectButton {
actionType: "Select";
usingObjectInteractor: true;
opaqueMove: true;
action[0]: @+gestureAction0;
}
Subobject#gestureAction0 {
class: 'ilog.cpl.interactor.IlpGestureAction';
gesture: BUTTON1_DOUBLE_CLICKED;
modifiers: 'shift,control';
action: @+action0;
}
Subobject#action0 {
class: 'my.custom.ActionImplementation';
}
You can find out whether this event occurred on an
IlpObject
by means of the following code (which should be in the
MyAction
class):
How to check whether a given action
occurred in the equipment view interactor
// Implementation of the ActionListener interface
public void actionPerformed(ActionEvent e) {
// JTGO interactors use IlpViewActionEvent
IlpViewActionEvent viewEvent = (IlpViewActionEvent)e;
// Get the IlpObject (if any) where the interaction occurred
IlpObject ilpObj = viewEvent.getIlpObject();
// Perform operation on the given object
}
How to associate an action with a
keyboard event in the equipment view
You can associate actions with keyboard
events by using either CSS or the API.
The following extract shows how to
proceed in CSS:
Equipment {
interactor: true;
}
Interactor {
viewInteractor: @+viewInt;
}
Subobject#viewInt {
class: 'ilog.cpl.graphic.views.IlpViewsViewInteractor';
action[0]: @+viewAction0;
}
Subobject#viewAction0 {
class: 'ilog.cpl.interactor.IlpKeyStrokeAction';
keyStroke: 'typed D';
action: @+myAction;
}
Subobject#myAction {
class: MyAction;
}
The same configuration can be achieved
through the API, as follows:
// Create an actionAction myAction = new MyAction();
// Typing CTRL+D will trigger myAction
viewInteractor.setKeyStrokeAction(KeyStroke.getKeyStroke('D',java.awt.Event.CTR
L_MASK),myAction);
You can also customize the keystroke
actions that are associated with the interactors defined in the
equipment component toolbar. This configuration is performed
with the toolbar button definition. The following CSS extract
illustrates how this can be achieved:
How to associate an action with a
keyboard event for a equipment toolbar button interactor
You can associate actions with keyboard
events when one of the interactors defined in the equipment
component toolbar is active. The following CSS extract
illustrates this configuration:
Equipment {
toolbar: true;
}
ToolBar {
enabled: true;
button[0]: @+SelectButton;
}
Subobject#SelectButton {
actionType: "Select";
usingObjectInteractor: true;
opaqueMove: true;
action[0]: @+action0;
}
Subobject#action0 {
key: "control A";
class: "ilog.cpl.graph.action.IlpSelectAllObjectsAction";
}
In this configuration, the action "
IlpSelectAllObjectsAction
" is triggered when a Control-A keyboard event occurs while the
selection interactor is set in the equipment view. You can
define any list of actions associated with keyboard events by
using the indexed property
action
. To be accepted by the CSS customization, the action class
must be a JavaBean.
How to define a pop-up menu factory for
the equipment view
You can customize a pop-up menu factory
for the equipment view either through CSS or through the API.
The following extract shows how to add a
pop-up menu factory through CSS:
Equipment {
interactor: true;
}
Interactor {
viewInteractor: @+viewInt;
}
Subobject#viewInt {
class: 'ilog.cpl.graphic.views.IlpViewsViewInteractor';
popupMenuFactory: @+viewPopupMenuFactory;
}
Subobject#viewPopupMenuFactory {
class: MyPopupMenuFactory;
}
The same configuration can be achieved
through the API, as follows:
// Subclass IlpAbstractPopupMenuFactory, which has useful shortcuts
IlpPopupMenuFactory popupMenuFactory = new IlpAbstractPopupMenuFactory() {
// Add the identifier of each of the selected objects to the menu
public JPopupMenu createPopupMenu (IlpObjectSelectionModel ilpSelectionModel)
{
// Create an empty popup menu
JPopupMenu menu = new JPopupMenu();
// Access the selected objects from the selection model
Collection selectedObjects = ilpSelectionModel.getSelectedObjects();
// fill the menu according to the current selection
return menu;
}
};
The following code shows you how to
associate the defined pop-up menu factory with the equipment
component:
How to associate a pop-up menu factory
with the equipment component
// Set the popup menu factory to the view interactor
viewInteractor.setPopupMenuFactory(popupMenuFactory);
You can also customize a pop-up menu
factory that is associated with the interactors defined in the
equipment component toolbar. This configuration is performed
with the toolbar button definition. The following CSS extract
illustrates how this can be achieved:
How to define a pop-up menu factory for
a equipment toolbar button interactor
The following CSS extract illustrates
this configuration:
Equipment {
toolbar: true;
}
ToolBar {
enabled: true;
button[0]: @+SelectButton;
}
Subobject#SelectButton {
actionType: "Select";
usingObjectInteractor: true;
opaqueMove: true;
popupMenuFactory: @=viewPopupMenuFactory;
}
Subobject#viewPopupMenuFactory {
class: 'AlarmPopupMenuFactory';
}
The pop-up menu factory is customized using property
popupMenuFactory
in the button configuration. To be accepted during the CSS
customization, the pop-up menu factory class must be a
JavaBean.
Selection interactor
The
IltSelectInteractor class allows you to
select, move, and interact directly with objects. You can:
Click
an object to select it and deselect all other objects.
Use
Shift-click to select an unselected object or to deselect a
selected object while keeping other prior selected objects
selected.
Drag a
selection rectangle to select all objects within this
rectangle.
Drag
one selected object and thereby cause all other selected
objects to move in relation to it.
If
setUsingObjectInteractor(true)
is called on the interactor, then you can also:
You can configure the selection interactor
to use Ctrl-click instead of Shift-click for multiple selection.
How to configure the selection
interactor for multiple selection in the equipment view
In CSS, use the following rules:
Subobject#SelectButton {
multipleSelectionModifier: "java.awt.event.InputEvent.CTRL_MASK";
selectionModifier: "java.awt.event.InputEvent.SHIFT_MASK";
}
In the API, use the following code:
setMultipleSelectionModifier(InputEvent.CTRL_MASK);
setSelectionModifer(InputEvent.SHIFT_MASK);
Group reshape interactor
For polygonal and linear groups:
Dragging
a vertex moves it.
Ctrl-click
on a vertex removes it.
Ctrl-click
on an edge adds a vertex at that point on the edge.
Make rectangular node interactor
The
IltMakeRectGroupInteractor class creates a
node with a rectangular shape (
IltRectGroup). One corner of the rectangle
is denoted by the point where the cursor is located when the
mouse button is released. Make sure that you do really move the
mouse between the time when you press and the time when you
release the mouse button. Otherwise, the shape is created empty
and the node might be invisible.
Make polygonal node interactor
Make polyline node interactor
Make link interactor
The
IltMakeLinkInteractor class creates links (
IltLink ) between nodes. This interactor
works in the following way: the user clicks one node and then
goes on dragging the mouse over another node so that the two
nodes are selected. When the user releases the mouse, a link is
drawn between the two nodes.