diva.canvas.event
Class EventLayer

java.lang.Object
  extended by diva.canvas.CanvasLayer
      extended by 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

Version:
$Revision: 1.16 $
Author:
John Reekie

Constructor Summary
EventLayer()
           
 
Method Summary
 void addInteractor(Interactor i)
          Add an interactor to this interactor.
 void addLayerListener(LayerListener l)
          Add the given layer listener to this dispatcher.
 void addLayerMotionListener(LayerMotionListener l)
          Add the given layer motion listener to this dispatcher.
 void dispatchEvent(AWTEvent event)
          Dispatch an AWT event on this layer.
 Iterator interactors()
          Return an iteractor over the attached interactors.
 boolean isConsuming()
          Test the consuming flag of this layer.
 boolean isEnabled()
          Test the enabled flag of this layer.
protected  void processLayerEvent(LayerEvent event)
          Process a layer event.
 void removeInteractor(Interactor i)
          Remove the given interactor from this interactor.
 void removeLayerListener(LayerListener l)
          Remove the given layer listener from this dispatcher.
 void removeLayerMotionListener(LayerMotionListener l)
          Remove the given layer motion listener from this dispatcher.
 void setConsuming(boolean flag)
          Set the consuming flag of this layer.
 void setEnabled(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
 

Constructor Detail

EventLayer

public EventLayer()
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(AWTEvent event)
Dispatch an AWT event on this layer. Currently only layer events are handled.

Specified by:
dispatchEvent in interface EventAcceptor

interactors

public Iterator interactors()
Return an iteractor 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:
isEnabled in interface EventAcceptor

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:
setEnabled in interface EventAcceptor


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.