Class TLspPortholeController
java.lang.Object
com.luciad.view.lightspeed.controller.ALspController
com.luciad.view.lightspeed.controller.visualinspection.TLspPortholeController
- All Implemented Interfaces:
ILcdAWTEventListener,ILspController
Mouse controller that allows to visually compare two sets of layers by exposing one set of layers through a porthole
in the other set.
The first set of layers is visible by default.
The second set is shown in a rectangular area around the mouse location.
By moving the mouse different parts of the layer sets are revealed and hidden.
This allows easily spotting differences between the layer sets.
Holding down the shift key and moving the mouse wheel will resize the porthole.
Example usage of using the controller to compare two layers is shown below:
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.- Since:
- 2016.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new controller that visually compares two sets of layers by exposing one set of layers through a porthole in the other set. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPropertyChangeListener(PropertyChangeListener aListener) Adds aPropertyChangeListenerto thisILspController.Returns the list of layer collections that we are interacting with.Returns the porthole center in view coordinates.intReturns the size of the area around the porthole location.Returns the styler that is used to visualize the porthole.handleAWTEventImpl(AWTEvent aAWTEvent) Called byhandleAWTEvent.handleFXEventImpl(Event aEvent) Called byhandleFXEvent.voidRemoves all layers.voidRemoves the givenPropertyChangeListenerfrom thisILspController.voidsetLayers(Collection<? extends ILspLayer> aLayers1, Collection<? extends ILspLayer> aLayers2) Configures a porthole through the first set of layers, exposing the second set of layers.voidsetPortholeLocation(double aX, double aY) Sets the porthole center in view coordinates.voidsetPortholeSize(int aPortholeSize) Defines the size of the area around the porthole location.voidsetPortholeStyler(ILspStyler aPortholeStyler) Sets the styler that is used to visualize the porthole.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
-
TLspPortholeController
public 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.
-
-
Method Details
-
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
-
setLayers
public 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. If the provided layers are raster layers and havelayer typeBACKGROUND, using them in this controller will change their type toINTERACTIVE. 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}.- Parameters:
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 null
-
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(ILspView)has been called already.
-
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.
-
getLayers
Returns the list of layer collections that we are interacting with.- Returns:
- the list of layer collections that we are interacting with
-
getPortholeLocation
Returns the porthole center in view coordinates.- Returns:
- the coordinates that define the location of the porthole in the view
-
setPortholeLocation
public void setPortholeLocation(double aX, double aY) Sets the porthole center in view coordinates.- Parameters:
aX- the x-coordinateaY- the y-coordinate
-
setPortholeSize
public void setPortholeSize(int aPortholeSize) Defines the size of the area around the porthole location.- Parameters:
aPortholeSize- the new width and height of the porthole
-
getPortholeSize
public int getPortholeSize()Returns the size of the area around the porthole location.- Returns:
- the width and height of the porthole
-
getPortholeStyler
Returns the styler that is used to visualize the porthole.- Returns:
- the styler used to visualize the porthole
-
setPortholeStyler
Sets the styler that is used to visualize the porthole. The porthole geometry will be a bounds object in view coordinates.- Parameters:
aPortholeStyler- the styler used to visualize the porthole
-
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.
-