Package diva.canvas.event
Class EventLayer
- java.lang.Object
-
- diva.canvas.CanvasLayer
-
- diva.canvas.event.EventLayer
-
- All Implemented Interfaces:
CanvasComponent,EventAcceptor
public class EventLayer extends CanvasLayer implements EventAcceptor
An event layer is a canvas layer that accepts mouse events. It is designed to be layered over or under other layers, such as FigureLayer, and accepts a number of options that control whether it consumes events and so on. Event layers can have event listeners attached to them, which will be notified when events occur.Sample uses of the event layer
- On top of a figure layer, events consumed: trap all events before they get to the figure layer.
- On top of a figure layer, events not consumed: monitor all events but still allow the figure layer to respond.
- Behind of a figure layer: catch events on the "background" of the pane, which didn't hit a figure in the figure layer.
- Version:
- $Id$
- Author:
- John Reekie
-
-
Constructor Summary
Constructors Constructor Description EventLayer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInteractor(Interactor i)Add an interactor to this interactor.voidaddLayerListener(LayerListener l)Add the given layer listener to this dispatcher.voidaddLayerMotionListener(LayerMotionListener l)Add the given layer motion listener to this dispatcher.voiddispatchEvent(java.awt.AWTEvent event)Dispatch an AWT event on this layer.java.util.Iteratorinteractors()Return an interactor over the attached interactors.booleanisConsuming()Test the consuming flag of this layer.booleanisEnabled()Test the enabled flag of this layer.protected voidprocessLayerEvent(LayerEvent event)Process a layer event.voidremoveInteractor(Interactor i)Remove the given interactor from this interactor.voidremoveLayerListener(LayerListener l)Remove the given layer listener from this dispatcher.voidremoveLayerMotionListener(LayerMotionListener l)Remove the given layer motion listener from this dispatcher.voidsetConsuming(boolean flag)Set the consuming flag of this layer.voidsetEnabled(boolean flag)Set the enabled flag of this layer.-
Methods inherited from class diva.canvas.CanvasLayer
getCanvasPane, getLayerBounds, getParent, getToolTipText, getTransformContext, repaint, repaint, setParent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface diva.canvas.CanvasComponent
getParent, getTransformContext, repaint, repaint
-
-
-
-
Method Detail
-
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.
-
addLayerListener
public void addLayerListener(LayerListener l)
Add the given layer listener to this dispatcher.
-
addLayerMotionListener
public void addLayerMotionListener(LayerMotionListener l)
Add the given layer motion listener to this dispatcher.
-
dispatchEvent
public void dispatchEvent(java.awt.AWTEvent event)
Dispatch an AWT event on this layer. Currently only layer events are handled.- Specified by:
dispatchEventin interfaceEventAcceptor- Parameters:
event- the event.
-
interactors
public java.util.Iterator interactors()
Return an interactor over the attached interactors.
-
isConsuming
public boolean isConsuming()
Test the consuming flag of this layer. If this flag is set, the layer consumes all input events.
-
isEnabled
public boolean isEnabled()
Test the enabled flag of this layer. Note that this flag does not indicate whether the layer is actually enabled, as its pane or one if its ancestors may not be enabled.- Specified by:
isEnabledin interfaceEventAcceptor- Returns:
- true if the object is prepared to handle events with processEvent()
-
processLayerEvent
protected void processLayerEvent(LayerEvent event)
Process a layer event. This method dispatches the event to any registered layer listeners or layer motion listeners, and then to any interactors. If the "consuming" flag is set, it consumes the event before returning.
-
removeInteractor
public void removeInteractor(Interactor i)
Remove the given interactor from this interactor.
-
removeLayerListener
public void removeLayerListener(LayerListener l)
Remove the given layer listener from this dispatcher.
-
removeLayerMotionListener
public void removeLayerMotionListener(LayerMotionListener l)
Remove the given layer motion listener from this dispatcher.
-
setConsuming
public void setConsuming(boolean flag)
Set the consuming flag of this layer. If this flag is set, the layer consumes all input events.
-
setEnabled
public void setEnabled(boolean flag)
Set the enabled flag of this layer. If the flag is false, then the layer will not respond to user input events.- Specified by:
setEnabledin interfaceEventAcceptor- Parameters:
flag- True if the object is prepared to handle events with processEvent();
-
-