|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdiva.canvas.interactor.AbstractInteractor
diva.canvas.interactor.CompositeInteractor
diva.canvas.interactor.SelectionInteractor
public class SelectionInteractor
A SelectionInteractor is attached to an object that can be put into and out of a selection. Associated with each such role is a selection model, which is the selection that figures are added to or removed from. When a mouse pressed event has occurred, all figures associated with the same SelectionModel will be unselected before the new one is selected. So, to make sure only one figure is selected at a time, do this: SelectionModel m = new SelectionModel(); SelectionInteractor s1 = new SelectionInteractor(m); SelectionInteractor s2 = new SelectionInteractor(m);
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.
Field Summary | |
---|---|
private SelectionRenderer |
_renderer
The selection renderer |
private SelectionModel |
_selection
The selection model |
private MouseFilter |
_selectionFilter
The mouse filter for selecting items |
private MouseFilter |
_toggleFilter
The mouse filter for toggling items |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class diva.canvas.interactor.CompositeInteractor |
---|
addInteractor, interactors, isMotionEnabled, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseReleased, removeInteractor |
Methods inherited from class diva.canvas.interactor.AbstractInteractor |
---|
getMouseFilter, isConsuming, isEnabled, mouseClicked, setEnabled, setMotionEnabled, setMouseFilter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private SelectionModel _selection
private SelectionRenderer _renderer
private MouseFilter _selectionFilter
private MouseFilter _toggleFilter
Constructor Detail |
---|
public SelectionInteractor()
public SelectionInteractor(SelectionModel model)
Method Detail |
---|
public boolean accept(LayerEvent e)
accept
in interface Interactor
accept
in class CompositeInteractor
public 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
public 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
public 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();
public void setSelectionManipulator(Manipulator manipulator)
public void setSelectionRenderer(SelectionRenderer r)
public void setToggleFilter(MouseFilter f)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |