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
ConstructorsConstructorDescriptionConstructs a new, uninitialized transformation. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation2D> aConstraint) Adds a new constraint.voidaddPropertyChangeListener(PropertyChangeListener aListener) Add a PropertyChangeListener to the listener list.voidapply(ILcdGLDrawable aGLDrawable) Applies the current world-to-view transformation to the specifiedILcdGLDrawable.voidapplyLocalOrigin(ILcdGLDrawable aGLDrawable, ILcdPoint aOrigin) Modifies the OpenGLMODELVIEWmatrix so that the given point is the origin.clone()Returns a deep clone of this transformation.protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) Fires a property change event to all registered listeners.Returns an (unmodifiable)Iterablecontaining all the constraints currently set on thisTLspViewXYZWorldTransformation2D.doublegetFar()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.intGets 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.doublegetNear()Gets the value of the near plane distance.double[]Gets the projection matrix.doubleReturns the rotation in degrees, positive counter-clockwise.doubleReturns the scale in X dimension.doubleGets the scale in Y dimension.Returns the origin of the view's coordinate system.intgetWidth()Gets the width in pixels of the viewport.Returns the point at the origin of the world coordinate system.voidSets the given transformation parameters with a uniform scale.voidSets the given transformation parameters.voidremoveConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation2D> aConstraint) Removes the given constraint.voidRemove a PropertyChangeListener from the listener list.voidrestoreLocalOrigin(ILcdGLDrawable aGLDrawable) Restores the OpenGLMODELVIEWmatrix stack so that the local origin is again (0,0,0).voidset(ALspViewXYZWorldTransformation aOther) Sets this view transformation's properties to be equal to the other one.voidsetFar(double aFar) Sets the far plane distance.voidsetNear(double aNear) Sets the value of the near plane distance.voidsetSize(int aWidth, int aHeight) Sets the size of the viewport.toString()voidviewPoint2WorldSFCT(ILcdPoint aViewPoint, ILcd3DEditablePoint aWorldPointSFCT) Transforms a point in view coordinates to a point in world coordinates.voidworldPoint2ViewSFCT(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 useTLspViewTransformationUtilto preserve the visible area.- Parameters:
aView- the view for which this transformation can be used.
-
-
Method Details
-
getIdentifier
Description copied from class:ALspViewXYZWorldTransformationReturns 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:
getIdentifierin classALspViewXYZWorldTransformation- Returns:
- an object that can be used to compare transformations as described above
-
getImmutableClone
Description copied from class:ALspViewXYZWorldTransformationReturns 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:
getImmutableClonein 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. Iflisteneris 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. Iflistenerwas added more than once to the same event source, it will be notified one less time after being removed. Iflisteneris 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)Iterablecontaining all the constraints currently set on thisTLspViewXYZWorldTransformation2D.- Returns:
- an unmodifiable iterable over the current constraints.
-
applyLocalOrigin
Modifies the OpenGLMODELVIEWmatrix so that the given point is the origin. This method does not modify this transformation object.- Specified by:
applyLocalOriginin classALspViewXYZWorldTransformation- Parameters:
aGLDrawable- the drawable that is painted on. Shall not be null.aOrigin- the new origin. Shall not be null.
-
restoreLocalOrigin
Restores the OpenGLMODELVIEWmatrix stack so that the local origin is again (0,0,0).- Specified by:
restoreLocalOriginin classALspViewXYZWorldTransformation- Parameters:
aGLDrawable- the drawable painting is performed on
-
apply
Description copied from class:ALspViewXYZWorldTransformationApplies the current world-to-view transformation to the specifiedILcdGLDrawable. This method sets the OpenGL modelview and projection matrices as appropriate.- Specified by:
applyin classALspViewXYZWorldTransformation- Parameters:
aGLDrawable- theILcdGLDrawableto be configured
-
getFrustum
Description copied from class:ALspViewXYZWorldTransformationReturns the current view frustum.- Specified by:
getFrustumin 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:
setin 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:
getScaleXin classALspViewXYZWorldTransformation- Returns:
- the scale in X dimension
-
getScaleY
public double getScaleY()Gets the scale in Y dimension.- Specified by:
getScaleYin 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:
setSizein 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:
getWidthin classALspViewXYZWorldTransformation- Returns:
- the width
-
getHeight
public int getHeight()Gets the height in pixels of the viewport.- Specified by:
getHeightin classALspViewXYZWorldTransformation- Returns:
- the height
-
worldPoint2ViewSFCT
Description copied from class:ALspViewXYZWorldTransformationTransforms 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:
worldPoint2ViewSFCTin classALspViewXYZWorldTransformation- Parameters:
aWorldPoint- the world point to transformaViewPointSFCT- the point to be set
-
viewPoint2WorldSFCT
Description copied from class:ALspViewXYZWorldTransformationTransforms 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:
viewPoint2WorldSFCTin 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:
clonein classALspViewXYZWorldTransformation- Returns:
- a deep clone of this transformation
-
toString
-
getGeodeticVisibleArea
Description copied from class:ALspViewXYZWorldTransformationReturns 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:
getGeodeticVisibleAreain classALspViewXYZWorldTransformation- Returns:
- a polygon which bounds the currently visible area of the world
-