public class TLspSwipeController extends ALspController
Swiping is done by dragging the swipe line using the mouse from left-to-right or top-to-bottom. This is illustrated in the following screenshot:
Example usage of using the controller to compare two layers is shown below:
ILspLayer layer1 = ...; ILspLayer layer2 = ...; ILspView view = ...; TLspSwipeController swipeController = new TLspSwipeController(); swipeController.setLayers(Collections.singleton(layer1), Collections.singleton(layer2)); view.setController(swipeController);
The behavior of the swipe controller can
be adapted by overriding or extending handleAWTEventImpl
and using the setSwipeLineOrientation
and setSwipeLineLocation
methods
to perform the required swiping, for example on key strokes.
This class can also be used to implement a programmatic swiping action. In this case,
please ensure to call startInteraction
and
terminateInteraction
before and after swiping respectively.
This code sample shows how to set up a swipe line between two layers in an ILcdAction
:
final ILspLayer layer1 = ...; final ILspLayer layer2 = ...; final ILspView view = ...; final TLspSwipeController swipeController = new TLspSwipeController(); ALcdAction swipeAction = new ALcdAction() { public void actionPerformed(ActionEvent e) { if (getValue(ILcdAction.SELECTED_KEY) == Boolean.TRUE) { swipeController.setLayers(Collections.singleton(layer1), Collections.singleton(layer2)); swipeController.startInteraction(view); swipeController.setSwipeLineOrientation(TLspSwipeController.SwipeLineOrientation.VERTICAL); swipeController.setSwipeLineLocation(view.getWidth() / 2.0, view.getHeight() / 2.0); // optionally, enable specific styling of the swipe line for (int i = 0; i < swipeController.getLayered().layerCount(); i++) { getView().addLayer((ILspLayer) swipeController.getLayered().getLayer(i)); } } else { for (int i = 0; i < swipeController.getLayered().layerCount(); i++) { getView().removeLayer(swipeController.getLayered().getLayer(i)); } swipeController.terminateInteraction(view); swipeController.removeAllLayers(); } } };
The swipe controller adds a layer to the view to visualize the swipe line. To customize
the swipe line visualization, you can use setSwipeLineStyler
,
setFocusSwipeLineStyler
, and
setActiveSwipeLineStyler
.
TLspFlickerController
Modifier and Type | Class and Description |
---|---|
static class |
TLspSwipeController.SwipeLineOrientation
Indicates the direction of the swipe line.
|
Constructor and Description |
---|
TLspSwipeController()
Constructs a controller that allows to visually compare two sets of layers
by moving a swipe line left/right or up/down.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener aListener)
Adds a
PropertyChangeListener to this ILspController . |
ILspStyler |
getActiveSwipeLineStyler()
Gets the styler that is used to visualize the swipe line
when there is interaction (i.e., when the mouse is dragging the swipe line).
|
ILspStyler |
getFocusSwipeLineStyler()
Gets the styler that is used to visualize the swipe line
when the mouse is over the swipe line (i.e., has focus).
|
List<Collection<ILspLayer>> |
getLayers()
Returns the list of layer collections that we are swiping between.
|
Point |
getSwipeLineLocation()
Gets the swipe line location in view coordinates.
|
TLspSwipeController.SwipeLineOrientation |
getSwipeLineOrientation()
Gets the orientation of the swipe line.
|
ILspStyler |
getSwipeLineStyler()
Gets the styler that is used to visualize the swipe line
when there is no interaction.
|
AWTEvent |
handleAWTEventImpl(AWTEvent aAWTEvent)
Called by
handleAWTEvent . |
javafx.event.Event |
handleFXEventImpl(javafx.event.Event aEvent)
Called by
handleFXEvent . |
boolean |
isAutomaticOrientationChange()
Determines whether the controller is allowed to automatically change the swipe line orientation
when dragging the mouse in the opposite direction.
|
boolean |
isFocused()
Returns true if the swipe line has focus.
|
void |
removeAllLayers()
Removes all layers.
|
void |
removePropertyChangeListener(PropertyChangeListener aListener)
Removes the given
PropertyChangeListener from this ILspController . |
void |
setActiveSwipeLineStyler(ILspStyler aActiveSwipeLineStyler)
Sets the styler that is used to visualize the swipe line
when there is interaction (i.e., when the mouse is dragging the swipe line).
|
void |
setAutomaticOrientationChange(boolean aValue)
Sets whether the controller is allowed to automatically change the swipe line orientation
when dragging the mouse in the opposite direction.
|
void |
setFocusSwipeLineStyler(ILspStyler aFocusSwipeLineStyler)
Sets the styler that is used to visualize the swipe line
when the mouse is over the swipe line (i.e., has focus).
|
void |
setLayers(Collection<? extends ILspLayer> aLayers1,
Collection<? extends ILspLayer> aLayers2)
Sets the two sets of layers to swipe.
|
void |
setSwipeLineLocation(double aX,
double aY)
Sets the swipe line location in view coordinates.
|
void |
setSwipeLineOrientation(TLspSwipeController.SwipeLineOrientation aSwipeLineOrientation)
Sets the orientation of the swipe line.
|
void |
setSwipeLineStyler(ILspStyler aSwipeLineStyler)
Sets the styler that is used to visualize the swipe line when there is no interaction.
|
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 TLspSwipeController()
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 setLayers(Collection<? extends ILspLayer> aLayers1, Collection<? extends ILspLayer> aLayers2)
layer type
BACKGROUND
,
using them in this controller will change their type to INTERACTIVE
. Upon termination the original layer type will be restored.
Note that layers in the view that are not specified here are not affected. This for example means
that if you swipe between layers A and C, but layer B appears in-between layer A and C,
that the swipe controller will turn the left part of A visible and the right part of C visible,
but that B will obstruct C and the swiping will appear to happen between A and B as opposed
to A and C. To overcome
this, make sure that you always swipe between consecutive layers. In the example
this would mean that you swipe between the collections {A,B} and {C}.aLayers1
- The left and top layer, can be nullaLayers2
- The right and bottom layer, can be nullpublic void removeAllLayers()
IllegalStateException
- when the controller is active on the view, or
startInteraction(com.luciad.view.lightspeed.ILspView)
has been called already.public 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 List<Collection<ILspLayer>> getLayers()
public TLspSwipeController.SwipeLineOrientation getSwipeLineOrientation()
setSwipeLineOrientation(com.luciad.view.lightspeed.controller.visualinspection.TLspSwipeController.SwipeLineOrientation)
,
TLspSwipeController.SwipeLineOrientation
public void setSwipeLineOrientation(TLspSwipeController.SwipeLineOrientation aSwipeLineOrientation)
aSwipeLineOrientation
- the swipe line orientationgetSwipeLineOrientation()
,
TLspSwipeController.SwipeLineOrientation
public void setAutomaticOrientationChange(boolean aValue)
By default such automatic orientation changes are allowed.
aValue
- whether or not the controller automatically changes swipe line orientationisAutomaticOrientationChange()
public boolean isAutomaticOrientationChange()
By default such automatic orientation changes are allowed.
setAutomaticOrientationChange(boolean)
public Point getSwipeLineLocation()
public void setSwipeLineLocation(double aX, double aY)
aX
- the x-coordinate, relevant when the swipe line has vertical orientation.aY
- the y-coordinate, relevant when the swipe line has horizontal orientation.public ILspStyler getSwipeLineStyler()
public void setSwipeLineStyler(ILspStyler aSwipeLineStyler)
By default getFocusSwipeLineStyler==getSwipeLineStyler.
aSwipeLineStyler
- the styler used to visualize the swipe line when there is no interactionpublic boolean isFocused()
public ILspStyler getFocusSwipeLineStyler()
By default getFocusSwipeLineStyler==getSwipeLineStyler.
public void setFocusSwipeLineStyler(ILspStyler aFocusSwipeLineStyler)
aFocusSwipeLineStyler
- the styler used to visualize the swipe line when it has focuspublic ILspStyler getActiveSwipeLineStyler()
By default getActiveSwipeLineStyler==getSwipeLineStyler.
public void setActiveSwipeLineStyler(ILspStyler aActiveSwipeLineStyler)
aActiveSwipeLineStyler
- the styler used to visualize the swipe line when there is interactionpublic 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.