Class TLspFlickerController

java.lang.Object
com.luciad.view.lightspeed.controller.ALspController
com.luciad.view.lightspeed.controller.visualinspection.TLspFlickerController
All Implemented Interfaces:
ILcdAWTEventListener, ILspController

public class TLspFlickerController extends ALspController
Mouse controller that allows to visually compare multiple collections of layers by quickly toggling their visibility. Doing so allows easy verification of differences in the layer contents.

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:

 

 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);
     }
   }

 };
 
 

This class is not thread safe. It should be used only on the paint thread.
Since:
2014.1
See Also:
  • Constructor Details

    • TLspFlickerController

      public TLspFlickerController()
      Constructs a controller that allows to visually compare layer sets by flickering between the two sets.
  • Method Details

    • setLayers

      public void setLayers(Collection<? extends ILspLayer>... aLayers)
      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

      public void setLayers(List<? extends Collection<? extends ILspLayer>> aLayers)
      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, or startInteraction(com.luciad.view.lightspeed.ILspView) has been called already.
    • startInteraction

      public void startInteraction(ILspView aView)
      Description copied from class: ALspController
      Called to start interacting with the controller. This automatically happens when setting the controller on the view using 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.

      Specified by:
      startInteraction in interface ILspController
      Overrides:
      startInteraction in class ALspController
      Parameters:
      aView - the view the controller operates on
    • terminateInteraction

      public void terminateInteraction(ILspView aView)
      Description copied from class: ALspController
      Terminates interaction with this controller. This automatically happens when setting a different controller on the view using 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.

      Specified by:
      terminateInteraction in interface ILspController
      Overrides:
      terminateInteraction in class ALspController
      Parameters:
      aView - the view the controller was operating on
    • handleAWTEventImpl

      public AWTEvent handleAWTEventImpl(AWTEvent aAWTEvent)
      Description copied from class: ALspController
      Called by 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 TLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.
      Specified by:
      handleAWTEventImpl in class ALspController
      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

      public Event handleFXEventImpl(Event aEvent)
      Description copied from class: ALspController
      Called by handleFXEvent. Returns null when the controller consumed the event. When the controller did not use the given event, it is returned unaltered.
      Overrides:
      handleFXEventImpl in class ALspController
      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

      public List<Collection<ILspLayer>> 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

      public void addPropertyChangeListener(PropertyChangeListener aListener)
      Description copied from interface: ILspController
      Adds a PropertyChangeListener to this ILspController.
      Specified by:
      addPropertyChangeListener in interface ILspController
      Overrides:
      addPropertyChangeListener in class ALspController
      Parameters:
      aListener - the listener
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener aListener)
      Description copied from interface: ILspController
      Removes the given PropertyChangeListener from this ILspController.
      Specified by:
      removePropertyChangeListener in interface ILspController
      Overrides:
      removePropertyChangeListener in class ALspController
      Parameters:
      aListener - the listener.