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
,paintImpl
andhandleAWTEventImpl
methods. Note that only events that pass thefilter
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 (seegetCursor
andsetCursor()
).
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds aPropertyChangeListener
to thisILspController
.void
addStatusListener
(ILcdStatusListener aStatusListener) Adds a status listener to this controller.void
This method will append the passed controller to the end of the chain.protected void
firePropertyChange
(String aPropertyName, Object aOldValue, Object aNewValue) Fires a property change event.protected void
fireStatusEvent
(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 anILcdLayered
for 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 theILspView
the controller is interacting with.void
handleAWTEvent
(AWTEvent aAWTEvent) Delegates tohandleAWTEventImpl
.abstract AWTEvent
handleAWTEventImpl
(AWTEvent aAWTEvent) Called byhandleAWTEvent
.void
handleFXEvent
(Event aEvent) Delegates tohandleFXEventImpl
.handleFXEventImpl
(Event aEvent) Called byhandleFXEvent
.paint
(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) Paints the visual feedback of this controller.protected TLspPaintProgress
paintImpl
(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaint
for this controller.protected final void
registerViewPropertyNameForReset
(String aViewPropertyName) Registers the name of a property of theILspView
on which this controller is dependent.void
Removes the givenPropertyChangeListener
from thisILspController
.void
removeStatusListener
(ILcdStatusListener aStatusListener) Removes a status listener to this controller.void
setAWTFilter
(ILcdFilter<AWTEvent> aAWTFilter) Registers a filter for this controller.void
Sets the AWT mouse cursor for this controller.void
setFXCursor
(Cursor aCursor) JavaFX equivalent ofsetCursor(Cursor)
, to be used when this controller is active in aTLspFXView
.void
setFXFilter
(ILcdFilter<Event> aFXFilter) Registers a filter for this controller.void
void
void
setShortDescription
(String aShortDescription) void
startInteraction
(ILspView aView) Called to start interacting with the controller.protected void
startInteractionImpl
(ILspView aView) The specific implementation ofstartInteraction
for this controller.void
terminateInteraction
(ILspView aView) Terminates interaction with this controller.protected void
terminateInteractionImpl
(ILspView aView) The specific implementation ofterminateInteraction
for this controller.
-
Constructor Details
-
ALspController
protected ALspController() -
ALspController
-
-
Method Details
-
addPropertyChangeListener
Description copied from interface:ILspController
Adds aPropertyChangeListener
to thisILspController
.- Specified by:
addPropertyChangeListener
in interfaceILspController
- Parameters:
listener
- the listener
-
removePropertyChangeListener
Description copied from interface:ILspController
Removes the givenPropertyChangeListener
from thisILspController
.- Specified by:
removePropertyChangeListener
in 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.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 receiveTLcdStatusEvent
s 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.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 receiveTLcdStatusEvent
s 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 theILspView
on which this controller is dependent. When the view fires aPropertyChangeEvent
corresponding to this property, the controller will "reset" itself by invoking its ownterminateInteraction
andstartInteraction
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
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 callsstartInteraction
on the next controller. OverridestartInteractionImpl
if you want to add your own behavior to this controller.- Specified by:
startInteraction
in 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 callsterminateInteraction
on the next controller. OverrideterminateInteractionImpl
if you want to add your own behavior to this controller.- Specified by:
terminateInteraction
in 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:
paint
in 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 theILspView
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
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:ILspController
Gets the name of this controller.- Specified by:
getName
in interfaceILspController
- Returns:
- the name associated to this
ILspController
-
setShortDescription
- Parameters:
aShortDescription
- the short description to associate to thisILspController
-
getShortDescription
Description copied from interface:ILspController
Gets a short description for this controller.- Specified by:
getShortDescription
in interfaceILspController
- Returns:
- the short description associated to this
ILspController
-
setIcon
- Parameters:
aIcon
- theILcdIcon
to associate to thisILspController
-
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 interfaceILspController
- Returns:
- the
ILcdIcon
associated 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 tonull
to 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 tonull
to disable filtering.- Parameters:
aFXFilter
- a event filter.- Since:
- 2019.0
-
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 interfaceILspController
- Returns:
- a reference to the next controller.
- See Also:
-
appendController
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 interfaceILspController
- Parameters:
aEnd
- the controller to be appended to the end of the chain.
-
getLayered
Description copied from interface:ILspController
Returns an
ILcdLayered
for this controller. Custom implementations of this method should take care to return the sameILcdLayered
instance every time this method is called to guarantee correct working of theILcdLayered
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 interfaceILspController
- Returns:
- an ILcdLayered object, or null if this controller has no layers.
-
startInteractionImpl
The specific implementation ofstartInteraction
for this controller.- Parameters:
aView
- the view to start interaction with.
-
terminateInteractionImpl
The specific implementation ofterminateInteraction
for this controller.- Parameters:
aView
- the view to terminate interaction with.
-
paintImpl
protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaint
for 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:
handleAWTEvent
in interfaceILcdAWTEventListener
- Parameters:
aAWTEvent
- the event to be handled
-
handleAWTEventImpl
Called byhandleAWTEvent
. Returnsnull
when the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen withTLcdTouchEvent
s). 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
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:
handleFXEvent
in interfaceILspController
- Parameters:
aEvent
- the event to be handled- Since:
- 2019.0
-
handleFXEventImpl
Called byhandleFXEvent
. Returnsnull
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
-