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
ConstructorsConstructorDescriptionConstructs a controller that allows to visually compare layer sets by flickering between the two sets. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPropertyChangeListener(PropertyChangeListener aListener) Adds aPropertyChangeListenerto thisILspController.Returns the list of layer collections that we are flickering between.intReturns the index of the layer collection that is visible.handleAWTEventImpl(AWTEvent aAWTEvent) Called byhandleAWTEvent.handleFXEventImpl(Event aEvent) Called byhandleFXEvent.voidRemoves all layers.voidRemoves the givenPropertyChangeListenerfrom thisILspController.voidsetLayers(Collection<? extends ILspLayer>... aLayers) Sets the layers to flicker, i.e., to quickly toggle visibility.voidsetLayers(List<? extends Collection<? extends ILspLayer>> aLayers) Sets the layers to flicker, i.e., to quickly toggle visibility.voidsetVisibleIndex(int aIndex) Sets the collection of layers with the given index visible, making the layers in the other collections invisible.voidstartInteraction(ILspView aView) Called to start interacting with the controller.voidterminateInteraction(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:ALspControllerCalled 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- Overrides:
startInteractionin classALspController- Parameters:
aView- the view the controller operates on
-
terminateInteraction
Description copied from class:ALspControllerTerminates 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- Overrides:
terminateInteractionin classALspController- Parameters:
aView- the view the controller was operating on
-
handleAWTEventImpl
Description copied from class:ALspControllerCalled 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.- Specified by:
handleAWTEventImplin classALspController- Parameters:
aAWTEvent- the event to be handled.- Returns:
nullwhen the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-
handleFXEventImpl
Description copied from class:ALspControllerCalled byhandleFXEvent. Returnsnullwhen the controller consumed the event. When the controller did not use the given event, it is returned unaltered.- Overrides:
handleFXEventImplin classALspController- Parameters:
aEvent- the event to be handled.- Returns:
nullwhen 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:ILspControllerAdds aPropertyChangeListenerto thisILspController.- Specified by:
addPropertyChangeListenerin interfaceILspController- Overrides:
addPropertyChangeListenerin classALspController- Parameters:
aListener- the listener
-
removePropertyChangeListener
Description copied from interface:ILspControllerRemoves the givenPropertyChangeListenerfrom thisILspController.- Specified by:
removePropertyChangeListenerin interfaceILspController- Overrides:
removePropertyChangeListenerin classALspController- Parameters:
aListener- the listener.
-