Class TLspViewXYZWorldTransformation2D
- All Implemented Interfaces:
ILcdPropertyChangeSource
,Cloneable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.luciad.view.lightspeed.camera.ALspViewXYZWorldTransformation
ALspViewXYZWorldTransformation.LocationMode, ALspViewXYZWorldTransformation.OutputDevice
-
Constructor Summary
ConstructorDescriptionConstructs a new, uninitialized transformation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConstraint
(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation2D> aConstraint) Adds a new constraint.void
addPropertyChangeListener
(PropertyChangeListener aListener) Add a PropertyChangeListener to the listener list.void
apply
(ILcdGLDrawable aGLDrawable) Applies the current world-to-view transformation to the specifiedILcdGLDrawable
.void
applyLocalOrigin
(ILcdGLDrawable aGLDrawable, ILcdPoint aOrigin) Modifies the OpenGLMODELVIEW
matrix so that the given point is the origin.clone()
Returns a deep clone of this transformation.protected void
firePropertyChange
(String propertyName, Object oldValue, Object newValue) Fires a property change event to all registered listeners.Returns an (unmodifiable)Iterable
containing all the constraints currently set on thisTLspViewXYZWorldTransformation2D
.double
getFar()
Gets the value of the far plane distance.Returns the current view frustum.Returns a polygon which approximates the area of the globe which is visible in the current view.int
Gets the height in pixels of the viewport.Returns an identifier object that can be used to efficiently compare transformations.Returns an immutable deep clone of this transformationdouble[]
Gets the model-view matrix.double
getNear()
Gets the value of the near plane distance.double[]
Gets the projection matrix.double
Returns the rotation in degrees, positive counter-clockwise.double
Returns the scale in X dimension.double
Gets the scale in Y dimension.Returns the origin of the view's coordinate system.int
getWidth()
Gets the width in pixels of the viewport.Returns the point at the origin of the world coordinate system.void
Sets the given transformation parameters with a uniform scale.void
Sets the given transformation parameters.void
removeConstraint
(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation2D> aConstraint) Removes the given constraint.void
Remove a PropertyChangeListener from the listener list.void
restoreLocalOrigin
(ILcdGLDrawable aGLDrawable) Restores the OpenGLMODELVIEW
matrix stack so that the local origin is again (0,0,0).void
set
(ALspViewXYZWorldTransformation aOther) Sets this view transformation's properties to be equal to the other one.void
setFar
(double aFar) Sets the far plane distance.void
setNear
(double aNear) Sets the value of the near plane distance.void
setSize
(int aWidth, int aHeight) Sets the size of the viewport.toString()
void
viewPoint2WorldSFCT
(ILcdPoint aViewPoint, ILcd3DEditablePoint aWorldPointSFCT) Transforms a point in view coordinates to a point in world coordinates.void
worldPoint2ViewSFCT
(ILcdPoint aWorldPoint, ILcd3DEditablePoint aViewPointSFCT) Transforms a point in world coordinates to a point in view coordinates.Methods inherited from class com.luciad.view.lightspeed.camera.ALspViewXYZWorldTransformation
getClip, getFeatureScale, getMapScale, getOutputDevice, getScale, getView, toolkitPoint2ViewSFCT, toolkitPoint2WorldSFCT, toolkitPoint2WorldSFCT, viewAWTPoint2worldSFCT, viewBounds2worldSFCT, viewPoint2ToolkitSFCT, viewPoint2WorldSFCT, worldBounds2viewSFCT, worldPoint2ToolkitSFCT
-
Constructor Details
-
TLspViewXYZWorldTransformation2D
Constructs a new, uninitialized transformation. UselookAt(com.luciad.shape.ILcdPoint, java.awt.Point, double, double, double)
to set an initial viewer location before using this transformation, or useTLspViewTransformationUtil
to preserve the visible area.- Parameters:
aView
- the view for which this transformation can be used.
-
-
Method Details
-
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 classALspViewXYZWorldTransformation
- Returns:
- an object that can be used to compare transformations as described above
-
getImmutableClone
Description copied from class:ALspViewXYZWorldTransformation
Returns an immutable deep clone of this transformationUse this clone for example to pass the view-to-world transformation to another thread than the painting thread.
- Specified by:
getImmutableClone
in classALspViewXYZWorldTransformation
- Returns:
- an immutable deep clone of this transformation
-
addPropertyChangeListener
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. Iflistener
is null, no exception is thrown and no action is taken.- Parameters:
aListener
- The PropertyChangeListener to be added- See Also:
-
removePropertyChangeListener
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties. Iflistener
was added more than once to the same event source, it will be notified one less time after being removed. Iflistener
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
Fires a property change event to all registered listeners.- Parameters:
propertyName
- the name of the property that changedoldValue
- the old valuenewValue
- 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 thisTLspViewXYZWorldTransformation2D
.- Returns:
- an unmodifiable iterable over the current constraints.
-
applyLocalOrigin
Modifies the OpenGLMODELVIEW
matrix so that the given point is the origin. This method does not modify this transformation object.- Specified by:
applyLocalOrigin
in classALspViewXYZWorldTransformation
- Parameters:
aGLDrawable
- the drawable that is painted on. Shall not be null.aOrigin
- the new origin. Shall not be null.
-
restoreLocalOrigin
Restores the OpenGLMODELVIEW
matrix stack so that the local origin is again (0,0,0).- Specified by:
restoreLocalOrigin
in classALspViewXYZWorldTransformation
- Parameters:
aGLDrawable
- the drawable painting is performed on
-
apply
Description copied from class:ALspViewXYZWorldTransformation
Applies the current world-to-view transformation to the specifiedILcdGLDrawable
. This method sets the OpenGL modelview and projection matrices as appropriate.- Specified by:
apply
in classALspViewXYZWorldTransformation
- Parameters:
aGLDrawable
- theILcdGLDrawable
to be configured
-
getFrustum
Description copied from class:ALspViewXYZWorldTransformation
Returns the current view frustum.- Specified by:
getFrustum
in classALspViewXYZWorldTransformation
- 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 theILcdXYWorldReference
(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-unitaScaleY
- the new scale for the Y-dimension, in pixels per world-unitaRotation
- the new rotation in degrees positive counter-clockwise
-
lookAt
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 theILcdXYWorldReference
(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-unitaRotation
- the new rotation in degrees positive counter-clockwise
-
set
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 classALspViewXYZWorldTransformation
- 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
Returns the point at the origin of the world coordinate system.- Returns:
- the point at the origin of the world coordinate system
-
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 classALspViewXYZWorldTransformation
- Returns:
- the scale in X dimension
-
getScaleY
public double getScaleY()Gets the scale in Y dimension.- Specified by:
getScaleY
in classALspViewXYZWorldTransformation
- 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 classALspViewXYZWorldTransformation
- Parameters:
aWidth
- the width in pixelsaHeight
- the height in pixels
-
getWidth
public int getWidth()Gets the width in pixels of the viewport.- Specified by:
getWidth
in classALspViewXYZWorldTransformation
- Returns:
- the width
-
getHeight
public int getHeight()Gets the height in pixels of the viewport.- Specified by:
getHeight
in classALspViewXYZWorldTransformation
- Returns:
- the height
-
worldPoint2ViewSFCT
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 classALspViewXYZWorldTransformation
- Parameters:
aWorldPoint
- the world point to transformaViewPointSFCT
- the point to be set
-
viewPoint2WorldSFCT
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 classALspViewXYZWorldTransformation
- Parameters:
aViewPoint
- the view point to transform to world coordinatesaWorldPointSFCT
- 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 classALspViewXYZWorldTransformation
- Returns:
- a deep clone of this transformation
-
toString
-
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 returnsnull
.- Specified by:
getGeodeticVisibleArea
in classALspViewXYZWorldTransformation
- Returns:
- a polygon which bounds the currently visible area of the world
-