public class TLspPortholeController extends ALspController
The behavior of the controller can be adapted by overriding or extendingILspLayer layer1 = ...; ILspLayer layer2 = ...; ILspView view = ...; TLspPortholeController controller = new TLspPortholeController(); controller.setLayers(Collections.singleton(layer1), Collections.singleton(layer2)); view.setController(controller);
handleAWTEventImpl
and using the setPortholeLocation(double, double)
and setPortholeSize(int)
methods, for example based on key strokes.
This class can also be used to implement a programmatic porthole action. In this case,
please ensure to call startInteraction
and
terminateInteraction
before and after interacting with it respectively.
This code sample shows how to set up a porthole between two layers in an ILcdAction
around
AWT location (200, 300):
The controller adds a layer to the view to visualize the porthole outline. To customize the visualization, you can usefinal ILspLayer layer1 = ...; final ILspLayer layer2 = ...; final ILspView view = ...; final TLspPortholeController controller = new TLspPortholeController(); ALcdAction action = new ALcdAction() { public void actionPerformed(ActionEvent e) { if (getValue(ILcdAction.SELECTED_KEY) == Boolean.TRUE) { controller.setLayers(Collections.singleton(layer1), Collections.singleton(layer2)); controller.startInteraction(view); controller.setPortholeLocation(200, 300); controller.setPortholeSize(100); // optionally, enable specific styling of the porthole shape for (int i = 0; i < controller.getLayered().layerCount(); i++) { getView().addLayer((ILspLayer) controller.getLayered().getLayer(i)); } } else { for (int i = 0; i < controller.getLayered().layerCount(); i++) { getView().removeLayer(controller.getLayered().getLayer(i)); } controller.terminateInteraction(view); controller.removeAllLayers(); } } };
setPortholeStyler(ILspStyler)
.
This class is not thread safe. It should be used only on the paint thread.com.luciad.view.lightspeed.controller.visualinspection
Constructor and Description |
---|
TLspPortholeController()
Constructs a new controller that visually compares two sets of layers by exposing one set of layers through a porthole
in the other set.
|
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 interacting with.
|
Point |
getPortholeLocation()
Returns the porthole center in view coordinates.
|
int |
getPortholeSize()
Returns the size of the area around the porthole location.
|
ILspStyler |
getPortholeStyler()
Returns the styler that is used to visualize the porthole.
|
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> aLayers1,
Collection<? extends ILspLayer> aLayers2)
Configures a porthole through the first set of layers, exposing the second set of layers.
|
void |
setPortholeLocation(double aX,
double aY)
Sets the porthole center in view coordinates.
|
void |
setPortholeSize(int aPortholeSize)
Defines the size of the area around the porthole location.
|
void |
setPortholeStyler(ILspStyler aPortholeStyler)
Sets the styler that is used to visualize the porthole.
|
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 TLspPortholeController()
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 interact between layers A and C, but layer B appears in-between layer A and C,
that the controller will turn the left part of A visible and the right part of C visible,
but that B will obstruct C and the interaction will appear to happen between A and B as opposed
to A and C. To overcome this, make sure that you always interact between consecutive layers. In the example
this would mean that you interact between the collections {A,B} and {C}.
aLayers1
- The layers that will only be visible around the porthole, can be nullaLayers2
- The layers that will only be visible inside the porthole, can be nullpublic void removeAllLayers()
IllegalStateException
- when the controller is active on the view, or
startInteraction(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 Point getPortholeLocation()
public void setPortholeLocation(double aX, double aY)
aX
- the x-coordinateaY
- the y-coordinatepublic void setPortholeSize(int aPortholeSize)
aPortholeSize
- the new width and height of the portholepublic int getPortholeSize()
public ILspStyler getPortholeStyler()
public void setPortholeStyler(ILspStyler aPortholeStyler)
aPortholeStyler
- the styler used to visualize the portholepublic 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.