Interface ILspView

All Superinterfaces:
ILcdLayered, ILcdPropertyChangeSource, ILcdTreeLayered, ILcdView, Serializable
All Known Subinterfaces:
ILspAWTView
All Known Implementing Classes:
ALspAWTView, TLspAWTView, TLspExternalView, TLspFXView, TLspOffscreenView, TLspSwingView

public interface ILspView extends ILcdView, ILcdTreeLayered
An ILcdView to visualize geospatial data in 2D or 3D, based on OpenGL.

View contents

An ILspView 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 a controller. 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 interface ILspAWTView 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
  • Method Details

    • getLayers

      default List<ILspLayer> getLayers()
      Description copied from interface: ILcdLayered
      Returns a List of the layers.
      Specified by:
      getLayers in interface ILcdLayered
      Returns:
      an unmodifiable List of the layers in this ILcdLayered
    • 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 to destroy().
      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:
      setAutoUpdate in interface ILcdView
      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:
      isAutoUpdate in interface ILcdView
      Returns:
      true if the view automatically updates when necessary; false if the view must be repainted manually
      See Also:
    • setLayerFactory

      void setLayerFactory(ILspLayerFactory aLayerFactory)
      Sets the factory used to create layers for models added to the view using addModel.
      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 using addModel.
      Returns:
      the factory used to create layers for models added to the view
    • addLayer

      void addLayer(ILspLayer aLayer)
      Adds the given layer to the view.
      Parameters:
      aLayer - the layer to add
    • getLayer

      ILspLayer getLayer(int aIndex)
      Returns the layer at the given index.
      Specified by:
      getLayer in interface ILcdLayered
      Specified by:
      getLayer in interface ILcdTreeLayered
      Parameters:
      aIndex - the index of the requested layer
      Returns:
      the layer at the given index
    • addLayersFor

      Collection<ILspLayer> addLayersFor(ILcdModel aModel)
      Adds a model to be displayed in this view. To this effect, the view asks its layer factory to create one or more ILspLayers 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

      void setBackground(Color aColor)
      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

      void setXYZWorldReference(ILcdXYZWorldReference aXYZWorldReference)
      Sets the view's world coordinate system, repainting the view according to isAutoUpdate.

      TLspViewTransformationUtil provides 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

      void setViewXYZWorldTransformation(ALspViewXYZWorldTransformation aViewXYZWorldTransformation)
      Sets the transformation that is used to transform from view coordinates to world coordinates and vice versa.

      TLspViewTransformationUtil provides 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

      void setController(ILspController aController)
      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 call startInteraction when a controller is set on the view, and terminateInteraction when the controller is removed from the view. To detach a controller from the view, you either set another controller or you set the controller to null. Furthermore, the view is responsible for providing input events to the controller via its ILcdAWTEventListener.handleAWTEvent(java.awt.AWTEvent) handleAWTEvent} method. Finally, the view must also invoke the paint method 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

      void addLayerSelectionListener(ILcdSelectionListener aSelectionListener)
      Adds the given ILcdSelectionListener to 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

      void removeLayerSelectionListener(ILcdSelectionListener aSelectionListener)
      Removes the given ILcdSelectionListener from the view so that it is no longer notified of selection changes.
      Parameters:
      aSelectionListener - the selection listener to remove
    • addLayerModelListener

      void addLayerModelListener(ILcdModelListener aModelListener)
      Adds a ILcdModelListener to 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

      void removeLayerModelListener(ILcdModelListener aModelListener)
      Unregisters the given ILcdModelListener from 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

      void addPropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
      Registers the given PropertyChangeListener to be notified when this view's properties change.
      Specified by:
      addPropertyChangeListener in interface ILcdPropertyChangeSource
      Parameters:
      aPropertyChangeListener - the listener to notify of changes of this view's properties
      See Also:
    • removePropertyChangeListener

      void removePropertyChangeListener(PropertyChangeListener aPropertyChangeListener)
      Unregisters the given PropertyChangeListener from receiving property change events for this view.
      Specified by:
      removePropertyChangeListener in interface ILcdPropertyChangeSource
      Parameters:
      aPropertyChangeListener - the listener that should no longer be notified of changes of this views properties
      See Also:
    • addViewListener

      void addViewListener(ILspViewListener aViewListener)
      Adds the given ILspViewListener to the view to be notified of initialization, disposal or render events.
      Parameters:
      aViewListener - the view listener to add
    • removeViewListener

      void removeViewListener(ILspViewListener aViewListener)
      Removes the given ILspViewListener from the view.
      Parameters:
      aViewListener - the view listener to remove.
    • addViewInvalidationListener

      void addViewInvalidationListener(ILcdViewInvalidationListener aInvalidationListener)
      Registers an ILcdViewInvalidationListener to be informed when the view's contents are invalid. This can happen directly (e.g. by calling ILcdView.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

      void removeViewInvalidationListener(ILcdViewInvalidationListener aInvalidationListener)
      Unregisters an ILcdViewInvalidationListener so 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

      void setPaintingOrder(ILspPaintingOrder aPaintingOrder)
      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 of 1.0 results 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 or 0). It is possible to disable terrain elevation using ILspTerrainSupport#setElevationEnabled.

      A factor of 1.0 results in no exaggeration.

      Parameters:
      aFactor - the vertical exaggeration factor
      See Also:
    • setLabelPlacer

      void setLabelPlacer(ILspLabelPlacer aPlacer)
      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, never null.
      Throws:
      IllegalArgumentException - when the new label placer is null.
      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 return TLspOpenGLProfile.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 of getViewXYZWorldTransformation(): In other words, getViewType() is equivalent to an instanceof test on the ALspViewXYZWorldTransformation.
      Returns:
      the current view type
    • invokeLater

      default void invokeLater(Runnable aRunnable)
      Schedules the supplied Runnable to be executed on the thread which owns this view. For an ALspAWTView, 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 an UnsupportedOperationException.

      Parameters:
      aRunnable - the runnable to be executed
      Since:
      2019.0
    • getGLDrawable

      default ILcdGLDrawable 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 returns null.

      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 the OpenGL viewport width or height and the width 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 and ILcdGLDrawable.getViewportSize() will be 50% wider and taller than ILcdGLDrawable.getSize(). For more information about DPI scaling, see ILcdGLDrawable.getDPIScale() and ALspViewXYZWorldTransformation.
      Returns:
      the DPI scaling factor of this view
      Since:
      2019.0