public class TLspFlickerController extends ALspController
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); } } };
TLspSwipeController
Constructor and Description |
---|
TLspFlickerController()
Constructs a controller that allows to visually compare layer sets
by flickering between the
two sets.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aListener)
Adds a
PropertyChangeListener to this ILspController . |
List<Collection<ILspLayer>> |
getLayers()
Returns the list of layer collections that we are flickering between.
|
int |
getVisibleIndex()
Returns the index of the layer collection that is visible.
|
AWTEvent |
handleAWTEventImpl(AWTEvent aAWTEvent)
Called by
handleAWTEvent . |
javafx.event.Event |
handleFXEventImpl(javafx.event.Event aEvent)
Called by
handleFXEvent . |
void |
removeAllLayers()
Removes all layers.
|
void |
removePropertyChangeListener(PropertyChangeListener aListener)
Removes the given
PropertyChangeListener from this ILspController . |
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.
|
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
public TLspFlickerController()
public void setLayers(Collection<? extends ILspLayer>... aLayers)
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}.
aLayers
- The different collections of layers to flicker between.IllegalArgumentException
- if no layers or less than two collections are providedpublic void setLayers(List<? extends Collection<? extends ILspLayer>> aLayers)
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}.
aLayers
- The different collections of layers to flicker between.IllegalArgumentException
- if no layers or less than two collections are providedpublic void removeAllLayers()
IllegalStateException
- when the controller is active on the view, or
startInteraction(com.luciad.view.lightspeed.ILspView)
has been called already.public void startInteraction(ILspView aView)
ALspController
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
startInteraction
in class ALspController
aView
- the view the controller operates onpublic void terminateInteraction(ILspView aView)
ALspController
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
terminateInteraction
in class ALspController
aView
- the view the controller was operating onpublic AWTEvent handleAWTEventImpl(AWTEvent aAWTEvent)
ALspController
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.handleAWTEventImpl
in class ALspController
aAWTEvent
- the event to be handled.null
when the input event was consumed, the (possibly modified) input
event when it was (partially) consumed.public javafx.event.Event handleFXEventImpl(javafx.event.Event aEvent)
ALspController
handleFXEvent
.
Returns null
when the controller consumed the event. When the controller did not use the
given event, it is returned unaltered.handleFXEventImpl
in class ALspController
aEvent
- the event to be handled.null
when the input event was consumed, the (possibly modified) input
event when it was (partially) consumed.public void setVisibleIndex(int aIndex)
aIndex
- the index of the visible layerspublic List<Collection<ILspLayer>> getLayers()
This list and the collections it contains are immutable.
public int getVisibleIndex()
public void addPropertyChangeListener(PropertyChangeListener aListener)
ILspController
PropertyChangeListener
to this ILspController
.addPropertyChangeListener
in interface ILspController
addPropertyChangeListener
in class ALspController
aListener
- the listenerpublic void removePropertyChangeListener(PropertyChangeListener aListener)
ILspController
PropertyChangeListener
from this ILspController
.removePropertyChangeListener
in interface ILspController
removePropertyChangeListener
in class ALspController
aListener
- the listener.