Class ALspController

java.lang.Object
com.luciad.view.lightspeed.controller.ALspController
All Implemented Interfaces:
ILcdAWTEventListener, ILspController
Direct Known Subclasses:
ALspActionController, ALspTouchController, TLspCreateController, TLspEditController, TLspFlickerController, TLspInteractiveLabelsController, TLspMagnifierController, TLspPanController, TLspPortholeController, TLspRecenterProjectionController, TLspRotateController, TLspRulerController, TLspSelectController, TLspSwipeController, TLspTouchSelectEditController, TLspZoomByRectangleController, TLspZoomController, TLspZoomToController

public abstract class ALspController extends Object implements ILspController

A base class of ILspController that interacts with one view at a time. It automatically stores a reference to the view the controller is interacting with.

This ILspController is designed to be added in a chain of controllers. It implements startInteraction, terminateInteraction, paint and handleAWTEvent to call a corresponding implementation, and then invoke the same method in the next controller if available.

A typical controller extends this class in the following way:

  • Implement/extend the startInteractionImpl, terminateInteractionImpl, paintImpl and handleAWTEventImpl methods. Note that only events that pass the filter are handled by this controller. Other events are offered immediately to the next controller in the chain.
  • Depending on the input events, the controller will execute model, layer, view, or other changes and repaint the view when necessary.
  • for visual feedback, the controller can render on the view (see paint) and/or change the mouse cursor during the user interaction (see getCursor and setCursor()).

Note that if the controller is used with a JavaFX view, the methods handleFXEvent(javafx.event.Event), handleFXEventImpl(javafx.event.Event) and setFXFilter(com.luciad.util.ILcdFilter<javafx.event.Event>) are used instead of their AWT counterparts.

