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.
TLspViewTransformationUtil
ALspViewXYZWorldTransformation.LocationMode, ALspViewXYZWorldTransformation.OutputDevice
Constructor and Description |
---|
TLspViewXYZWorldTransformation2D(ILspView aView)
Constructs a new, uninitialized transformation.
|
Modifier and Type | Method and Description |
---|---|
void |
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 specified
ILcdGLDrawable . |
void |
applyLocalOrigin(ILcdGLDrawable aGLDrawable,
ILcdPoint aOrigin)
Modifies the OpenGL
MODELVIEW matrix so that the given
point is the origin. |
TLspViewXYZWorldTransformation2D |
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.
|
Iterable<ALspCameraConstraint<TLspViewXYZWorldTransformation2D>> |
getConstraints()
Returns an (unmodifiable)
Iterable containing all the constraints currently set on
this TLspViewXYZWorldTransformation2D . |
double |
getFar()
Gets the value of the far plane distance.
|
TLspFrustum |
getFrustum()
Returns the current view frustum.
|
ILcdComplexPolygon |
getGeodeticVisibleArea()
Returns a polygon which approximates the area of the globe which is
visible in the current view.
|
int |
getHeight()
Gets the height in pixels of the viewport.
|
Object |
getIdentifier()
Returns an identifier object that can be used to efficiently
compare transformations.
|
TLspViewXYZWorldTransformation2D |
getImmutableClone()
Returns an immutable deep clone of this transformation
|
double[] |
getModelViewMatrix()
Gets the model-view matrix.
|
double |
getNear()
Gets the value of the near plane distance.
|
double[] |
getProjectionMatrix()
Gets the projection matrix.
|
double |
getRotation()
Returns the rotation in degrees, positive counter-clockwise.
|
double |
getScaleX()
Returns the scale in X dimension.
|
double |
getScaleY()
Gets the scale in Y dimension.
|
Point |
getViewOrigin()
Returns the origin of the view's coordinate system.
|
int |
getWidth()
Gets the width in pixels of the viewport.
|
TLcdXYPoint |
getWorldOrigin()
Returns the point at the origin of the world coordinate system.
|
void |
lookAt(ILcdPoint aWorldOrigin,
Point aViewOrigin,
double aScale,
double aRotation)
Sets the given transformation parameters with a uniform scale.
|
void |
lookAt(ILcdPoint aWorldOrigin,
Point aViewOrigin,
double aScaleX,
double aScaleY,
double aRotation)
Sets the given transformation parameters.
|
void |
removeConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation2D> aConstraint)
Removes the given constraint.
|
void |
removePropertyChangeListener(PropertyChangeListener aListener)
Remove a PropertyChangeListener from the listener list.
|
void |
restoreLocalOrigin(ILcdGLDrawable aGLDrawable)
Restores the OpenGL
MODELVIEW 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.
|
String |
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.
|
getClip, getFeatureScale, getMapScale, getOutputDevice, getScale, getView, toolkitPoint2ViewSFCT, toolkitPoint2WorldSFCT, toolkitPoint2WorldSFCT, viewAWTPoint2worldSFCT, viewBounds2worldSFCT, viewPoint2ToolkitSFCT, viewPoint2WorldSFCT, worldBounds2viewSFCT, worldPoint2ToolkitSFCT
public TLspViewXYZWorldTransformation2D(ILspView aView)
lookAt(com.luciad.shape.ILcdPoint, java.awt.Point, double, double, double)
to set an initial viewer
location before using this transformation, or use
TLspViewTransformationUtil
to
preserve the visible area.aView
- the view for which this transformation can be used.public Object getIdentifier()
ALspViewXYZWorldTransformation
Object yourIdentifier = ...;
ALspViewXYZWorldTransformation v2w = ...;
Object myIdentifier = v2w.getIdentifier();
boolean transformationValid = yourIdentifier.equals(myIdentifier);
getIdentifier
in class ALspViewXYZWorldTransformation
public TLspViewXYZWorldTransformation2D getImmutableClone()
ALspViewXYZWorldTransformation
Use this clone for example to pass the view-to-world transformation to another thread than the painting thread.
getImmutableClone
in class ALspViewXYZWorldTransformation
public void addPropertyChangeListener(PropertyChangeListener aListener)
listener
is null, no exception is thrown and no action
is taken.aListener
- The PropertyChangeListener to be addedALcdWeakPropertyChangeListener
,
ILcdPropertyChangeSource.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener aListener)
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.aListener
- The PropertyChangeListener to be removedILcdPropertyChangeSource.addPropertyChangeListener(java.beans.PropertyChangeListener)
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
propertyName
- the name of the property that changedoldValue
- the old valuenewValue
- the new valuepublic void addConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation2D> aConstraint)
aConstraint
- a constraint.public void removeConstraint(ALspCameraConstraint<? extends TLspViewXYZWorldTransformation2D> aConstraint)
aConstraint
- a constraint.public Iterable<ALspCameraConstraint<TLspViewXYZWorldTransformation2D>> getConstraints()
Iterable
containing all the constraints currently set on
this TLspViewXYZWorldTransformation2D
.public void applyLocalOrigin(ILcdGLDrawable aGLDrawable, ILcdPoint aOrigin)
MODELVIEW
matrix so that the given
point is the origin.
This method does not modify this transformation object.applyLocalOrigin
in class ALspViewXYZWorldTransformation
aGLDrawable
- the drawable that is painted on. Shall not be null.aOrigin
- the new origin. Shall not be null.public void restoreLocalOrigin(ILcdGLDrawable aGLDrawable)
MODELVIEW
matrix stack
so that the local origin is again (0,0,0).restoreLocalOrigin
in class ALspViewXYZWorldTransformation
aGLDrawable
- the drawable painting is performed onpublic void apply(ILcdGLDrawable aGLDrawable)
ALspViewXYZWorldTransformation
ILcdGLDrawable
. This method sets the OpenGL modelview and projection
matrices as appropriate.apply
in class ALspViewXYZWorldTransformation
aGLDrawable
- the ILcdGLDrawable
to be configuredpublic TLspFrustum getFrustum()
ALspViewXYZWorldTransformation
getFrustum
in class ALspViewXYZWorldTransformation
public void lookAt(ILcdPoint aWorldOrigin, Point aViewOrigin, double aScaleX, double aScaleY, double aRotation)
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:
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-clockwisepublic void lookAt(ILcdPoint aWorldOrigin, Point aViewOrigin, double aScale, double aRotation)
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:
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-clockwisepublic void set(ALspViewXYZWorldTransformation aOther)
set
in class ALspViewXYZWorldTransformation
aOther
- the transformation to copy the properties fromIllegalArgumentException
- if aOther is not a TLspViewXYZWorldTransformation2Dset(ALspViewXYZWorldTransformation)
,
TLspViewXYZWorldTransformation3D.set(ALspViewXYZWorldTransformation)
public double[] getModelViewMatrix()
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.
public double[] getProjectionMatrix()
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.
public TLcdXYPoint getWorldOrigin()
public Point getViewOrigin()
public double getScaleX()
getScaleX
in class ALspViewXYZWorldTransformation
public double getScaleY()
getScaleY
in class ALspViewXYZWorldTransformation
public double getRotation()
public double getNear()
public void setNear(double aNear)
aNear
- the new near plane distancepublic double getFar()
public void setFar(double aFar)
aFar
- the new far plane distancepublic void setSize(int aWidth, int aHeight)
setSize
in class ALspViewXYZWorldTransformation
aWidth
- the width in pixelsaHeight
- the height in pixelspublic int getWidth()
getWidth
in class ALspViewXYZWorldTransformation
public int getHeight()
getHeight
in class ALspViewXYZWorldTransformation
public void worldPoint2ViewSFCT(ILcdPoint aWorldPoint, ILcd3DEditablePoint aViewPointSFCT)
ALspViewXYZWorldTransformation
See the class documentation for important information about view coordinates and DPI scaling.
worldPoint2ViewSFCT
in class ALspViewXYZWorldTransformation
aWorldPoint
- the world point to transformaViewPointSFCT
- the point to be setpublic void viewPoint2WorldSFCT(ILcdPoint aViewPoint, ILcd3DEditablePoint aWorldPointSFCT)
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.
viewPoint2WorldSFCT
in class ALspViewXYZWorldTransformation
aViewPoint
- the view point to transform to world coordinatesaWorldPointSFCT
- the point to setpublic TLspViewXYZWorldTransformation2D clone()
Note: this method doesn't copy over or clone the added constraints.
clone
in class ALspViewXYZWorldTransformation
public ILcdComplexPolygon getGeodeticVisibleArea()
ALspViewXYZWorldTransformation
null
.getGeodeticVisibleArea
in class ALspViewXYZWorldTransformation