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:
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.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.
ILspController
Modifier | Constructor and Description |
---|---|
protected |
ALspController() |
protected |
ALspController(ILcdLayered aLayered) |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a
PropertyChangeListener to this ILspController . |
void |
addStatusListener(ILcdStatusListener aStatusListener)
Adds a status listener to this controller.
|
void |
appendController(ILspController aEnd)
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.
|
ILcdFilter<AWTEvent> |
getAWTFilter()
Returns the currently used AWT event filter.
|
Cursor |
getCursor()
Returns the mouse cursor for this controller.
|
javafx.scene.Cursor |
getFXCursor()
JavaFX equivalent of
getCursor() . |
ILcdFilter<javafx.event.Event> |
getFXFilter()
Returns the currently used FX event filter.
|
ILcdIcon |
getIcon()
Gets the icon that is used for example on buttons
in the graphical user interface to identify this controller.
|
ILcdLayered |
getLayered()
Returns an
ILcdLayered for this controller. |
String |
getName()
Gets the name of this controller.
|
ILspController |
getNextController()
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.
|
String |
getShortDescription()
Gets a short description for this controller.
|
ILspView |
getView()
Returns the
ILspView the controller is interacting with. |
void |
handleAWTEvent(AWTEvent aAWTEvent)
Delegates to
handleAWTEventImpl . |
abstract AWTEvent |
handleAWTEventImpl(AWTEvent aAWTEvent)
Called by
handleAWTEvent . |
void |
handleFXEvent(javafx.event.Event aEvent)
Delegates to
handleFXEventImpl . |
javafx.event.Event |
handleFXEventImpl(javafx.event.Event aEvent)
Called by
handleFXEvent . |
TLspPaintProgress |
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 of
paint for this controller. |
protected void |
registerViewPropertyNameForReset(String aViewPropertyName)
Registers the name of a property of the
ILspView on which this controller is dependent. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes the given
PropertyChangeListener from this ILspController . |
void |
removeStatusListener(ILcdStatusListener aStatusListener)
Removes a status listener to this controller.
|
void |
setAWTFilter(ILcdFilter<AWTEvent> aAWTFilter)
Registers a filter for this controller.
|
void |
setCursor(Cursor aCursor)
Sets the AWT mouse cursor for this controller.
|
void |
setFXCursor(javafx.scene.Cursor aCursor)
JavaFX equivalent of
setCursor(Cursor) , to be used when this controller is active in a
TLspFXView . |
void |
setFXFilter(ILcdFilter<javafx.event.Event> aFXFilter)
Registers a filter for this controller.
|
void |
setIcon(ILcdIcon aIcon) |
void |
setName(String aName) |
void |
setShortDescription(String aShortDescription) |
void |
startInteraction(ILspView aView)
Called to start interacting with the controller.
|
protected void |
startInteractionImpl(ILspView aView)
The specific implementation of
startInteraction for this controller. |
void |
terminateInteraction(ILspView aView)
Terminates interaction with this controller.
|
protected void |
terminateInteractionImpl(ILspView aView)
The specific implementation of
terminateInteraction for this controller. |
protected ALspController()
protected ALspController(ILcdLayered aLayered)
public void addPropertyChangeListener(PropertyChangeListener listener)
ILspController
PropertyChangeListener
to this ILspController
.addPropertyChangeListener
in interface ILspController
listener
- the listenerpublic void removePropertyChangeListener(PropertyChangeListener listener)
ILspController
PropertyChangeListener
from this ILspController
.removePropertyChangeListener
in interface ILspController
listener
- the listener.protected void firePropertyChange(String aPropertyName, Object aOldValue, Object aNewValue)
aPropertyName
- the name of the propertyaOldValue
- the old valueaNewValue
- the new valuepublic void addStatusListener(ILcdStatusListener aStatusListener)
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
TLcdStatusEvent
s from this controller, and not from any other other controller in
the chain.
aStatusListener
- the status listener to register.public void removeStatusListener(ILcdStatusListener aStatusListener)
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 TLcdStatusEvent
s from other
controllers it was registered to, just not from this controller anymore.
aStatusListener
- the status listener to unregister.protected void fireStatusEvent(TLcdStatusEvent aStatusEvent)
aStatusEvent
- the event to fire.protected final void registerViewPropertyNameForReset(String aViewPropertyName)
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.aViewPropertyName
- the name of the property for which this controller should listenpublic void startInteraction(ILspView aView)
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.startInteraction
in interface ILspController
aView
- the view the controller operates onpublic void terminateInteraction(ILspView aView)
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.terminateInteraction
in interface ILspController
aView
- the view the controller was operating onpublic TLspPaintProgress paint(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase)
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.
paint
in interface ILspController
aGLDrawable
- the ILcdGLDrawable on which the view is rendered.aView
- the view.aPaintPhase
- the current paint phasepublic ILspView getView()
ILspView
the controller is interacting with.ILspView
the controller is interacting with, or null if the controller is
not interacting with a view.public Cursor getCursor()
getFXCursor()
}.setCursor(java.awt.Cursor)
public javafx.scene.Cursor getFXCursor()
getCursor()
.setFXCursor(javafx.scene.Cursor)
public void setCursor(Cursor aCursor)
setFXCursor(javafx.scene.Cursor)
.aCursor
- the cursor for this controller, or null if the controller does not have a specific cursorgetCursor()
public void setFXCursor(javafx.scene.Cursor aCursor)
setCursor(Cursor)
, to be used when this controller is active in a
TLspFXView
.aCursor
- the cursor for this controller, or null if the controller does not have a specific cursorgetFXCursor()
public void setName(String aName)
aName
- the name to associate to this ILspController
public String getName()
ILspController
getName
in interface ILspController
ILspController
public void setShortDescription(String aShortDescription)
aShortDescription
- the short description to associate to this ILspController
public String getShortDescription()
ILspController
getShortDescription
in interface ILspController
ILspController
public void setIcon(ILcdIcon aIcon)
aIcon
- the ILcdIcon
to associate to this ILspController
public ILcdIcon getIcon()
ILspController
getIcon
in interface ILspController
ILcdIcon
associated to this ILspController
public ILcdFilter<AWTEvent> getAWTFilter()
setAWTFilter(com.luciad.util.ILcdFilter)
public void setAWTFilter(ILcdFilter<AWTEvent> aAWTFilter)
null
to disable filtering.aAWTFilter
- a event filter.TLcdAWTEventFilterBuilder
public ILcdFilter<javafx.event.Event> getFXFilter()
setFXFilter(com.luciad.util.ILcdFilter)
public void setFXFilter(ILcdFilter<javafx.event.Event> aFXFilter)
null
to disable filtering.aFXFilter
- a event filter.public ILspController getNextController()
ILspController
getNextController
in interface ILspController
ILspController.appendController(com.luciad.view.lightspeed.controller.ILspController)
public void appendController(ILspController aEnd)
ILspController
appendController
in interface ILspController
aEnd
- the controller to be appended to the end of the chain.public ILcdLayered getLayered()
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.
getLayered
in interface ILspController
protected void startInteractionImpl(ILspView aView)
startInteraction
for this controller.aView
- the view to start interaction with.protected void terminateInteractionImpl(ILspView aView)
terminateInteraction
for this controller.aView
- the view to terminate interaction with.protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase)
paint
for this controller.aGLDrawable
- the drawable that should be painted onaView
- the view that is painted onaPaintPhase
- the current paint phasepublic void handleAWTEvent(AWTEvent aAWTEvent)
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.handleAWTEvent
in interface ILcdAWTEventListener
aAWTEvent
- the event to be handledpublic abstract AWTEvent handleAWTEventImpl(AWTEvent aAWTEvent)
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
TLcdTouchEvent
s). When the controller did not use the given event, it is returned
unaltered.aAWTEvent
- the event to be handled.null
when the input event was consumed, the (possibly modified) input
event when it was (partially) consumed.public void handleFXEvent(javafx.event.Event aEvent)
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.handleFXEvent
in interface ILspController
aEvent
- the event to be handledpublic javafx.event.Event handleFXEventImpl(javafx.event.Event aEvent)
handleFXEvent
.
Returns null
when the controller consumed the event. When the controller did not use the
given event, it is returned unaltered.aEvent
- the event to be handled.null
when the input event was consumed, the (possibly modified) input
event when it was (partially) consumed.