Package diva.canvas.interactor
Class CompositeInteractor
- java.lang.Object
-
- diva.canvas.interactor.AbstractInteractor
-
- diva.canvas.interactor.CompositeInteractor
-
- All Implemented Interfaces:
LayerListener,LayerMotionListener,Interactor,java.util.EventListener
- Direct Known Subclasses:
SelectionInteractor
public class CompositeInteractor extends AbstractInteractor
An interactor that forwards events to other interactors.- Version:
- $Id$
- Author:
- John Reekie
-
-
Constructor Summary
Constructors Constructor Description CompositeInteractor()Create a new composite interactor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(LayerEvent e)Accept an event if any attached interactor will accept it.voidaddInteractor(Interactor i)Add an interactor to this interactor.java.util.Iteratorinteractors()Return an interactor over the attached interactors.booleanisMotionEnabled()Return true if any contained interactor is motion enabled.voidmouseDragged(LayerEvent event)Handle a mouse drag event.voidmouseEntered(LayerEvent event)Handle a mouse entered event.voidmouseExited(LayerEvent event)Handle a mouse exited event.voidmouseMoved(LayerEvent event)Handle a mouse moved event.voidmousePressed(LayerEvent event)Handle a mouse press event.voidmouseReleased(LayerEvent event)Handle a mouse released event.voidremoveInteractor(Interactor i)Remove the given interactor from this interactor.-
Methods inherited from class diva.canvas.interactor.AbstractInteractor
getMouseFilter, isConsuming, isEnabled, mouseClicked, setConsuming, setEnabled, setMotionEnabled, setMouseFilter
-
-
-
-
Method Detail
-
accept
public boolean accept(LayerEvent e)
Accept an event if any attached interactor will accept it.- Specified by:
acceptin interfaceInteractor- Overrides:
acceptin classAbstractInteractor- Parameters:
e- The event
-
addInteractor
public void addInteractor(Interactor i)
Add an interactor to this interactor. The added interactor will have events forwarded to it if it accepts the event.
-
interactors
public java.util.Iterator interactors()
Return an interactor over the attached interactors.
-
isMotionEnabled
public boolean isMotionEnabled()
Return true if any contained interactor is motion enabled.- Specified by:
isMotionEnabledin interfaceInteractor- Overrides:
isMotionEnabledin classAbstractInteractor- Returns:
- true if the interactor is motion enabled
-
mouseDragged
public void mouseDragged(LayerEvent event)
Handle a mouse drag event. If there's a current interactor receiving events, pass the event to it.- Specified by:
mouseDraggedin interfaceLayerListener- Overrides:
mouseDraggedin classAbstractInteractor- Parameters:
event- The event
-
mouseEntered
public void mouseEntered(LayerEvent event)
Handle a mouse entered event. If this interactor is not enabled, return immediately. For each interactor, see if it will accept the event, and if it will, pass this event and the subsequent motion and exited events to it.- Specified by:
mouseEnteredin interfaceLayerMotionListener- Overrides:
mouseEnteredin classAbstractInteractor- Parameters:
event- The event
-
mouseExited
public void mouseExited(LayerEvent event)
Handle a mouse exited event. If there is a current interactor receiving motion events, pass the event to it.- Specified by:
mouseExitedin interfaceLayerMotionListener- Overrides:
mouseExitedin classAbstractInteractor- Parameters:
event- The event
-
mouseMoved
public void mouseMoved(LayerEvent event)
Handle a mouse moved event. If there is a current interactor receiving motion events, pass the event to it.- Specified by:
mouseMovedin interfaceLayerMotionListener- Overrides:
mouseMovedin classAbstractInteractor- Parameters:
event- The event
-
mousePressed
public void mousePressed(LayerEvent event)
Handle a mouse press event. If this interactor is enabled, call each attached interactor's accept() event. Pass the event to the first one that accepts the event, and remember it to forward subsequent events to. Continue this process for all attached interactors until the event is consumed.- Specified by:
mousePressedin interfaceLayerListener- Overrides:
mousePressedin classAbstractInteractor- Parameters:
event- The event
-
mouseReleased
public void mouseReleased(LayerEvent event)
Handle a mouse released event. If there's a current interactor receiving events, pass the event to it.- Specified by:
mouseReleasedin interfaceLayerListener- Overrides:
mouseReleasedin classAbstractInteractor- Parameters:
event- The event
-
removeInteractor
public void removeInteractor(Interactor i)
Remove the given interactor from this interactor.
-
-