public class IlvCycleSelectAccelerator extends IlvAccelerator
IlvCycleSelectAccelerator
allows the user to
select the objects in a manager using the keyboard.
At each specified key event, it causes the next object to be selected.
After the last object, the first object is selected again.
The accelerator has options that determine whether nodes, links, subgraphs,
or other objects get selected, whether the selections descend into expanded
subgraphs, and whether the selection order is forwards or backwards.
The following code example shows how to use
IlvCycleSelectAccelerator
in a simple Java application:
// ensure that the manager view receives the TAB key events managerView.setFocusTraversalKeysEnabled(false); // Install the select accelerator manager.addAccelerator( new IlvCycleSelectAccelerator(KeyEvent.KEY_PRESSED, KeyEvent.VK_TAB, 0, true));
All input events are handled by means of interactors or accelerators. Accelerators,
such as IlvCycleSelectAccelerator
, 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 |
---|
IlvCycleSelectAccelerator(int type,
int keyCode,
char keyChar,
int modifiers,
boolean consumeEvents)
Creates an
IlvCycleSelectAccelerator . |
IlvCycleSelectAccelerator(int type,
int keyCode,
int modifiers)
Creates an
IlvCycleSelectAccelerator . |
IlvCycleSelectAccelerator(int type,
int keyCode,
int modifiers,
boolean consumeEvents)
Creates an
IlvCycleSelectAccelerator . |
IlvCycleSelectAccelerator(KeyStroke keystroke,
boolean consumeEvents)
Creates an
IlvCycleSelectAccelerator associated with the specified
key stroke. |
Modifier and Type | Method and Description |
---|---|
protected boolean |
endOfSequence(IlvGraphic g)
This method is called when the last object of the selection sequence
was already selected and the accelerator key is pressed once more.
|
Comparator<IlvGraphic> |
getComparator()
Returns the comparator that defines the order of the selection
sequence.
|
protected IlvGraphic |
getNext(IlvManagerView v,
IlvGraphic selected)
Returns the next object to select, if the input object is selected.
|
protected boolean |
handleEvent(IlvManagerView v)
Processes the event.
|
boolean |
isDescendIntoExpandedSubgraphsAllowed()
Returns whether the accelerator will descend the selection cycle into
the inner nodes of nested subgraphs.
|
boolean |
isEnsureVisible()
Returns whether the view is translated so that the object that
gets selected by this accelerator is visible in the view.
|
boolean |
isForward()
Returns whether the selection cycles in the forward direction.
|
protected boolean |
isSelectable(IlvGraphic g)
Returns true if the input object is selectable.
|
boolean |
isSelectExpandedSubgraphsAllowed()
Returns whether the accelerator will select nodes that are
expanded subgraphs.
|
boolean |
isSelectLinksAllowed()
Returns whether the accelerator will select links in a grapher.
|
boolean |
isSelectNodesAllowed()
Returns whether the accelerator will select nodes that are not
expanded subgraphs.
|
boolean |
isSelectNonNodesOrLinksAllowed()
Returns whether the accelerator will select objects that are not
nodes or links in a grapher.
|
void |
setComparator(Comparator<IlvGraphic> c)
Sets the comparator that defines the order of the selection
sequence.
|
void |
setDescendIntoExpandedSubgraphsAllowed(boolean allowed)
Sets whether the accelerator will descend the selection cycle into
the inner nodes of nested subgraphs.
|
void |
setEnsureVisible(boolean ensure)
Sets whether the view is translated so that the object that
gets selected by this accelerator is visible in the view.
|
void |
setForward(boolean forward)
Sets whether the selection cycles in the forward direction.
|
void |
setSelectExpandedSubgraphsAllowed(boolean allowed)
Sets whether the accelerator will select nodes that are
expanded subgraphs.
|
void |
setSelectLinksAllowed(boolean allowed)
Sets whether the accelerator will select links in a grapher.
|
void |
setSelectNodesAllowed(boolean allowed)
Sets whether the accelerator will select nodes that are not
expanded subgraphs.
|
void |
setSelectNonNodesOrLinksAllowed(boolean allowed)
Sets whether the accelerator will select objects that are not
nodes or links in a grapher.
|
CtrlChar, getEventType, getKeyChar, getKeyCode, getModifier, isConsumeEvents, setConsumeEvents
public IlvCycleSelectAccelerator(KeyStroke keystroke, boolean consumeEvents)
IlvCycleSelectAccelerator
associated with the specified
key stroke.keystroke
- The key stroke associated with the accelerator.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 IlvCycleSelectAccelerator(int type, int keyCode, char keyChar, int modifiers, boolean consumeEvents)
IlvCycleSelectAccelerator
.
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.
If you are creating accelerators that have the same key code or key character
and have intersecting sets of modifiers, then use
IlvCycleSelectAccelerator(KeyStroke, boolean)
instead. An example is if you want to define an accelerator that responds to a
key character while the CTRL modifier is pressed and a different accelerator that
will respond to the same key character while both the CTRL and ALT modifiers are
pressed. Accelerators created from key strokes match more accurately against
modifier combinations.
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.IlvCycleSelectAccelerator(KeyStroke, boolean)
public IlvCycleSelectAccelerator(int type, int keyCode, int modifiers, boolean consumeEvents)
IlvCycleSelectAccelerator
.
If you are creating
accelerators that have the same key code and have intersecting sets of modifiers, then use
IlvCycleSelectAccelerator(KeyStroke, boolean)
instead. An example is if you
want to define an accelerator that responds to a key code while the CTRL modifier is
pressed and a different accelerator that will respond to the same key code while both
the CTRL and ALT modifiers are pressed. Accelerators created from key strokes match
more accurately against modifier combinations.
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.IlvCycleSelectAccelerator(KeyStroke, boolean)
public IlvCycleSelectAccelerator(int type, int keyCode, int modifiers)
IlvCycleSelectAccelerator
. By default, the accelerator cycles
though all nodes and descends into subgraphs, but never selects a link.
If you are creating
accelerators that have the same key code and have intersecting sets of modifiers, then use
IlvCycleSelectAccelerator(KeyStroke, boolean)
instead. An example is if you
want to define an accelerator that responds to a key code while the CTRL modifier is
pressed and a different accelerator that will respond to the same key code while both
the CTRL and ALT modifiers are pressed. Accelerators created from key strokes match
more accurately against modifier combinations.
type
- The type of the AWT event.keyCode
- The code associated with the key.modifiers
- The modifiers of the key.IlvCycleSelectAccelerator(KeyStroke, boolean)
protected boolean handleEvent(IlvManagerView v)
handleEvent
in class IlvAccelerator
v
- The manager view.protected IlvGraphic getNext(IlvManagerView v, IlvGraphic selected)
v
- The current view.selected
- The currenly selected object. Pass null
to find the first object to be selected.null
, if there are no more
objects to select.protected boolean isSelectable(IlvGraphic g)
protected boolean endOfSequence(IlvGraphic g)
false
.g
- The object to be selected next. Can be null if no objects are
selectable at all.public boolean isSelectNonNodesOrLinksAllowed()
public void setSelectNonNodesOrLinksAllowed(boolean allowed)
public boolean isSelectNodesAllowed()
public void setSelectNodesAllowed(boolean allowed)
public boolean isSelectLinksAllowed()
public void setSelectLinksAllowed(boolean allowed)
public boolean isSelectExpandedSubgraphsAllowed()
public void setSelectExpandedSubgraphsAllowed(boolean allowed)
public boolean isDescendIntoExpandedSubgraphsAllowed()
public void setDescendIntoExpandedSubgraphsAllowed(boolean allowed)
public boolean isForward()
public void setForward(boolean forward)
public boolean isEnsureVisible()
public void setEnsureVisible(boolean ensure)
public Comparator<IlvGraphic> getComparator()
public void setComparator(Comparator<IlvGraphic> c)
null
is passed, the canonical object order of
the manager is used.
For instance, you can pass a comparator that compares the bounding box
of the graphic objects in x direction, so that the selection sequence
follows the x direction.
Hint: when passing a comparator that compares coordinates of graphic objects and descending the selection cycle into subgraphs, it is useful to enable selection invariant submanager bounds on all subgraphs. Otherwise, each selection step may change the bounds of the subgraphs and hence change the order of the selection cycle in unexpected ways.
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.