Class 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
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,paintImplandhandleAWTEventImplmethods. Note that only events that pass thefilterare 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 (seegetCursorandsetCursor()).
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds aPropertyChangeListenerto thisILspController.voidaddStatusListener(ILcdStatusListener aStatusListener) Adds a status listener to this controller.voidThis method will append the passed controller to the end of the chain.protected voidfirePropertyChange(String aPropertyName, Object aOldValue, Object aNewValue) Fires a property change event.protected voidfireStatusEvent(TLcdStatusEvent aStatusEvent) Fires a status changed event to registered listeners.Returns the currently used AWT event filter.Returns the mouse cursor for this controller.JavaFX equivalent ofgetCursor().Returns the currently used FX event filter.getIcon()Gets the icon that is used for example on buttons in the graphical user interface to identify this controller.Returns anILcdLayeredfor this controller.getName()Gets the name of this controller.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.Gets a short description for this controller.getView()Returns theILspViewthe controller is interacting with.voidhandleAWTEvent(AWTEvent aAWTEvent) Delegates tohandleAWTEventImpl.abstract AWTEventhandleAWTEventImpl(AWTEvent aAWTEvent) Called byhandleAWTEvent.voidhandleFXEvent(Event aEvent) Delegates tohandleFXEventImpl.handleFXEventImpl(Event aEvent) Called byhandleFXEvent.paint(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) Paints the visual feedback of this controller.protected TLspPaintProgresspaintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaintfor this controller.protected final voidregisterViewPropertyNameForReset(String aViewPropertyName) Registers the name of a property of theILspViewon which this controller is dependent.voidRemoves the givenPropertyChangeListenerfrom thisILspController.voidremoveStatusListener(ILcdStatusListener aStatusListener) Removes a status listener to this controller.voidsetAWTFilter(ILcdFilter<AWTEvent> aAWTFilter) Registers a filter for this controller.voidSets the AWT mouse cursor for this controller.voidsetFXCursor(Cursor aCursor) JavaFX equivalent ofsetCursor(Cursor), to be used when this controller is active in aTLspFXView.voidsetFXFilter(ILcdFilter<Event> aFXFilter) Registers a filter for this controller.voidvoidvoidsetShortDescription(String aShortDescription) voidstartInteraction(ILspView aView) Called to start interacting with the controller.protected voidstartInteractionImpl(ILspView aView) The specific implementation ofstartInteractionfor this controller.voidterminateInteraction(ILspView aView) Terminates interaction with this controller.protected voidterminateInteractionImpl(ILspView aView) The specific implementation ofterminateInteractionfor this controller.
-
Constructor Details
-
ALspController
protected ALspController() -
ALspController
-
-
Method Details
-
addPropertyChangeListener
Description copied from interface:ILspControllerAdds aPropertyChangeListenerto thisILspController.- Specified by:
addPropertyChangeListenerin interfaceILspController- Parameters:
listener- the listener
-
removePropertyChangeListener
Description copied from interface:ILspControllerRemoves the givenPropertyChangeListenerfrom thisILspController.- Specified by:
removePropertyChangeListenerin interfaceILspController- Parameters:
listener- the listener.
-
firePropertyChange
Fires a property change event.- Parameters:
aPropertyName- the name of the propertyaOldValue- the old valueaNewValue- the new value
-
addStatusListener
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.aStatusListenerwill only be added as a listener to this controller, and not to the other controllers in the chain. As such,aStatusListenerwill only receiveTLcdStatusEvents from this controller, and not from any other other controller in the chain.- Parameters:
aStatusListener- the status listener to register.
-
removeStatusListener
Removes a status listener to this controller. Nothing happens if the listener was not registered.aStatusListenerwill 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,aStatusListenerwill still receiveTLcdStatusEvents from other controllers it was registered to, just not from this controller anymore.- Parameters:
aStatusListener- the status listener to unregister.
-
fireStatusEvent
Fires a status changed event to registered listeners.- Parameters:
aStatusEvent- the event to fire.
-
registerViewPropertyNameForReset
Registers the name of a property of theILspViewon which this controller is dependent. When the view fires aPropertyChangeEventcorresponding to this property, the controller will "reset" itself by invoking its ownterminateInteractionandstartInteractionmethods. 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
Called to start interacting with the controller. This automatically happens when setting the controller on the view usingILspView.setController(com.luciad.view.lightspeed.controller.ILspController). This implementation sends out a status event based on theshort description. It also callsstartInteractionon the next controller. OverridestartInteractionImplif you want to add your own behavior to this controller.- Specified by:
startInteractionin interfaceILspController- Parameters:
aView- the view the controller operates on
-
terminateInteraction
Terminates interaction with this controller. This automatically happens when setting a different controller on the view usingILspView.setController(com.luciad.view.lightspeed.controller.ILspController). This implementation also callsterminateInteractionon the next controller. OverrideterminateInteractionImplif you want to add your own behavior to this controller.- Specified by:
terminateInteractionin interfaceILspController- 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:
paintin interfaceILspController- 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
Returns theILspViewthe controller is interacting with.- Returns:
- the
ILspViewthe controller is interacting with, or null if the controller is not interacting with a view.
-
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 {#linkgetFXCursor()}.- Returns:
- the cursor for this controller, or null if the controller does not have a specific cursor
- See Also:
-
getFXCursor
JavaFX equivalent ofgetCursor().- Returns:
- the JavaFX cursor for this controller, or null if the controller does not have a specific cursor
- Since:
- 2020.0
- See Also:
-
setCursor
Sets the AWT mouse cursor for this controller. For JavaFX, seesetFXCursor(javafx.scene.Cursor).- Parameters:
aCursor- the cursor for this controller, or null if the controller does not have a specific cursor- See Also:
-
setFXCursor
JavaFX equivalent ofsetCursor(Cursor), to be used when this controller is active in aTLspFXView.- Parameters:
aCursor- the cursor for this controller, or null if the controller does not have a specific cursor- Since:
- 2020.0
- See Also:
-
setName
- Parameters:
aName- the name to associate to thisILspController
-
getName
Description copied from interface:ILspControllerGets the name of this controller.- Specified by:
getNamein interfaceILspController- Returns:
- the name associated to this
ILspController
-
setShortDescription
- Parameters:
aShortDescription- the short description to associate to thisILspController
-
getShortDescription
Description copied from interface:ILspControllerGets a short description for this controller.- Specified by:
getShortDescriptionin interfaceILspController- Returns:
- the short description associated to this
ILspController
-
setIcon
- Parameters:
aIcon- theILcdIconto associate to thisILspController
-
getIcon
Description copied from interface:ILspControllerGets the icon that is used for example on buttons in the graphical user interface to identify this controller.- Specified by:
getIconin interfaceILspController- Returns:
- the
ILcdIconassociated to thisILspController
-
getAWTFilter
Returns the currently used AWT event filter.- Returns:
- the current AWT event filter
- See Also:
-
setAWTFilter
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 tonullto disable filtering.- Parameters:
aAWTFilter- a event filter.- See Also:
-
getFXFilter
Returns the currently used FX event filter.- Returns:
- the current FX event filter
- Since:
- 2020.0
- See Also:
-
setFXFilter
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 tonullto disable filtering.- Parameters:
aFXFilter- a event filter.- Since:
- 2019.0
-
getNextController
Description copied from interface:ILspControllerReturns 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:
getNextControllerin interfaceILspController- Returns:
- a reference to the next controller.
- See Also:
-
appendController
Description copied from interface:ILspControllerThis 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:
appendControllerin interfaceILspController- Parameters:
aEnd- the controller to be appended to the end of the chain.
-
getLayered
Description copied from interface:ILspControllerReturns an
ILcdLayeredfor this controller. Custom implementations of this method should take care to return the sameILcdLayeredinstance every time this method is called to guarantee correct working of theILcdLayeredinterface.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
ILspLayerinstances.- Specified by:
getLayeredin interfaceILspController- Returns:
- an ILcdLayered object, or null if this controller has no layers.
-
startInteractionImpl
The specific implementation ofstartInteractionfor this controller.- Parameters:
aView- the view to start interaction with.
-
terminateInteractionImpl
The specific implementation ofterminateInteractionfor this controller.- Parameters:
aView- the view to terminate interaction with.
-
paintImpl
protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaintfor this controller.- Parameters:
aGLDrawable- the drawable that should be painted onaView- the view that is painted onaPaintPhase- the current paint phase- Returns:
- whether or not the painting was finished
-
handleAWTEvent
Delegates tohandleAWTEventImpl. If that method does not returnnull, 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:
handleAWTEventin interfaceILcdAWTEventListener- Parameters:
aAWTEvent- the event to be handled
-
handleAWTEventImpl
Called byhandleAWTEvent. Returnsnullwhen the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen withTLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.- Parameters:
aAWTEvent- the event to be handled.- Returns:
nullwhen the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
handleFXEvent
Delegates tohandleFXEventImpl. If that method does not returnnull, 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:
handleFXEventin interfaceILspController- Parameters:
aEvent- the event to be handled- Since:
- 2019.0
-
handleFXEventImpl
Called byhandleFXEvent. Returnsnullwhen 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:
nullwhen the input event was consumed, the (possibly modified) input event when it was (partially) consumed.- Since:
- 2019.0
-