public final class TLspViewNavigationUtil extends Object
This class supports:
pan(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint)
zoom(double)
rotate(com.luciad.shape.ILcdPoint, double, double)
and rotateTo(com.luciad.shape.ILcdPoint, double, double)
fit(com.luciad.view.lightspeed.layer.ILspLayer...)
center(com.luciad.view.lightspeed.layer.ILspLayer...)
This class also supports animated navigation in a view. This allows a smooth transition from the current state to the desired state.
animatedPan(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint)
animatedZoom(double)
animatedZoomTo(com.luciad.shape.ILcdPoint, double)
animatedRotate(com.luciad.shape.ILcdPoint, double, double)
animatedFit(com.luciad.shape.ILcdBounds, com.luciad.reference.ILcdGeoReference)
animatedCenter(com.luciad.view.lightspeed.layer.ILspLayer...)
ILcdAnimation
.
Depending on the auto-start property
, you still need to run these animation
using the ALcdAnimationManager
. Typically, you would use the view's camera as
key, e.g.:
ALcdAnimationManager.getInstance().putAnimation(view.getViewXYZWorldTransformation(), animation);
Constructor and Description |
---|
TLspViewNavigationUtil(ILspView aView)
Constructor for new
TLspViewNavigationUtil . |
Modifier and Type | Method and Description |
---|---|
ILcdAnimation |
animatedCenter(ILcdBounds aBounds,
ILcdGeoReference aGeoReference)
Starts an animation that moves the view to the middle of the specified bounds.
|
ILcdAnimation |
animatedCenter(ILspLayer... aLayers)
Starts an animation that moves the view to the middle of data of the specified layers.
|
ILcdAnimation |
animatedCenterOnModelBounds(ILcdBounds aBounds,
ILcdModelReference aReference)
Starts an animation that moves the view to the middle of the specified bounds.
|
ILcdAnimation |
animatedContinuousPan(double aSpeedX,
double aSpeedY)
Returns an animation that pans the view until stopped with a direction and speed specified
by
aSpeedX and aSpeedY . |
ILcdAnimation |
animatedContinuousRotate(ILcdPoint aRotateCenter,
double aYawSpeed,
double aPitchSpeed)
Returns an animation that rotates the view around
aRotateCenter until stopped. |
ILcdAnimation |
animatedContinuousZoom(ILcdPoint aViewPointCenter,
double aZoomSpeed)
Returns an animation that zooms the view in or out on
aViewPointCenter until stopped. |
ILcdAnimation |
animatedFit(Collection<ILspLayer> aLayers)
Returns an animation that fits the view on the specified layers.
|
ILcdAnimation |
animatedFit(ILcdBounds aBounds,
ILcdGeoReference aBoundsReference)
Starts an animation that fits the view on the specified bounds.
|
ILcdAnimation |
animatedFitOnModelBounds(ILcdBounds aBounds,
ILcdModelReference aBoundsReference)
Returns an animation that fits the view on the specified bounds.
|
ALcdAnimation |
animatedPan(ILcdPoint aViewPointStart,
ILcdPoint aViewPointDestination)
Returns an animation with the specified
aDuration that pans the view from
aViewPointStart to aViewPointDestination . |
ALcdAnimation |
animatedRotate(ILcdPoint aRotateCenter,
double aDeltaYaw,
double aDeltaPitch)
Returns an animation with the specified
aDuration that rotates the view around
aRotateCenter . |
ALcdAnimation |
animatedZoom(double aFactor)
Starts an
ILcdAnimation that zooms the view by the specified
factor. |
ALcdAnimation |
animatedZoom(double aFactor,
ILcdPoint aViewPointCenter)
Starts an
ILcdAnimation that zooms the view by the specified
factor. |
ALcdAnimation |
animatedZoom(TLcdMapScale aMapScale,
TLcdMapScale.ScaleLocation aScaleLocation)
Creates an
animation that zooms from the view's current map scale
to the given map scale. |
ALcdAnimation |
animatedZoomTo(ILcdPoint aViewPointDestination,
double aFactor)
Starts an
ILcdAnimation that
centers the view on the specified point and zooms it by the specified
factor. |
void |
center(ILcdBounds aBounds,
ILcdGeoReference aGeoReference)
Moves the view to the middle of the specified bounds.
|
void |
center(ILspLayer... aLayers)
Moves the view to the middle of data of the specified layers.
|
void |
centerOnModelBounds(ILcdBounds aBounds,
ILcdModelReference aReference)
Moves the view to the middle of the specified bounds.
|
void |
fit(Collection<ILspLayer> aLayers)
Fits the view on the specified layers.
|
void |
fit(ILcdBounds aBounds,
ILcdGeoReference aGeoReference)
Fits the view on the specified bounds.
|
void |
fit(ILspLayer... aLayers)
Fits the view on the specified layers.
|
void |
fitOnModelBounds(ILcdBounds aBounds,
ILcdModelReference aReference)
Fits the view on the specified bounds.
|
double |
getAnimationSpeedUp()
Returns the animation speedup used by all (non-continuous animations offered by this class).
|
double |
getFitMargin()
Returns the margin that is added to the bounds passed to
fit(com.luciad.view.lightspeed.layer.ILspLayer...) or animatedFit(com.luciad.shape.ILcdBounds, com.luciad.reference.ILcdGeoReference) . |
boolean |
isAutoStartAnimations()
Returns true if (non-continuous) animations should be started as soon as they are created.
|
void |
pan(ILcdPoint aViewPointStart,
ILcdPoint aViewPointDestination)
Pans the view so that the world point visible under
aViewPointStart is visible under
aViewPointDestination instead. |
void |
rotate(ILcdPoint aRotateCenter,
double aDeltaYaw,
double aDeltaPitch)
Rotates the view around
aRotateCenter . |
void |
rotateTo(ILcdPoint aRotateCenter,
double aYaw,
double aPitch)
Rotates the view around
aRotateCenter . |
void |
setAnimationSpeedUp(double aAnimationSpeedUp)
Sets the animation speed used by all (non-continuous animations offered by this class).
|
void |
setAutoStartAnimations(boolean aAutoStartAnimations)
Enables or disables automatically starting (non-continuous) animations.
|
void |
setFitMargin(double aMargin)
Sets a margin on the bounds passed to
fit(com.luciad.view.lightspeed.layer.ILspLayer...) or animatedFit(com.luciad.shape.ILcdBounds, com.luciad.reference.ILcdGeoReference) . |
void |
zoom(double aFactor)
Zoom in or out on the center of the view with the specified factor.
|
void |
zoom(ILcdPoint aViewPointCenter,
double aFactor)
Zooms in or out on
aViewPointCenter with the specified factor. |
void |
zoom(TLcdMapScale aMapScale,
TLcdMapScale.ScaleLocation aScaleLocation)
Zooms to the given map scale.
|
public TLspViewNavigationUtil(ILspView aView)
TLspViewNavigationUtil
.aView
- the view to navigate on.public double getAnimationSpeedUp()
public void setAnimationSpeedUp(double aAnimationSpeedUp)
1.0
. A value of 2.0
means animation will run
twice as fast, a value of 0.5
means they take twice as long.aAnimationSpeedUp
- the animation speed up to use.public boolean isAutoStartAnimations()
public void setAutoStartAnimations(boolean aAutoStartAnimations)
true
.aAutoStartAnimations
- true if animations should be started automatically, false otherwise.animatedFit(java.util.Collection)
,
animatedFit(com.luciad.shape.ILcdBounds, com.luciad.reference.ILcdGeoReference)
,
animatedPan(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint)
,
animatedRotate(com.luciad.shape.ILcdPoint, double, double)
,
animatedZoom(double)
,
animatedZoom(double, com.luciad.shape.ILcdPoint)
,
animatedZoomTo(com.luciad.shape.ILcdPoint, double)
public void pan(ILcdPoint aViewPointStart, ILcdPoint aViewPointDestination)
aViewPointStart
is visible under
aViewPointDestination
instead.aViewPointStart
- the start of the pan action, in view coordinates.aViewPointDestination
- the destination of the pan action, in view coordinates.public void rotate(ILcdPoint aRotateCenter, double aDeltaYaw, double aDeltaPitch)
aRotateCenter
. The passed values are added to
the current yaw and pitch angle.aRotateCenter
- the point in world coordinates to rotate around.aDeltaYaw
- the change in yaw, in degrees.aDeltaPitch
- the change in pitch, in degrees (typically only used in 3D).public void rotateTo(ILcdPoint aRotateCenter, double aYaw, double aPitch)
aRotateCenter
. The yaw and pitch are set to the passed
values.aRotateCenter
- the point in world coordinates to rotate around.aYaw
- the change in yaw, in degrees.aPitch
- the change in pitch, in degrees (typically only used in 3D).public void zoom(double aFactor)
aFactor
- the zoom factor with which to multiply the view scale
.
Values larger than 1 zoom in, smaller values zoom out.public void zoom(ILcdPoint aViewPointCenter, double aFactor)
aViewPointCenter
with the specified factor.aViewPointCenter
- the point to zoom in or out on, in view coordinates.aFactor
- the zoom factor with which to multiply the view scale
.
Values larger than 1 zoom in, smaller values zoom out.public void zoom(TLcdMapScale aMapScale, TLcdMapScale.ScaleLocation aScaleLocation)
Bear in mind that on 3D maps, this method might be somewhat inaccurate.
This is the case because the map scale depends heavily on the terrain data that is currently loaded on the map,
while the terrain in turn also depends on the scale. Specifically, more detailed terrain gets loaded as you're
zooming in, so when zooming in from far away, the terrain's low level of detail can significantly affect your zoom
operation. To counter this effect, it is recommended to use the
animated zoom
instead when that is possible. This
method lasts a couple of frames and thereby allows the zoom to adapt to any terrain changes that appear in the
process.
2D maps are not affected by this issue.
aMapScale
- the target map scale to zoom in or out toaScaleLocation
- where the map scale should be measuredpublic ALcdAnimation animatedPan(ILcdPoint aViewPointStart, ILcdPoint aViewPointDestination)
aDuration
that pans the view from
aViewPointStart
to aViewPointDestination
.
If the auto start property
is true,
the animation will be started before the method returns, and already running navigation animations
are cancelled.
aViewPointStart
- the start of the pan action, in view coordinates.aViewPointDestination
- the destination of the pan action, in view coordinates.public ILcdAnimation animatedContinuousPan(double aSpeedX, double aSpeedY)
aSpeedX
and aSpeedY
.
This method will not start this animation. The user should call
putAnimation
with the view's ALspViewXYZWorldTransformation
as key. Note that this
animation will run indefinitely until manually removed for the animation manager.
aSpeedX
- the x pan speed, in pixels per second.aSpeedY
- the y pan speed, in pixels per second.public ALcdAnimation animatedRotate(ILcdPoint aRotateCenter, double aDeltaYaw, double aDeltaPitch)
aDuration
that rotates the view around
aRotateCenter
.
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aRotateCenter
- the center of the rotation, in world coordinates.aDeltaYaw
- the change in yaw, in degrees.aDeltaPitch
- the change in pitch, in degrees. Only used in 3D.public ILcdAnimation animatedContinuousRotate(ILcdPoint aRotateCenter, double aYawSpeed, double aPitchSpeed)
aRotateCenter
until stopped.
The speed is defined by aYawSpeed
and aPitchSpeed
.
This method will not start this animation. The user should call
putAnimation
with the view's ALspViewXYZWorldTransformation
as key.
aRotateCenter
- the center of the rotation, in world coordinates.aYawSpeed
- the yaw speed, in degrees per second.aPitchSpeed
- the pitch speed, in degrees per second.public ALcdAnimation animatedZoom(double aFactor)
ILcdAnimation
that zooms the view by the specified
factor. A factor 1 means no change; larger values zoom in, smaller values
zoom out. The zoom is performed on the center of the view.
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aFactor
- the zoom factor with which to multiply the view scale
public ALcdAnimation animatedZoom(TLcdMapScale aMapScale, TLcdMapScale.ScaleLocation aScaleLocation)
animation
that zooms from the view's current map scale
to the given map scale.
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aMapScale
- the target map scale to zoom in or out toaScaleLocation
- where the map scale should be measuredpublic ILcdAnimation animatedContinuousZoom(ILcdPoint aViewPointCenter, double aZoomSpeed)
aViewPointCenter
until stopped.
The speed is defined by aZoomSpeed
.
This method will not start this animation. The user should call
putAnimation
with the view's ALspViewXYZWorldTransformation
as key.
aViewPointCenter
- the point to zoom in on.aZoomSpeed
- the zoom speed, every second the view is zoomed with this factor
by multiplying it with the view scale
public ALcdAnimation animatedZoom(double aFactor, ILcdPoint aViewPointCenter)
ILcdAnimation
that zooms the view by the specified
factor. A factor 1 means no change; larger values zoom in, smaller values
zoom out. The zoom is performed around the specified point in the view.
To also pan the view so that the target point will end up in the middle of the view, use animatedZoomTo(com.luciad.shape.ILcdPoint, double)
.
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aFactor
- the zoom factor with which to multiply the view scale
aViewPointCenter
- the point to zoom in on or zoom out from, in view coordinatespublic ALcdAnimation animatedZoomTo(ILcdPoint aViewPointDestination, double aFactor)
ILcdAnimation
that
centers the view on the specified point and zooms it by the specified
factor. A factor 1 means no change; smaller values zoom in, larger values
zoom out.
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aViewPointDestination
- the location to center on, in view coordinatesaFactor
- the zoom factor with which to multiply the view scale
public double getFitMargin()
fit(com.luciad.view.lightspeed.layer.ILspLayer...)
or animatedFit(com.luciad.shape.ILcdBounds, com.luciad.reference.ILcdGeoReference)
.setFitMargin(double)
public void setFitMargin(double aMargin)
Sets a margin on the bounds passed to fit(com.luciad.view.lightspeed.layer.ILspLayer...)
or animatedFit(com.luciad.shape.ILcdBounds, com.luciad.reference.ILcdGeoReference)
.
This margin is used to enlarge the bounds on which to fit. The
given margin is a value larger than or equal to 0. The margin is added to all sides of the bounds.
E.g. if the margin is 0.1
, both the width and height of the bounds are enlarged by 20%
.
By default, this value is 0.05.
aMargin
- the margin used to enlarge the bounds on which to fit.public ILcdAnimation animatedFit(ILcdBounds aBounds, ILcdGeoReference aBoundsReference) throws TLcdOutOfBoundsException
This fit animation updates the ALspViewXYZWorldTransformation
so that the specified bounds fit entirely in the given view.
This method will both move the view and change the scale, but will keep the current rotation
or pitch (in 3D).
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aBounds
- the bounds to which to fit on.aBoundsReference
- the reference of the given bounds, null
if it's the view's world reference.TLcdOutOfBoundsException
- when fitting on the given bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public ILcdAnimation animatedFitOnModelBounds(ILcdBounds aBounds, ILcdModelReference aBoundsReference) throws TLcdOutOfBoundsException
This fit animation updates the ALspViewXYZWorldTransformation
so that the specified bounds fit entirely in the given view.
This method will both move the view and change the scale, but will keep the current rotation
or pitch (in 3D).
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aBounds
- the bounds to which to fit on.aBoundsReference
- the reference of the given bounds, null
if it's the view's world reference.TLcdOutOfBoundsException
- when fitting on the given bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public ILcdAnimation animatedFit(Collection<ILspLayer> aLayers) throws TLcdNoBoundsException, TLcdOutOfBoundsException
This fit animation updates the ALspViewXYZWorldTransformation
so that the specified layers fit entirely in the given view.
This method will both move the view and change the scale, but will keep the current rotation
or pitch (in 3D).
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aLayers
- the layers to fit on.TLcdNoBoundsException
- when no bounds could be calculated based on the passed layers,
for instance if all layers are empty.TLcdOutOfBoundsException
- when fitting on the layer bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public void fit(ILspLayer... aLayers) throws TLcdNoBoundsException, TLcdOutOfBoundsException
This fit action updates the ALspViewXYZWorldTransformation
so that the specified layers fit entirely in the given view.
This method will both move the view and change the scale, but will keep the current rotation
or pitch (in 3D).
This method cancels already running view navigation animations.
aLayers
- the layers on which to fitTLcdNoBoundsException
- when no bounds could be calculated based on the passed layers,
for instance if all layers are empty.TLcdOutOfBoundsException
- when fitting on the layer bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public void fit(Collection<ILspLayer> aLayers) throws TLcdNoBoundsException, TLcdOutOfBoundsException
This fit action updates the ALspViewXYZWorldTransformation
so that the specified layers fit entirely in the given view.
It will both move the view and change the scale, but will keep the current rotation
or pitch (in 3D).
This method cancels already running view navigation animations.
aLayers
- the layers on which to fitTLcdNoBoundsException
- when no bounds could be calculated based on the passed layers,
for instance if all layers are empty.TLcdOutOfBoundsException
- when fitting on the layer bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public void fit(ILcdBounds aBounds, ILcdGeoReference aGeoReference) throws TLcdOutOfBoundsException
This fit action updates the ALspViewXYZWorldTransformation
so that the specified bounds fits entirely in the given view.
It will both move the view and change the scale, but will keep the current rotation
or pitch (in 3D).
This method cancels already running view navigation animations.
aBounds
- the bounds to which the view will be fitaGeoReference
- the reference of the bounds to which the view will be fit, null to specify
the world reference.TLcdOutOfBoundsException
- when fitting on the given bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public void fitOnModelBounds(ILcdBounds aBounds, ILcdModelReference aReference) throws TLcdOutOfBoundsException
This fit action updates the ALspViewXYZWorldTransformation
so that the specified bounds fits entirely in the given view.
This method will both move the view and change the scale, but will keep the current rotation
or pitch (in 3D).
This method cancels already running view navigation animations.
aBounds
- the bounds to which the view will be fitaReference
- the reference of the bounds to which the view will be fit, null to specify
the world reference.TLcdOutOfBoundsException
- when fitting on the given bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public void center(ILspLayer... aLayers) throws TLcdOutOfBoundsException, TLcdNoBoundsException
This method cancels already running view navigation animations.
aLayers
- the layers to center onTLcdNoBoundsException
- when no bounds could be calculated based on the passed layers,
for instance if all layers are empty.TLcdOutOfBoundsException
- when centering on the layer bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public void center(ILcdBounds aBounds, ILcdGeoReference aGeoReference) throws TLcdOutOfBoundsException
This method cancels already running view navigation animations.
aBounds
- the bounds to center onaGeoReference
- the reference of the given bounds, or null if the bounds are in the view's world
coordinates.TLcdOutOfBoundsException
- when centering on the given bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public void centerOnModelBounds(ILcdBounds aBounds, ILcdModelReference aReference) throws TLcdOutOfBoundsException
This method cancels already running view navigation animations.
aBounds
- the bounds to center onaReference
- the reference of the given bounds, or null if the bounds are in the view's world
coordinates.TLcdOutOfBoundsException
- when centering on the given bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public ILcdAnimation animatedCenter(ILspLayer... aLayers) throws TLcdOutOfBoundsException, TLcdNoBoundsException
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aLayers
- the layers to center onTLcdNoBoundsException
- when no bounds could be calculated based on the passed layers,
for instance if all layers are empty.TLcdOutOfBoundsException
- when centering on the layer bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public ILcdAnimation animatedCenter(ILcdBounds aBounds, ILcdGeoReference aGeoReference) throws TLcdOutOfBoundsException
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aBounds
- the bounds to center onaGeoReference
- the reference of the given bounds, or null if the bounds are in the view's world
coordinates.TLcdOutOfBoundsException
- when centering on the given bounds isn't possible, for instance
when the bounds aren't visible in the current projection.public ILcdAnimation animatedCenterOnModelBounds(ILcdBounds aBounds, ILcdModelReference aReference) throws TLcdOutOfBoundsException
If the auto start property
is true,
the animation is started before the method returns, and already running navigation animations are cancelled.
aBounds
- the bounds to center onaReference
- the reference of the given bounds, or null if the bounds are in the view's world
coordinates.TLcdOutOfBoundsException
- when centering on the given bounds isn't possible, for instance
when the bounds aren't visible in the current projection.