Class TLspFlickerController
- All Implemented Interfaces:
ILcdAWTEventListener
,ILspController
Flickering is done by (quickly) clicking the mouse button.
Example usage of using the controller to compare two layers is shown below:
ILspLayer layer1 = ...; ILspLayer layer2 = ...; ILspView view = ...; TLspFlickerController flickerController = new TLspFlickerController(); flickerController.setLayers(Collections.singleton(layer1), Collections.singleton(layer2)); view.setController(flickerController);
The behavior can
be adapted by overriding or extending handleAWTEventImpl
and using the setVisibleIndex(int)
, getVisibleIndex()
, and getLayers()
methods
to perform the required flickering, for example on key strokes.
This class can also be used to implement a programmatic flickering action. In this case,
please ensure to call startInteraction
and
terminateInteraction
before and after flickering respectively.
This code sample shows how to flicker 10 times between two layers in an ILcdAction
:
This class is not thread safe. It should be used only on the paint thread.final ILspLayer layer1 = ...; final ILspLayer layer2 = ...; final ILspView view = ...; final TLspFlickerController flickerController = new TLspFlickerController(); ALcdAction flickerAction = new ALcdAction() { public void actionPerformed(ActionEvent e) { if (isEnabled()) { flickerController.setLayers(Collections.singleton(layer1), Collections.singleton(layer2)); flickerController.startInteraction(view); for (int i=0; i<10; i++) { flickerController.setVisibleIndex(1-flickerController.getVisibleIndex()); } flickerController.terminateInteraction(view); } } };
- Since:
- 2014.1
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructs a controller that allows to visually compare layer sets by flickering between the two sets. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(PropertyChangeListener aListener) Adds aPropertyChangeListener
to thisILspController
.Returns the list of layer collections that we are flickering between.int
Returns the index of the layer collection that is visible.handleAWTEventImpl
(AWTEvent aAWTEvent) Called byhandleAWTEvent
.handleFXEventImpl
(Event aEvent) Called byhandleFXEvent
.void
Removes all layers.void
Removes the givenPropertyChangeListener
from thisILspController
.void
setLayers
(Collection<? extends ILspLayer>... aLayers) Sets the layers to flicker, i.e., to quickly toggle visibility.void
setLayers
(List<? extends Collection<? extends ILspLayer>> aLayers) Sets the layers to flicker, i.e., to quickly toggle visibility.void
setVisibleIndex
(int aIndex) Sets the collection of layers with the given index visible, making the layers in the other collections invisible.void
startInteraction
(ILspView aView) Called to start interacting with the controller.void
terminateInteraction
(ILspView aView) Terminates interaction with this controller.Methods inherited from class com.luciad.view.lightspeed.controller.ALspController
addStatusListener, appendController, firePropertyChange, fireStatusEvent, getAWTFilter, getCursor, getFXCursor, getFXFilter, getIcon, getLayered, getName, getNextController, getShortDescription, getView, handleAWTEvent, handleFXEvent, paint, paintImpl, registerViewPropertyNameForReset, removeStatusListener, setAWTFilter, setCursor, setFXCursor, setFXFilter, setIcon, setName, setShortDescription, startInteractionImpl, terminateInteractionImpl
-
Constructor Details
-
TLspFlickerController
public TLspFlickerController()Constructs a controller that allows to visually compare layer sets by flickering between the two sets.
-
-
Method Details
-
setLayers
Sets the layers to flicker, i.e., to quickly toggle visibility. When started, only the first layer collection is visible and the others are set to invisible. When pressing the mouse button, the next layer collection is set to visible, and the others are set to invisible.Note that layers in the view that are not specified here are not affected. This for example means that if you flicker between layers A and C, but layer B appears in-between layer A and C, that the flicker controller will turn A invisible and C visible after the first click, but that B will obstruct C and the flickering effect will not be visible. To overcome this, make sure that you always flicker between consecutive layers. In the example this would mean that you flicker between the collections {A,B} and {C}.
- Parameters:
aLayers
- The different collections of layers to flicker between.- Throws:
IllegalArgumentException
- if no layers or less than two collections are provided
-
setLayers
Sets the layers to flicker, i.e., to quickly toggle visibility. When started, only the first layer collection is visible and the others are set to invisible. When pressing the mouse button, the next layer collection is set to visible, and the others are set to invisible.Note that layers in the view that are not specified here are not affected. This for example means that if you flicker between layers A and C, but layer B appears in-between layer A and C, that the flicker controller will turn A invisible and C visible after the first click, but that B will obstruct C and the flickering effect will not be visible. To overcome this, make sure that you always flicker between consecutive layers. In the example this would mean that you flicker between the collections {A,B} and {C}.
- Parameters:
aLayers
- The different collections of layers to flicker between.- Throws:
IllegalArgumentException
- if no layers or less than two collections are provided
-
removeAllLayers
public void removeAllLayers()Removes all layers. Should only be called when not interacting with the controller (i.e., it should not be set on the view).- Throws:
IllegalStateException
- when the controller is active on the view, orstartInteraction(com.luciad.view.lightspeed.ILspView)
has been called already.
-
startInteraction
Description copied from class:ALspController
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
- Overrides:
startInteraction
in classALspController
- Parameters:
aView
- the view the controller operates on
-
terminateInteraction
Description copied from class:ALspController
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
- Overrides:
terminateInteraction
in classALspController
- Parameters:
aView
- the view the controller was operating on
-
handleAWTEventImpl
Description copied from class:ALspController
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.- Specified by:
handleAWTEventImpl
in classALspController
- 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.
-
handleFXEventImpl
Description copied from class:ALspController
Called byhandleFXEvent
. Returnsnull
when the controller consumed the event. When the controller did not use the given event, it is returned unaltered.- Overrides:
handleFXEventImpl
in classALspController
- 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.
-
setVisibleIndex
public void setVisibleIndex(int aIndex) Sets the collection of layers with the given index visible, making the layers in the other collections invisible.- Parameters:
aIndex
- the index of the visible layers
-
getLayers
Returns the list of layer collections that we are flickering between.This list and the collections it contains are immutable.
- Returns:
- the list of layer collections that we are flickering between
-
getVisibleIndex
public int getVisibleIndex()Returns the index of the layer collection that is visible.- Returns:
- the visible layer collection index
-
addPropertyChangeListener
Description copied from interface:ILspController
Adds aPropertyChangeListener
to thisILspController
.- Specified by:
addPropertyChangeListener
in interfaceILspController
- Overrides:
addPropertyChangeListener
in classALspController
- Parameters:
aListener
- the listener
-
removePropertyChangeListener
Description copied from interface:ILspController
Removes the givenPropertyChangeListener
from thisILspController
.- Specified by:
removePropertyChangeListener
in interfaceILspController
- Overrides:
removePropertyChangeListener
in classALspController
- Parameters:
aListener
- the listener.
-