diva.canvas.interactor
Class CompositeInteractor

java.lang.Object
  extended by diva.canvas.interactor.AbstractInteractor
      extended by 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: CompositeInteractor.java 53042 2009-04-10 20:31:21Z cxh $
Author:
John Reekie

Field Summary
private  Interactor _currentInteractor
          The current interactor
private  java.util.ArrayList<Interactor> _interactors
          The list of attached interactors
 
Constructor Summary
CompositeInteractor()
          Create a new composite interactor.
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_interactors

private java.util.ArrayList<Interactor> _interactors
The list of attached interactors


_currentInteractor

private Interactor _currentInteractor
The current interactor

Constructor Detail

CompositeInteractor

public CompositeInteractor()
Create a new composite interactor. [The following is currently not true: By default, composite interactors do not consume events.]

Method Detail

accept

public boolean accept(LayerEvent e)
Accept an event if any attached interactor will accept it.

Specified by:
accept in interface Interactor
Overrides:
accept in class AbstractInteractor

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 interface Interactor
Overrides:
isMotionEnabled in class AbstractInteractor

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 interface LayerListener
Overrides:
mouseDragged in class AbstractInteractor

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 interface LayerMotionListener
Overrides:
mouseEntered in class AbstractInteractor

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 interface LayerMotionListener
Overrides:
mouseExited in class AbstractInteractor

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 interface LayerMotionListener
Overrides:
mouseMoved in class AbstractInteractor

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 interface LayerListener
Overrides:
mousePressed in class AbstractInteractor

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 interface LayerListener
Overrides:
mouseReleased in class AbstractInteractor

removeInteractor

public void removeInteractor(Interactor i)
Remove the given interactor from this interactor.