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 boolean
accept(LayerEvent e)
Accept an event if any attached interactor will accept it.void
addInteractor(Interactor i)
Add an interactor to this interactor.java.util.Iterator
interactors()
Return an interactor over the attached interactors.boolean
isMotionEnabled()
Return true if any contained interactor is motion enabled.void
mouseDragged(LayerEvent event)
Handle a mouse drag event.void
mouseEntered(LayerEvent event)
Handle a mouse entered event.void
mouseExited(LayerEvent event)
Handle a mouse exited event.void
mouseMoved(LayerEvent event)
Handle a mouse moved event.void
mousePressed(LayerEvent event)
Handle a mouse press event.void
mouseReleased(LayerEvent event)
Handle a mouse released event.void
removeInteractor(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:
accept
in interfaceInteractor
- Overrides:
accept
in 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:
isMotionEnabled
in interfaceInteractor
- Overrides:
isMotionEnabled
in 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:
mouseDragged
in interfaceLayerListener
- Overrides:
mouseDragged
in 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:
mouseEntered
in interfaceLayerMotionListener
- Overrides:
mouseEntered
in 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:
mouseExited
in interfaceLayerMotionListener
- Overrides:
mouseExited
in 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:
mouseMoved
in interfaceLayerMotionListener
- Overrides:
mouseMoved
in 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:
mousePressed
in interfaceLayerListener
- Overrides:
mousePressed
in 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:
mouseReleased
in interfaceLayerListener
- Overrides:
mouseReleased
in classAbstractInteractor
- Parameters:
event
- The event
-
removeInteractor
public void removeInteractor(Interactor i)
Remove the given interactor from this interactor.
-
-