public class IlvMoveSelectionAccelerator extends IlvAccelerator
IlvMoveSelectionAccelerator
is an accelerator that allows
the user to move the currently selected objects.
The following code example shows how to use
IlvMoveSelectionAccelerator
in a simple Java application:
// Install the select interactor on the view. // Use this interactor to select graphic objects with the mouse. The selected graphic // objects can then be moved using the move selection accelerator. IlvSelectInteractor inter = new IlvSelectInteractor(); inter.setOpaqueMove(true); mgrview.setInteractor(inter); // Install the move selection accelerator. IlvMoveSelectionAccelerator accelerator = new IlvMoveSelectionAccelerator(KeyEvent.KEY_PRESSED, KeyEvent.VK_LEFT, InputEvent.CTRL_MASK, true); accelerator.setMoveVector(-10, 0); manager.addAccelerator(accelerator);
All input events are handled by means of interactors or accelerators. Accelerators,
such as IlvMoveSelectionAccelerator
, are subclasses of IlvAccelerator
.
Each accelerator listens for a specific key event in the manager. For information on
handling events in a manager, see
Handling Events.
The following code examples show how to handle user events:
Constructor and Description |
---|
IlvMoveSelectionAccelerator(int type,
int keyCode,
char keyChar,
int modifiers,
boolean consumeEvents)
Creates an
IlvMoveSelectionAccelerator . |
IlvMoveSelectionAccelerator(int type,
int keyCode,
int modifiers)
Creates an
IlvMoveSelectionAccelerator . |
IlvMoveSelectionAccelerator(int type,
int keyCode,
int modifiers,
boolean consumeEvents)
Creates an
IlvMoveSelectionAccelerator . |
Modifier and Type | Method and Description |
---|---|
protected IlvManager |
getMoveSelectionManager(IlvManagerView v)
Returns the manager the selected objects must belong to when
isMoveAffectsSingleSubManager() returns false . |
double |
getMoveVectorX()
Returns the x-distance of the move vector.
|
double |
getMoveVectorY()
Returns the y-distance of the move vector.
|
IlvGraphicEnumeration |
getSelectedMovingObjects(IlvManager manager)
Returns the selected moving objects of the input manager.
|
protected boolean |
handleEvent(IlvManagerView v)
Processes the event.
|
boolean |
isHyperEdgesFollowEndNodes()
Returns
true if the segments of unselected hyperedges
move when all end nodes of the hyperedge are selected and moved. |
boolean |
isLinksFollowEndNodes()
Returns
true if the bends of unselected links move when
both end nodes are selected and moved. |
boolean |
isMoveAffectsSingleSubManager()
Returns whether moving objects must belong to the
same submanager.
|
void |
setHyperEdgesFollowEndNodes(boolean v)
Sets whether the segments of unselected hyperedges move when
all end nodes of the hyperedge are selected and moved.
|
void |
setLinksFollowEndNodes(boolean v)
Sets whether the bends of unselected links move when both end nodes
are selected and moved.
|
void |
setMoveAffectsSingleSubManager(boolean v)
Specifies whether moving objects must belong to the
same submanager or can be contained in different submanagers.
|
void |
setMoveVector(double dx,
double dy)
Sets the move vector in view coordinates.
|
CtrlChar, getEventType, getKeyChar, getKeyCode, getModifier, isConsumeEvents, setConsumeEvents
public IlvMoveSelectionAccelerator(int type, int keyCode, char keyChar, int modifiers, boolean consumeEvents)
IlvMoveSelectionAccelerator
.
You can specify the associated key either by a key code or by a key
character. Key codes are useful for function keys while
key characters are more useful for regular characters
'a'...'z','A'...'Z','0'...'9','+','-', etc.
which, depending on the keyboard layout may produce different key codes.
For instance, on a US keyboard, the character '+' has the same key code
as the character '=', while on a German keyboard, the character '+' has
the same key code as the character '*', hence specifying the '+'
character by key code instead of key character might be not suitable.
To indicate that only the key code should be checked, pass
KeyEvent.CHAR_UNDEFINED
as key character.
To indicate that only the key character should be checked, pass
KeyEvent.VK_UNDEFINED
as key code.type
- The type of the AWT event.keyCode
- The code associated with the key,
or KeyEvent.VK_UNDEFINED
.keyChar
- The character associated with the key,
or KeyEvent.CHAR_UNDEFINED
.modifiers
- The modifiers of the key.consumeEvents
- If true
, the accelerator handles and
consumes the event, except when the consume flag of the event
is already set to true
. If false
, the
accelerator ignores the event's consume flag, and handles all
events without changing the consume flag.public IlvMoveSelectionAccelerator(int type, int keyCode, int modifiers, boolean consumeEvents)
IlvMoveSelectionAccelerator
.type
- The type of the AWT event.keyCode
- The code associated with the key.modifiers
- The modifiers of the key.consumeEvents
- If true
, the accelerator handles and consumes
the event, except when the consume flag of the event is already set to
true
. If false
, the accelerator ignores the
event's consume flag, and handles all events without changing the
consume flag.public IlvMoveSelectionAccelerator(int type, int keyCode, int modifiers)
IlvMoveSelectionAccelerator
.type
- The type of the AWT event.keyCode
- The code associated with the key.modifiers
- The modifiers of the key.public void setMoveVector(double dx, double dy)
dx
- Distance this accelerator currently moves selected objects along the x axis.dy
- Distance this accelerator currently moves selected objects along the y axis.public double getMoveVectorX()
public double getMoveVectorY()
public void setLinksFollowEndNodes(boolean v)
By default, the bends of a link only move when the link is selected. If a group of nodes is selected and move, the straight links always follow the nodes, even if they are not selected, but the bends of unselected nonstraight links do not move. However, you can use this method to set the bends of all links to automatically follow the nodes, even if they are not straight and not explicitly selected.
v
- If true
, the bends of all links automatically follow
the end nodes when the end nodes are moved.public boolean isLinksFollowEndNodes()
true
if the bends of unselected links move when
both end nodes are selected and moved.public void setHyperEdgesFollowEndNodes(boolean v)
By default, the segments of a hyperedge only move when the hyperedge is selected. If a group of nodes is selected and moved, the hyperedges consisting of only one segment always follow the nodes, even if they are not selected, but the multiple segments of the other unselected hyperedges do not move. However, you can use this method to set all hyperedges to automatically follow the nodes.
v
- If true
, the hyperedges automatically follow the
end nodes when the end nodes are moved.public boolean isHyperEdgesFollowEndNodes()
true
if the segments of unselected hyperedges
move when all end nodes of the hyperedge are selected and moved.public void setMoveAffectsSingleSubManager(boolean v)
v
- If true
(default), this accelerator moves selected objects
simultaneously only if they belong to the same submanager as the first selected
object.public boolean isMoveAffectsSingleSubManager()
public IlvGraphicEnumeration getSelectedMovingObjects(IlvManager manager)
manager
- The manager.protected boolean handleEvent(IlvManagerView v)
handleEvent
in class IlvAccelerator
v
- The manager view.protected IlvManager getMoveSelectionManager(IlvManagerView v)
isMoveAffectsSingleSubManager()
returns false
.
In this case, all moving objects must belong to the same manager.
The default implementation returns the manager for the first selected movable object.v
- The manager view receiving the events handled by this interactor.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.