public class SelectionInteractor extends CompositeInteractor
When an item is selected, events are then forwarded to other interactors. If, however, the clicked-on figure has just been removed from the figure, do not forward events.
Constructor and Description |
---|
SelectionInteractor()
Create a new SelectionInteractor with a default selection model and
a default selection renderer.
|
SelectionInteractor(SelectionModel model)
Create a new SelectionInteractor with the given selection model
and a null selection renderer.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(LayerEvent e)
Accept an event if it will be accepted by the selection
filters.
|
MouseFilter |
getSelectionFilter()
Get the mouse filter that controls when this selection
filter is activated.
|
SelectionModel |
getSelectionModel()
Get the selection model
|
SelectionRenderer |
getSelectionRenderer()
Get the selection renderer
|
MouseFilter |
getToggleFilter()
Get the mouse filter that controls the toggling of
selections
|
static boolean |
isSelected(LayerEvent e)
Given a mouse event, check that the figure it contains
as its event source is selected.
|
void |
mousePressed(LayerEvent event)
Handle a mouse press event.
|
void |
setConsuming(boolean flag)
Set the consuming flag of this interactor.
|
void |
setPrototypeDecorator(FigureDecorator decorator)
Set the prototype decorator for selected figures.
|
void |
setSelectionFilter(MouseFilter f)
Set the mouse filter that controls when this selection
filter is activated.
|
void |
setSelectionManipulator(Manipulator manipulator)
Deprecated.
Use setPrototypeDecorator instead
|
void |
setSelectionModel(SelectionModel model)
Set the selection model.
|
void |
setSelectionRenderer(SelectionRenderer r)
Set the selection renderer.
|
void |
setToggleFilter(MouseFilter f)
Set the mouse filter that controls the toggling of
selections.
|
addInteractor, interactors, isMotionEnabled, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseReleased, removeInteractor
getMouseFilter, isConsuming, isEnabled, mouseClicked, setEnabled, setMotionEnabled, setMouseFilter
public SelectionInteractor()
public SelectionInteractor(SelectionModel model)
public boolean accept(LayerEvent e)
accept
in interface Interactor
accept
in class CompositeInteractor
e
- The eventpublic MouseFilter getSelectionFilter()
public SelectionModel getSelectionModel()
public SelectionRenderer getSelectionRenderer()
public MouseFilter getToggleFilter()
public static boolean isSelected(LayerEvent e)
public void mousePressed(LayerEvent event)
mousePressed
in interface LayerListener
mousePressed
in class CompositeInteractor
event
- The eventpublic void setConsuming(boolean flag)
Note that the behaviour when the flag is false is the desired behaviour when building panes that have an interactor attached to the background. That way, the event passes through to the background if a figure is hit on but the selection interactor's filters are set up to ignore that particular event.
There is a third possibility, which is not supported: never consume events. There is no way to do this currently, as the other two behaviors seemed more likely to be useful. (Also, that behaviour is harder to implement because of interaction with the superclass.)
setConsuming
in class AbstractInteractor
flag
- The consuming flagpublic void setSelectionModel(SelectionModel model)
public void setSelectionFilter(MouseFilter f)
public void setPrototypeDecorator(FigureDecorator decorator)
this.setSelectionRenderer(new BasicSelectionRenderer(decorator);
This method nullifies any previous renderers set with setSelectionRenderer();
@Deprecated public void setSelectionManipulator(Manipulator manipulator)
public void setSelectionRenderer(SelectionRenderer r)
public void setToggleFilter(MouseFilter f)