Class TLspViewXYZWorldTransformation2D

java.lang.Object
com.luciad.view.lightspeed.camera.ALspViewXYZWorldTransformation
com.luciad.view.lightspeed.camera.TLspViewXYZWorldTransformation2D
All Implemented Interfaces:
ILcdPropertyChangeSource, Cloneable

public class TLspViewXYZWorldTransformation2D extends ALspViewXYZWorldTransformation

Orthographic world-to-view transformation.

This transformation is not thread-safe for writing and should only be modified from the painting thread. The transformation is thread-safe for reading. However, to obtain consistent results on asynchronous tasks, an immutable clone should be used.

Since:
2012.0
See Also:
  • Constructor Details

  • Method Details

    • getIdentifier

      public Object getIdentifier()
      Description copied from class: ALspViewXYZWorldTransformation
      Returns an identifier object that can be used to efficiently compare transformations. If a transformation changes, the identifier should be a new object, i.e., a reference comparison should fail. This allows caches to store the identifier to associate a particular transformation state with certain data (e.g., a discretized shape).

      Testing whether a view-to-world transformation is still valid should then follow these lines of code:

      Object yourIdentifier = ...;
      ALspViewXYZWorldTransformation v2w = ...;
      Object myIdentifier = v2w.getIdentifier();
      boolean transformationValid = yourIdentifier.equals(myIdentifier);

      Specified by:
      getIdentifier in class ALspViewXYZWorldTransformation
      Returns:
      an object that can be used to compare transformations as described above
    • getImmutableClone

      public TLspViewXYZWorldTransformation2D getImmutableClone()
      Description copied from class: ALspViewXYZWorldTransformation
      Returns an immutable deep clone of this transformation

      Use this clone for example to pass the view-to-world transformation to another thread than the painting thread.

      Specified by:
      getImmutableClone in class ALspViewXYZWorldTransformation
      Returns:
      an immutable deep clone of this transformation
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener aListener)
      Add a PropertyChangeListener to the listener list. The listener is registered for all properties. The same listener object may be added more than once, and will be called as many times as it is added. If listener is null, no exception is thrown and no action is taken.
      Parameters:
      aListener - The PropertyChangeListener to be added
      See Also:
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener aListener)
      Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties. If listener was added more than once to the same event source, it will be notified one less time after being removed. If listener is null, or was never added, no exception is thrown and no action is taken.
      Parameters:
      aListener - The PropertyChangeListener to be removed
      See Also:
    • firePropertyChange

      protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
      Fires a property change event to all registered listeners.
      Parameters:
      propertyName - the name of the property that changed
      oldValue - the old value
      newValue - the new value
    • addConstraint

      public void addConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation2D> aConstraint)
      Adds a new constraint. The order in which constraints are added is important. Constraints that are added first are executed last. This means that when there are conflicts between constraints, the firstly added takes precedence.
      Parameters:
      aConstraint - a constraint.
    • removeConstraint

      public void removeConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation2D> aConstraint)
      Removes the given constraint.
      Parameters:
      aConstraint - a constraint.
    • getConstraints

      Returns an (unmodifiable) Iterable containing all the constraints currently set on this TLspViewXYZWorldTransformation2D.
      Returns:
      an unmodifiable iterable over the current constraints.
    • applyLocalOrigin

      public void applyLocalOrigin(ILcdGLDrawable aGLDrawable, ILcdPoint aOrigin)
      Modifies the OpenGL MODELVIEW matrix so that the given point is the origin.

      This method does not modify this transformation object.

      Specified by:
      applyLocalOrigin in class ALspViewXYZWorldTransformation
      Parameters:
      aGLDrawable - the drawable that is painted on. Shall not be null.
      aOrigin - the new origin. Shall not be null.
    • restoreLocalOrigin

      public void restoreLocalOrigin(ILcdGLDrawable aGLDrawable)
      Restores the OpenGL MODELVIEW matrix stack so that the local origin is again (0,0,0).
      Specified by:
      restoreLocalOrigin in class ALspViewXYZWorldTransformation
      Parameters:
      aGLDrawable - the drawable painting is performed on
    • apply

      public void apply(ILcdGLDrawable aGLDrawable)
      Description copied from class: ALspViewXYZWorldTransformation
      Applies the current world-to-view transformation to the specified ILcdGLDrawable. This method sets the OpenGL modelview and projection matrices as appropriate.
      Specified by:
      apply in class ALspViewXYZWorldTransformation
      Parameters:
      aGLDrawable - the ILcdGLDrawable to be configured
    • getFrustum

      public TLspFrustum getFrustum()
      Description copied from class: ALspViewXYZWorldTransformation
      Returns the current view frustum.
      Specified by:
      getFrustum in class ALspViewXYZWorldTransformation
      Returns:
      the current view frustum.
    • lookAt

      public void lookAt(ILcdPoint aWorldOrigin, Point aViewOrigin, double aScaleX, double aScaleY, double aRotation)
      Sets the given transformation parameters. The given world coordinates will coincide with the given view coordinates. The view is scaled and rotated using the world origin as center.

      The scale corresponds to the number of pixels per world unit, as determined by the ILcdXYWorldReference (usually meter). Hence, increasing the scale zooms in, and decreasing the scale zooms out.

      As an example, consider a view that is 1000 pixels wide, displaying geographical data, To fit and center the entire world, you need the following parameters:

      • view origin: 500,500 (the center of the view)
      • world origin: 0,0 (the center of the projected world)
      • scale: 1000 pixels/40.000km, or 1.0/40.000
      • rotation: 0 degrees
      Parameters:
      aWorldOrigin - a point in world coordinates that maps onto the view origin.
      aViewOrigin - a point in view coordinates that maps onto the world origin.
      aScaleX - the new scale for the X-dimension, in pixels per world-unit
      aScaleY - the new scale for the Y-dimension, in pixels per world-unit
      aRotation - the new rotation in degrees positive counter-clockwise
    • lookAt

      public void lookAt(ILcdPoint aWorldOrigin, Point aViewOrigin, double aScale, double aRotation)
      Sets the given transformation parameters with a uniform scale. The given world coordinates will coincide with the given view coordinates. The view is scaled and rotated using the world origin as center.

      The scale corresponds to the number of pixels per world unit, as determined by the ILcdXYWorldReference (usually meter). Hence, increasing the scale zooms in, and decreasing the scale zooms out.

      As an example, consider a view that is 1000 pixels wide, displaying geographical data, To fit and center the entire world, you need the following parameters:

      • view origin: 500,500 (the center of the view)
      • world origin: 0,0 (the center of the projected world)
      • scale: 1000 pixels/40.000km, or 1.0/40.000
      • rotation: 0 degrees
      Parameters:
      aWorldOrigin - a point in world coordinates that maps onto the view origin.
      aViewOrigin - a point in view coordinates that maps onto the world origin.
      aScale - the new scale in physical screen pixels per world-unit
      aRotation - the new rotation in degrees positive counter-clockwise
    • set

      public void set(ALspViewXYZWorldTransformation aOther)
      Sets this view transformation's properties to be equal to the other one. This does not consider any transformation constraints or the width and height of the view. This method only considers: This method can be useful to keep two transformations in sync (e.g., when having two views that need to exactly use the same camera properties).
      Specified by:
      set in class ALspViewXYZWorldTransformation
      Parameters:
      aOther - the transformation to copy the properties from
      Throws:
      IllegalArgumentException - if aOther is not a TLspViewXYZWorldTransformation2D
      See Also:
    • getModelViewMatrix

      public double[] getModelViewMatrix()
      Gets the model-view matrix.

      The array is a linearized 4x4 matrix where result[0] corresponds to row=0 and column=0, result[1] corresponds to row=1, column=0, etc. Note that this corresponds to how OpenGL expects matrices to be linearized.

      Returns:
      a 16 element matrix representing the model-view transformation
    • getProjectionMatrix

      public double[] getProjectionMatrix()
      Gets the projection matrix.

      The array is a linearized 4x4 matrix where result[0] corresponds to row=0 and column=0, result[1] corresponds to row=1, column=0, etc. Note that this corresponds to how OpenGL expects matrices to be linearized.

      Returns:
      a 16 element matrix representing the perspective transformation
    • getWorldOrigin

      public TLcdXYPoint getWorldOrigin()
      Returns the point at the origin of the world coordinate system.
      Returns:
      the point at the origin of the world coordinate system
    • getViewOrigin

      public Point getViewOrigin()
      Returns the origin of the view's coordinate system.
      Returns:
      the view's origin
    • getScaleX

      public double getScaleX()
      Returns the scale in X dimension.
      Specified by:
      getScaleX in class ALspViewXYZWorldTransformation
      Returns:
      the scale in X dimension
    • getScaleY

      public double getScaleY()
      Gets the scale in Y dimension.
      Specified by:
      getScaleY in class ALspViewXYZWorldTransformation
      Returns:
      the scale in Y dimension
    • getRotation

      public double getRotation()
      Returns the rotation in degrees, positive counter-clockwise.
      Returns:
      the rotation rotation
    • getNear

      public double getNear()
      Gets the value of the near plane distance.
      Returns:
      the value of the near plane distance
    • setNear

      public void setNear(double aNear)
      Sets the value of the near plane distance.
      Parameters:
      aNear - the new near plane distance
    • getFar

      public double getFar()
      Gets the value of the far plane distance.
      Returns:
      the far plane distance
    • setFar

      public void setFar(double aFar)
      Sets the far plane distance.
      Parameters:
      aFar - the new far plane distance
    • setSize

      public void setSize(int aWidth, int aHeight)
      Sets the size of the viewport.
      Specified by:
      setSize in class ALspViewXYZWorldTransformation
      Parameters:
      aWidth - the width in pixels
      aHeight - the height in pixels
    • getWidth

      public int getWidth()
      Gets the width in pixels of the viewport.
      Specified by:
      getWidth in class ALspViewXYZWorldTransformation
      Returns:
      the width
    • getHeight

      public int getHeight()
      Gets the height in pixels of the viewport.
      Specified by:
      getHeight in class ALspViewXYZWorldTransformation
      Returns:
      the height
    • worldPoint2ViewSFCT

      public void worldPoint2ViewSFCT(ILcdPoint aWorldPoint, ILcd3DEditablePoint aViewPointSFCT)
      Description copied from class: ALspViewXYZWorldTransformation
      Transforms a point in world coordinates to a point in view coordinates. The result of the transformation is stored in the second point parameter.

      See the class documentation for important information about view coordinates and DPI scaling.

      Specified by:
      worldPoint2ViewSFCT in class ALspViewXYZWorldTransformation
      Parameters:
      aWorldPoint - the world point to transform
      aViewPointSFCT - the point to be set
    • viewPoint2WorldSFCT

      public void viewPoint2WorldSFCT(ILcdPoint aViewPoint, ILcd3DEditablePoint aWorldPointSFCT)
      Description copied from class: ALspViewXYZWorldTransformation

      Transforms a point in view coordinates to a point in world coordinates. The result of the transformation is stored in the second point parameter.

      Note: this method interprets the z value ([0,1]) of the given point as the depth value in view space. If you are using 2D view points (e.g. the x and y coordinates of the mouse), it is advised to use ALspViewXYZWorldTransformation.viewPoint2WorldSFCT(Point, LocationMode, ILcd3DEditablePoint), which can calculate the world point at sea level or on the surface closest to the viewer.

      See the class documentation for important information about view coordinates and DPI scaling.

      Specified by:
      viewPoint2WorldSFCT in class ALspViewXYZWorldTransformation
      Parameters:
      aViewPoint - the view point to transform to world coordinates
      aWorldPointSFCT - the point to set
    • clone

      Returns a deep clone of this transformation.

      Note: this method doesn't copy over or clone the added constraints.

      Overrides:
      clone in class ALspViewXYZWorldTransformation
      Returns:
      a deep clone of this transformation
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getGeodeticVisibleArea

      public ILcdComplexPolygon getGeodeticVisibleArea()
      Description copied from class: ALspViewXYZWorldTransformation
      Returns a polygon which approximates the area of the globe which is visible in the current view. The polygon is expressed in geodetic coordinates using a standard WGS84 datum (i.e. the reference created by the default constructor of TLcdGeodeticReference). In some 2D map projections, the visible part of the map may consist of multiple disjoint areas. For this reason, this method returns a complex polygon.

      The computation does not take terrain into account: it is essentially the intersection of the frustum with the surface of the ellipsoid as seen in the current world reference.

      If the world is entirely outside of the view, this method returns null.

      Specified by:
      getGeodeticVisibleArea in class ALspViewXYZWorldTransformation
      Returns:
      a polygon which bounds the currently visible area of the world