public final class InputActionBindings extends Object
ActionMap
s and InputMap
s, which are
chained to a concatenated InputMap
and a
concatenated ActionMap
. Maps can be added
and will be chained in reverse order of addition, that is, the last added map
overrides all previous ones. For added InputMap
s it is possible to
block maps that were added earlier.Constructor and Description |
---|
InputActionBindings()
|
InputActionBindings(InputMap leafInputMap)
|
Modifier and Type | Method and Description |
---|---|
void |
addActionMap(int index,
String id,
ActionMap actionMap)
Add as
ActionMap with the specified id at the specified position
in the list (overrides maps at lower positions). |
void |
addActionMap(String id,
ActionMap actionMap)
Add as
ActionMap with the specified id to the end of the list
(overrides maps that were added earlier). |
void |
addInputMap(int index,
String id,
InputMap inputMap,
Collection<String> idsToBlock)
Inserts a
InputMap with the specified id at the specified
position in the list (overrides maps at lower positions). |
void |
addInputMap(int index,
String id,
InputMap inputMap,
String... idsToBlock)
Inserts a
InputMap with the specified id at the specified
position in the list (overrides maps at lower positions). |
void |
addInputMap(String id,
InputMap inputMap,
Collection<String> idsToBlock)
Adds a
InputMap with the specified id to the end of the list
(overrides maps that were added earlier). |
void |
addInputMap(String id,
InputMap inputMap,
String... idsToBlock)
Adds a
InputMap with the specified id to the end of the list
(overrides maps that were added earlier). |
ActionMap |
getConcatenatedActionMap()
Get the chained
ActionMap . |
InputMap |
getConcatenatedInputMap()
Get the chained
InputMap . |
static InputActionBindings |
installNewBindings(JComponent component,
int condition,
boolean replaceExistingMaps)
Creates a new
InputActionBindings and installs it into
component , either augmenting or replacing component s
existing InputMap and ActionMap . |
void |
removeActionMap(String id)
Remove the
ActionMap with the given id from the list. |
void |
removeInputMap(String id)
Remove the
InputMap with the given id from the list. |
void |
setParentActionMap(ActionMap parent)
Set existing parent ActionMap, which is managed outside of this
InputActionBindings and serves as a parent for the whole chain.
|
void |
setParentInputMap(InputMap parent)
Set existing parent InputMap, which is managed outside of this
InputActionBindings and serves as a parent for the whole chain.
|
public InputActionBindings()
public InputActionBindings(InputMap leafInputMap)
ActionMap
and set the given leaf
InputMap
.
This constructor is intended for use with
JComponent.WHEN_IN_FOCUSED_WINDOW
. In this case, a
ComponentInputMap
for the correct JComponent
is required.
leafInputMap
- the leaf InputMap
.public void removeActionMap(String id)
ActionMap
with the given id from the list.public void setParentActionMap(ActionMap parent)
public void addInputMap(String id, InputMap inputMap, String... idsToBlock)
InputMap
with the specified id to the end of the list
(overrides maps that were added earlier). If the specified id already
exists in the list, remove the corresponding earlier InputMap
.
If idsToBlock
are given, InputMap
s with these ids earlier
in the chain that should be disabled. The special id "all" blocks all
earlier InputMap
s.
id
- inputMap
- idsToBlock
- ids of InputMap
s earlier in the chain that should be
disabled.public void addInputMap(String id, InputMap inputMap, Collection<String> idsToBlock)
InputMap
with the specified id to the end of the list
(overrides maps that were added earlier). If the specified id already
exists in the list, remove the corresponding earlier InputMap
.
If idsToBlock
are given, InputMap
s with these ids earlier
in the chain that should be disabled. The special id "all" blocks all
earlier InputMap
s.
id
- inputMap
- idsToBlock
- ids of InputMap
s earlier in the chain that should be
disabled.public void addInputMap(int index, String id, InputMap inputMap, String... idsToBlock)
InputMap
with the specified id at the specified
position in the list (overrides maps at lower positions). If the
specified id already exists in the list, remove the corresponding earlier
InputMap
.
If idsToBlock
are given, InputMap
s with these ids earlier
in the chain that should be disabled. The special id "all" blocks all
earlier InputMap
s.
index
- id
- inputMap
- idsToBlock
- ids of InputMap
s earlier in the chain that should be
disabled.public void addInputMap(int index, String id, InputMap inputMap, Collection<String> idsToBlock)
InputMap
with the specified id at the specified
position in the list (overrides maps at lower positions). If the
specified id already exists in the list, remove the corresponding earlier
InputMap
.
If idsToBlock
are given, InputMap
s with these ids earlier
in the chain that should be disabled. The special id "all" blocks all
earlier InputMap
s.
index
- id
- inputMap
- idsToBlock
- ids of InputMap
s earlier in the chain that should be
disabled.public void removeInputMap(String id)
InputMap
with the given id from the list.public void setParentInputMap(InputMap parent)
public InputMap getConcatenatedInputMap()
public ActionMap getConcatenatedActionMap()
public static InputActionBindings installNewBindings(JComponent component, int condition, boolean replaceExistingMaps)
InputActionBindings
and installs it into
component
, either augmenting or replacing component
s
existing InputMap
and ActionMap
.component
- the component whose InputMap
and ActionMap
to set.condition
- one of JComponent.WHEN_IN_FOCUSED_WINDOW
,
WHEN_IN_FOCUSED_WINDOW
,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
.replaceExistingMaps
- if true
, the existing InputMap
and ActionMap
will be replaced. If false
, the existing maps will become the
parents of the new ones.InputActionBindings
Copyright © 2015–2022 SciJava. All rights reserved.