Since:
2012.0
See Also:
  • Constructor Details

    • ALspController

      protected ALspController()
    • ALspController

      protected ALspController(ILcdLayered aLayered)
  • Method Details

    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Description copied from interface: ILspController
      Adds a PropertyChangeListener to this ILspController.
      Specified by:
      addPropertyChangeListener in interface ILspController
      Parameters:
      listener - the listener
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Description copied from interface: ILspController
      Removes the given PropertyChangeListener from this ILspController.
      Specified by:
      removePropertyChangeListener in interface ILspController
      Parameters:
      listener - the listener.
    • firePropertyChange

      protected void firePropertyChange(String aPropertyName, Object aOldValue, Object aNewValue)
      Fires a property change event.
      Parameters:
      aPropertyName - the name of the property
      aOldValue - the old value
      aNewValue - the new value
    • addStatusListener

      public void addStatusListener(ILcdStatusListener aStatusListener)
      Adds a status listener to this controller. This listener will be notified when the status of the controller changes, for instance start or terminate interaction with a view.

      aStatusListener will only be added as a listener to this controller, and not to the other controllers in the chain. As such, aStatusListener will only receive TLcdStatusEvents from this controller, and not from any other other controller in the chain.

      Parameters:
      aStatusListener - the status listener to register.
    • removeStatusListener

      public void removeStatusListener(ILcdStatusListener aStatusListener)
      Removes a status listener to this controller. Nothing happens if the listener was not registered.

      aStatusListener will only be removed as a listener from this controller, and not from any other controllers in the chain it might be registered to. As such, aStatusListener will still receive TLcdStatusEvents from other controllers it was registered to, just not from this controller anymore.

      Parameters:
      aStatusListener - the status listener to unregister.
    • fireStatusEvent

      protected void fireStatusEvent(TLcdStatusEvent aStatusEvent)
      Fires a status changed event to registered listeners.
      Parameters:
      aStatusEvent - the event to fire.
    • registerViewPropertyNameForReset

      protected final void registerViewPropertyNameForReset(String aViewPropertyName)
      Registers the name of a property of the ILspView on which this controller is dependent. When the view fires a PropertyChangeEvent corresponding to this property, the controller will "reset" itself by invoking its own terminateInteraction and startInteraction methods. As an example, this method can be used to make a controller receive a notification when the view's world reference changes.
      Parameters:
      aViewPropertyName - the name of the property for which this controller should listen
    • startInteraction

      public void startInteraction(ILspView aView)
      Called to start interacting with the controller. This automatically happens when setting the controller on the view using ILspView.setController(com.luciad.view.lightspeed.controller.ILspController).

      This implementation sends out a status event based on the short description. It also calls startInteraction on the next controller. Override startInteractionImpl if you want to add your own behavior to this controller.

      Specified by:
      startInteraction in interface ILspController
      Parameters:
      aView - the view the controller operates on
    • terminateInteraction

      public void terminateInteraction(ILspView aView)
      Terminates interaction with this controller. This automatically happens when setting a different controller on the view using ILspView.setController(com.luciad.view.lightspeed.controller.ILspController).

      This implementation also calls terminateInteraction on the next controller. Override terminateInteractionImpl if you want to add your own behavior to this controller.

      Specified by:
      terminateInteraction in interface ILspController
      Parameters:
      aView - the view the controller was operating on
    • paint

      public TLspPaintProgress paint(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase)
      Paints the visual feedback of this controller.

      This method is called multiple times for different paint phases.

      Empty implementation. Redefine paintImpl(com.luciad.view.opengl.binding.ILcdGLDrawable, com.luciad.view.lightspeed.ILspView, com.luciad.view.lightspeed.TLspPaintPhase) method to render on the ILcdGLDrawable on which the view is rendered.

      Specified by:
      paint in interface ILspController
      Parameters:
      aGLDrawable - the ILcdGLDrawable on which the view is rendered.
      aView - the view.
      aPaintPhase - the current paint phase
      Returns:
      whether or not the painting was finished.
    • getView

      public ILspView getView()
      Returns the ILspView the controller is interacting with.
      Returns:
      the ILspView the controller is interacting with, or null if the controller is not interacting with a view.
    • getCursor

      public Cursor getCursor()
      Returns the mouse cursor for this controller. The cursor is typically retrieved by the view to configure its host component.
      This method returns the cursor for this controller, not the rest of chain.

      However, the property change listeners of the controller will be informed about cursor changes for the entire controller chain. A cursor property change event's value will be the first non-null cursor along the controller chain.

      For JavaFX, see {#link getFXCursor()}.

      Returns:
      the cursor for this controller, or null if the controller does not have a specific cursor
      See Also:
    • getFXCursor

      public Cursor getFXCursor()
      JavaFX equivalent of getCursor().
      Returns:
      the JavaFX cursor for this controller, or null if the controller does not have a specific cursor
      Since:
      2020.0
      See Also:
    • setCursor

      public void setCursor(Cursor aCursor)
      Sets the AWT mouse cursor for this controller. For JavaFX, see setFXCursor(javafx.scene.Cursor).
      Parameters:
      aCursor - the cursor for this controller, or null if the controller does not have a specific cursor
      See Also:
    • setFXCursor

      public void setFXCursor(Cursor aCursor)
      JavaFX equivalent of setCursor(Cursor), to be used when this controller is active in a TLspFXView.
      Parameters:
      aCursor - the cursor for this controller, or null if the controller does not have a specific cursor
      Since:
      2020.0
      See Also:
    • setName

      public void setName(String aName)
      Parameters:
      aName - the name to associate to this ILspController
    • getName

      public String getName()
      Description copied from interface: ILspController
      Gets the name of this controller.
      Specified by:
      getName in interface ILspController
      Returns:
      the name associated to this ILspController
    • setShortDescription

      public void setShortDescription(String aShortDescription)
      Parameters:
      aShortDescription - the short description to associate to this ILspController
    • getShortDescription

      public String getShortDescription()
      Description copied from interface: ILspController
      Gets a short description for this controller.
      Specified by:
      getShortDescription in interface ILspController
      Returns:
      the short description associated to this ILspController
    • setIcon

      public void setIcon(ILcdIcon aIcon)
      Parameters:
      aIcon - the ILcdIcon to associate to this ILspController
    • getIcon

      public ILcdIcon getIcon()
      Description copied from interface: ILspController
      Gets the icon that is used for example on buttons in the graphical user interface to identify this controller.
      Specified by:
      getIcon in interface ILspController
      Returns:
      the ILcdIcon associated to this ILspController
    • getAWTFilter

      public ILcdFilter<AWTEvent> getAWTFilter()
      Returns the currently used AWT event filter.
      Returns:
      the current AWT event filter
      See Also:
    • setAWTFilter

      public void setAWTFilter(ILcdFilter<AWTEvent> aAWTFilter)
      Registers a filter for this controller. Only events that are accepted will be handled by this controller. Other events will be delegated to the next controller in the chain. Set this filter to null to disable filtering.
      Parameters:
      aAWTFilter - a event filter.
      See Also:
    • getFXFilter

      public ILcdFilter<Event> getFXFilter()
      Returns the currently used FX event filter.
      Returns:
      the current FX event filter
      Since:
      2020.0
      See Also:
    • setFXFilter

      public void setFXFilter(ILcdFilter<Event> aFXFilter)
      Registers a filter for this controller. Only events that are accepted will be handled by this controller. Other events will be delegated to the next controller in the chain. Set this filter to null to disable filtering.
      Parameters:
      aFXFilter - a event filter.
      Since:
      2019.0
    • getNextController

      public ILspController getNextController()
      Description copied from interface: ILspController
      Returns a reference to the controller that is located after this one in a chain, or null if this controller is the last element of the chain.

      Note that this reference is not allowed to change while the controller is attached to a view directly or indirectly.

      Specified by:
      getNextController in interface ILspController
      Returns:
      a reference to the next controller.
      See Also:
    • appendController

      public void appendController(ILspController aEnd)
      Description copied from interface: ILspController
      This method will append the passed controller to the end of the chain. The controller will be stored as the next controller in the last element of the current chain.

      Note that this method is not allowed to be called while the controller is attached to a view directly or indirectly. Unattach the controller first, before calling this method.

      Specified by:
      appendController in interface ILspController
      Parameters:
      aEnd - the controller to be appended to the end of the chain.
    • getLayered

      public ILcdLayered getLayered()
      Description copied from interface: ILspController

      Returns an ILcdLayered for this controller. Custom implementations of this method should take care to return the same ILcdLayered instance every time this method is called to guarantee correct working of the ILcdLayered interface.

      The returned layered object should contain layers that are relevant to this controller. Any view using this controller should take into account the layers of its active controller.

      Note that the ILcdLayered is only allowed to contain ILspLayer instances.

      Specified by:
      getLayered in interface ILspController
      Returns:
      an ILcdLayered object, or null if this controller has no layers.
    • startInteractionImpl

      protected void startInteractionImpl(ILspView aView)
      The specific implementation of startInteraction for this controller.
      Parameters:
      aView - the view to start interaction with.
    • terminateInteractionImpl

      protected void terminateInteractionImpl(ILspView aView)
      The specific implementation of terminateInteraction for this controller.
      Parameters:
      aView - the view to terminate interaction with.
    • paintImpl

      protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase)
      The specific implementation of paint for this controller.
      Parameters:
      aGLDrawable - the drawable that should be painted on
      aView - the view that is painted on
      aPaintPhase - the current paint phase
      Returns:
      whether or not the painting was finished
    • handleAWTEvent

      public void handleAWTEvent(AWTEvent aAWTEvent)
      Delegates to handleAWTEventImpl. If that method does not return null, the result is passed on to the next controller in the chain (if one exists). If the controller has a filter that does not accept the event, the event is not delegated and is immediately passed on to the next controller.
      Specified by:
      handleAWTEvent in interface ILcdAWTEventListener
      Parameters:
      aAWTEvent - the event to be handled
    • handleAWTEventImpl

      public abstract AWTEvent handleAWTEventImpl(AWTEvent aAWTEvent)
      Called by handleAWTEvent. Returns null when the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen with TLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.
      Parameters:
      aAWTEvent - the event to be handled.
      Returns:
      null when the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
    • handleFXEvent

      public void handleFXEvent(Event aEvent)
      Delegates to handleFXEventImpl. If that method does not return null, the result is passed on to the next controller in the chain (if one exists). If the controller has a filter that does not accept the event, the event is not delegated and is immediately passed on to the next controller.
      Specified by:
      handleFXEvent in interface ILspController
      Parameters:
      aEvent - the event to be handled
      Since:
      2019.0
    • handleFXEventImpl

      public Event handleFXEventImpl(Event aEvent)
      Called by handleFXEvent. Returns null when the controller consumed the event. When the controller did not use the given event, it is returned unaltered.
      Parameters:
      aEvent - the event to be handled.
      Returns:
      null when the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
      Since:
      2019.0