Package com.luciad.view.lightspeed
Interface ILspView
- All Superinterfaces:
ILcdLayered,ILcdPropertyChangeSource,ILcdTreeLayered,ILcdView,Serializable
- All Known Subinterfaces:
ILspAWTView
- All Known Implementing Classes:
ALspAWTView,TLspAWTView,TLspExternalView,TLspFXView,TLspOffscreenView,TLspSwingView
An
ILcdView to visualize geospatial data in 2D or 3D, based on OpenGL.
View contents
AnILspView aggregates and displays a
number of ILspLayer objects. For example, a view might display a
map's geometry using three layers: countries, roads and rivers. Each layer
can provide multiple visual representations of its model, such as for
instance geometry and labels. The order in which layers and their visual
representations are drawn is decided by the view's ILspPaintingOrder. ILspLayer has a number of additional derived
interfaces for particular use cases, which are described in the documentation
of the com.luciad.view.lightspeed.layer package.
User interaction
The view offers user interaction with its contained layers' objects through acontroller. In the view example of the previous section,
the user might pan and zoom on the map, and retrieve more information on the displayed roads.
Only one controller can be active at a time. When you instantiate a view implementing
ILspView, it activates a default controller that combines common types of user interaction:
view navigation, selection and editing.
Coordinate system
A view has a world reference that describes the coordinate system to which all its layers are mapped. The view's transformation describes how world coordinates are mapped to view coordinates. This transformation determines whether the view is a 2D map or a 3D perspective view. Refer to the transformation's class javadoc for more information about view and toolkit coordinates, map scales, screen DPI and display scaling.Toolkit integration
This interface does not define how a view can be displayed on the screen. The derived interfaceILspAWTView defines a view that lives in an AWT component.
Similarly, TLspFXView defines a view that lives in a JavaFX node.
TLspOffscreenView defines a view that can be rendered to an image.- Since:
- 2012.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumView type enumeration that distinguishes between 2D and 3D views. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given layer to the view.voidaddLayerModelListener(ILcdModelListener aModelListener) Adds aILcdModelListenerto receive model change events from any layer's model in this view.voidaddLayerSelectionListener(ILcdSelectionListener aSelectionListener) Adds the givenILcdSelectionListenerto the view so that is notified of any selection changes in any of the view's layers.addLayersFor(ILcdModel aModel) Adds a model to be displayed in this view.voidaddPropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Registers the givenPropertyChangeListenerto be notified when this view's properties change.voidaddViewInvalidationListener(ILcdViewInvalidationListener aInvalidationListener) Registers anILcdViewInvalidationListenerto be informed when the view's contents are invalid.voidaddViewListener(ILspViewListener aViewListener) Adds the givenILspViewListenerto the view to be notified of initialization, disposal or render events.voiddestroy()Frees resources associated with this view.doubleGets the vertical exaggeration factor that is applied to altitudes and elevations in this view.Returns the view's background clear color.Gets the controller that the view uses to forward input events to.default doubleReturns the DPI scaling factor of this view.default ILcdGLDrawableReturns the OpenGL drawable associated with this view.intReturns the view's current height in number of screen pixels.Gets the currently used label placer.getLayer(int aIndex) Returns the layer at the given index.Sets the factory used to create layers for models added to the view usingaddModel.Returns aListof the layers.Returns a handler to report paint exceptions.Gets the order object that determines the order in which layers and their various painters are invoked.Returns the minimum required OpenGL profile that an end user system must support in order to be compatible with this view.Returns a view services object which provides various utilities that can be leveraged by the view's layers.Convenience method that returns whether the view is currently configured for 2D or 3D visualization.Returns the transformation that is used to transform from view coordinates to world coordinates and vice versa.intgetWidth()Returns the view's current width in number of screen pixels.Returns the view's current world coordinate system.default voidinvokeLater(Runnable aRunnable) Schedules the suppliedRunnableto be executed on the thread which owns this view.booleanReturns true if the view automatically updates its representation upon receiving any event that might require an update.voidremoveLayerModelListener(ILcdModelListener aModelListener) Unregisters the givenILcdModelListenerfrom receiving model change events from any layer's model in this view.voidremoveLayerSelectionListener(ILcdSelectionListener aSelectionListener) Removes the givenILcdSelectionListenerfrom the view so that it is no longer notified of selection changes.voidremovePropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Unregisters the givenPropertyChangeListenerfrom receiving property change events for this view.voidremoveViewInvalidationListener(ILcdViewInvalidationListener aInvalidationListener) Unregisters anILcdViewInvalidationListenerso that it is no longer informed of invalidation events for this view.voidremoveViewListener(ILspViewListener aViewListener) Removes the givenILspViewListenerfrom the view.voidsetAltitudeExaggerationFactor(double aFactor) Sets the vertical exaggeration factor that is applied to altitudes and elevations in this view.voidsetAutoUpdate(boolean b) Sets whether to update the view's representation automatically to keep it in sync with its state and the state of its models.voidsetBackground(Color aColor) Sets the view's background clear color.voidsetController(ILspController aController) Sets the controller that the view will forward input events to.voidsetLabelPlacer(ILspLabelPlacer aPlacer) Sets the label placer to be used by this view.voidsetLayerFactory(ILspLayerFactory aLayerFactory) Sets the factory used to create layers for models added to the view usingaddModel.voidsetPaintingOrder(ILspPaintingOrder aPaintingOrder) Sets the order object that determines the order in which layers and their various painters are invoked.voidsetViewXYZWorldTransformation(ALspViewXYZWorldTransformation aViewXYZWorldTransformation) Sets the transformation that is used to transform from view coordinates to world coordinates and vice versa.voidsetXYZWorldReference(ILcdXYZWorldReference aXYZWorldReference) Sets the view's world coordinate system, repainting the view according toisAutoUpdate.Methods inherited from interface com.luciad.view.ILcdLayered
addLayeredListener, moveLayerAt, removeLayeredListenerMethods inherited from interface com.luciad.view.ILcdTreeLayered
addLayeredListener, containsLayer, getRootNode, indexOf, layerCount, layerOf, layers, layersBackwards, removeAllLayers, removeLayer, removeLayeredListenerMethods inherited from interface com.luciad.view.ILcdView
addModel, invalidate, removeModel
-
Method Details
-
getLayers
Description copied from interface:ILcdLayeredReturns aListof the layers.- Specified by:
getLayersin interfaceILcdLayered- Returns:
- an unmodifiable
Listof the layers in thisILcdLayered
-
getServices
TLspViewServices getServices()Returns a view services object which provides various utilities that can be leveraged by the view's layers. Examples include caching mechanisms and asynchronous processing support. Note that this method returns null if invoked after a call todestroy().- Returns:
- a view services object
-
setAutoUpdate
void setAutoUpdate(boolean b) Sets whether to update the view's representation automatically to keep it in sync with its state and the state of its models.- Specified by:
setAutoUpdatein interfaceILcdView- Parameters:
b- true if the view should update automatically; false if it will be repainted manually- See Also:
-
isAutoUpdate
boolean isAutoUpdate()Returns true if the view automatically updates its representation upon receiving any event that might require an update. Such events can include changes to properties of the view or to an Object in a model, or addition/removal of models.- Specified by:
isAutoUpdatein interfaceILcdView- Returns:
- true if the view automatically updates when necessary; false if the view must be repainted manually
- See Also:
-
setLayerFactory
Sets the factory used to create layers for models added to the view usingaddModel.- Parameters:
aLayerFactory- the factory that will be used to create layers for models added to the view
-
getLayerFactory
ILspLayerFactory getLayerFactory()Sets the factory used to create layers for models added to the view usingaddModel.- Returns:
- the factory used to create layers for models added to the view
-
addLayer
Adds the given layer to the view.- Parameters:
aLayer- the layer to add
-
getLayer
Returns the layer at the given index.- Specified by:
getLayerin interfaceILcdLayered- Specified by:
getLayerin interfaceILcdTreeLayered- Parameters:
aIndex- the index of the requested layer- Returns:
- the layer at the given index
-
addLayersFor
Adds a model to be displayed in this view. To this effect, the view asks its layer factory to create one or moreILspLayers for the model, and adds that to its layer list. This method returns the layers that were created, or null if the layer factory failed to create a layer.- Parameters:
aModel- the model to be added to the view as a new layer- Returns:
- the layers that were added
-
getBackground
Color getBackground()Returns the view's background clear color.- Returns:
- the color which is used for clearing the background
-
setBackground
Sets the view's background clear color.- Parameters:
aColor- the color to be used for clearing the background
-
getWidth
int getWidth()Returns the view's current width in number of screen pixels. Divide by the DPI scale to obtain toolkit pixels.- Returns:
- the width of the view
-
getHeight
int getHeight()Returns the view's current height in number of screen pixels. Divide by the DPI scale to obtain toolkit pixels.- Returns:
- the height of the view
-
setXYZWorldReference
Sets the view's world coordinate system, repainting the view according toisAutoUpdate.TLspViewTransformationUtilprovides a convenient way to set up a 2D or 3D view.- Parameters:
aXYZWorldReference- the new world reference associated to this view
-
getXYZWorldReference
ILcdXYZWorldReference getXYZWorldReference()Returns the view's current world coordinate system.- Returns:
- the view's world coordinate system
-
setViewXYZWorldTransformation
Sets the transformation that is used to transform from view coordinates to world coordinates and vice versa.TLspViewTransformationUtilprovides a convenient way to set up a 2D or 3D view.- Parameters:
aViewXYZWorldTransformation- the transformation that is used to transform from view coordinates to world coordinates and vice versa.
-
getViewXYZWorldTransformation
ALspViewXYZWorldTransformation getViewXYZWorldTransformation()Returns the transformation that is used to transform from view coordinates to world coordinates and vice versa.- Returns:
- the transformation that is used to transform from view coordinates to world coordinates and vice versa.
-
setController
Sets the controller that the view will forward input events to. Only one controller can be active at a time. It is the responsibility of the view to callstartInteractionwhen a controller is set on the view, andterminateInteractionwhen the controller is removed from the view. To detach a controller from the view, you either set another controller or you set the controller tonull. Furthermore, the view is responsible for providing input events to the controller via itsILcdAWTEventListener.handleAWTEvent(java.awt.AWTEvent)handleAWTEvent} method. Finally, the view must also invoke thepaintmethod of its controller any time the view itself is repainted.- Parameters:
aController- the controller to be used for the view
-
getController
ILspController getController()Gets the controller that the view uses to forward input events to.- Returns:
- the controller the view uses to forward input events to
-
addLayerSelectionListener
Adds the givenILcdSelectionListenerto the view so that is notified of any selection changes in any of the view's layers.- Parameters:
aSelectionListener- the selection listener to add
-
removeLayerSelectionListener
Removes the givenILcdSelectionListenerfrom the view so that it is no longer notified of selection changes.- Parameters:
aSelectionListener- the selection listener to remove
-
addLayerModelListener
Adds aILcdModelListenerto receive model change events from any layer's model in this view.- Parameters:
aModelListener- the listener that will be notified of model change events from any layer's model in this view.
-
removeLayerModelListener
Unregisters the givenILcdModelListenerfrom receiving model change events from any layer's model in this view.- Parameters:
aModelListener- a listener that the view will no longer notify of model change events
-
addPropertyChangeListener
Registers the givenPropertyChangeListenerto be notified when this view's properties change.- Specified by:
addPropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aPropertyChangeListener- the listener to notify of changes of this view's properties- See Also:
-
removePropertyChangeListener
Unregisters the givenPropertyChangeListenerfrom receiving property change events for this view.- Specified by:
removePropertyChangeListenerin interfaceILcdPropertyChangeSource- Parameters:
aPropertyChangeListener- the listener that should no longer be notified of changes of this views properties- See Also:
-
addViewListener
Adds the givenILspViewListenerto the view to be notified of initialization, disposal or render events.- Parameters:
aViewListener- the view listener to add
-
removeViewListener
Removes the givenILspViewListenerfrom the view.- Parameters:
aViewListener- the view listener to remove.
-
addViewInvalidationListener
Registers anILcdViewInvalidationListenerto be informed when the view's contents are invalid. This can happen directly (e.g. by callingILcdView.invalidate(boolean, Object, String)) or indirectly (e.g. by using a controller)- Parameters:
aInvalidationListener- the listener to notify when the view has been invalidated- See Also:
-
removeViewInvalidationListener
Unregisters anILcdViewInvalidationListenerso that it is no longer informed of invalidation events for this view.- Parameters:
aInvalidationListener- the listener to no longer notify when the view has been invalidated- See Also:
-
destroy
void destroy()Frees resources associated with this view. The view must not be used anymore after this method has been called. -
getPaintingOrder
ILspPaintingOrder getPaintingOrder()Gets the order object that determines the order in which layers and their various painters are invoked.- Returns:
- the painting order object
-
setPaintingOrder
Sets the order object that determines the order in which layers and their various painters are invoked.- Parameters:
aPaintingOrder- the painting order object
-
getAltitudeExaggerationFactor
double getAltitudeExaggerationFactor()Gets the vertical exaggeration factor that is applied to altitudes and elevations in this view. All elevations are multiplied with this factor during visualization. The exaggeration factor must be strictly positive. A factor of1.0results in no exaggeration. Values between 0 and 1 result in reduced relief, values higher than 1 result in increased relief. Rendering artifacts may occur when using values that are too small or too large; for most applications, values below 1 and above 20 or so will not produce useful results.- Returns:
- the vertical exaggeration factor
-
setAltitudeExaggerationFactor
void setAltitudeExaggerationFactor(double aFactor) Sets the vertical exaggeration factor that is applied to altitudes and elevations in this view. Note that this method throws an exception when a non-strict positive value is passed to it (i.e. a negative number or0). It is possible to disable terrain elevation usingILspTerrainSupport#setElevationEnabled. A factor of1.0results in no exaggeration.- Parameters:
aFactor- the vertical exaggeration factor- See Also:
-
setLabelPlacer
Sets the label placer to be used by this view.A label placer positions the labels of all the view's layers. The layers are only responsible for painting of their labels, not de-cluttering them.
- Parameters:
aPlacer- the new placer, nevernull.- Throws:
IllegalArgumentException- when the new label placer isnull.- See Also:
-
getLabelPlacer
ILspLabelPlacer getLabelPlacer()Gets the currently used label placer.- Returns:
- the current placer, never
null.
-
getRequiredOpenGLProfile
TLspOpenGLProfile getRequiredOpenGLProfile()Returns the minimum required OpenGL profile that an end user system must support in order to be compatible with this view. This profile does NOT take into account any of the layers or painters that are present in the view -- these should be checked individually to get a complete overview of an application's OpenGL requirements. All current implementations of this method returnTLspOpenGLProfile.LIGHTSPEED_MINIMUM.- Returns:
- a
TLspGLProfile
-
getPaintExceptionHandler
ILcdPaintExceptionHandler getPaintExceptionHandler()Returns a handler to report paint exceptions. The view, as well as layers and painters can use this handler if they encounter an exception during painting. Because painting may happen asynchronously, the handler may be called from different threads.- Returns:
- a handler to report paint exceptions.
-
getViewType
ILspView.ViewType getViewType()Convenience method that returns whether the view is currently configured for 2D or 3D visualization. This is actually determined by the type ofgetViewXYZWorldTransformation():TLspViewXYZWorldTransformation2Dmaps toILspView.ViewType.VIEW_2DTLspViewXYZWorldTransformation3Dmaps toILspView.ViewType.VIEW_3D
getViewType()is equivalent to aninstanceoftest on theALspViewXYZWorldTransformation.- Returns:
- the current view type
-
invokeLater
Schedules the suppliedRunnableto be executed on the thread which owns this view. For anALspAWTView, for instance, this is the Swing EDT. This method returns immediately, without waiting for the runnable to execute. Note that if the view is destroyed, any runnables that are still pending will be discarded without being executed. By default, this method throws anUnsupportedOperationException.- Parameters:
aRunnable- the runnable to be executed- Since:
- 2019.0
-
getGLDrawable
Returns the OpenGL drawable associated with this view. The drawable acts as the view's entry point to the OpenGL API. The default implementation of this method returnsnull.- Returns:
- the OpenGL drawable associated with this view
- Since:
- 2019.0
-
getDPIScale
default double getDPIScale()Returns the DPI scaling factor of this view. The DPI scale is the ratio between theOpenGL viewport width or heightand thewidth or height of the drawable itself. When DPI scaling is enabled in the host operating system, the former will be larger than the latter. For instance, if the DPI scale is set to 150%, then this method will return 1.5 andILcdGLDrawable.getViewportSize()will be 50% wider and taller thanILcdGLDrawable.getSize(). For more information about DPI scaling, seeILcdGLDrawable.getDPIScale()andALspViewXYZWorldTransformation.- Returns:
- the DPI scaling factor of this view
- Since:
- 2019.0
-