Class 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.
    John Reekie
    • 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​(java.awt.AWTEvent event)
        Dispatch an AWT event on this layer. Currently only layer events are handled.
        Specified by:
        dispatchEvent in interface EventAcceptor
        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:
        isEnabled in interface EventAcceptor
        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:
        setEnabled in interface EventAcceptor
        flag - True if the object is prepared to handle events with processEvent();