Class TLspViewNavigationUtil
This class supports:
- Panning in the view: see
pan(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint)
- Zooming the view: see
zoom(double)
- Rotating the view (both 2D and 3D): see
rotate(com.luciad.shape.ILcdPoint, double, double)
androtateTo(com.luciad.shape.ILcdPoint, double, double)
- Fitting the view on an area: see
fit(com.luciad.view.lightspeed.layer.ILspLayer...)
- Panning the view to an area: see
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.
- Animated pan:
animatedPan(com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdPoint)
- Animated zoom:
animatedZoom(double)
- Animated pan+zoom:
animatedZoomTo(com.luciad.shape.ILcdPoint, double)
- Animated rotate:
animatedRotate(com.luciad.shape.ILcdPoint, double, double)
- Animated fit:
animatedFit(com.luciad.shape.ILcdBounds, com.luciad.reference.ILcdGeoReference)
- Animated center:
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);
- Since:
- 2012.0
-
Constructor Summary
ConstructorDescriptionTLspViewNavigationUtil
(ILspView aView) Constructor for newTLspViewNavigationUtil
. -
Method Summary
Modifier and TypeMethodDescriptionanimatedCenter
(ILcdBounds aBounds, ILcdGeoReference aGeoReference) Starts an animation that moves the view to the middle of the specified bounds.animatedCenter
(ILspLayer... aLayers) Starts an animation that moves the view to the middle of data of the specified layers.animatedCenterOnModelBounds
(ILcdBounds aBounds, ILcdModelReference aReference) Starts an animation that moves the view to the middle of the specified bounds.animatedContinuousPan
(double aSpeedX, double aSpeedY) Returns an animation that pans the view until stopped with a direction and speed specified byaSpeedX
andaSpeedY
.animatedContinuousRotate
(ILcdPoint aRotateCenter, double aYawSpeed, double aPitchSpeed) Returns an animation that rotates the view aroundaRotateCenter
until stopped.animatedContinuousZoom
(ILcdPoint aViewPointCenter, double aZoomSpeed) Returns an animation that zooms the view in or out onaViewPointCenter
until stopped.animatedFit
(ILcdBounds aBounds, ILcdGeoReference aBoundsReference) Starts an animation that fits the view on the specified bounds.animatedFit
(Collection<ILspLayer> aLayers) Returns an animation that fits the view on the specified layers.animatedFitOnModelBounds
(ILcdBounds aBounds, ILcdModelReference aBoundsReference) Returns an animation that fits the view on the specified bounds.animatedPan
(ILcdPoint aViewPointStart, ILcdPoint aViewPointDestination) Returns an animation with the specifiedaDuration
that pans the view fromaViewPointStart
toaViewPointDestination
.animatedRotate
(ILcdPoint aRotateCenter, double aDeltaYaw, double aDeltaPitch) Returns an animation with the specifiedaDuration
that rotates the view aroundaRotateCenter
.animatedZoom
(double aFactor) Starts anILcdAnimation
that zooms the view by the specified factor.animatedZoom
(double aFactor, ILcdPoint aViewPointCenter) Starts anILcdAnimation
that zooms the view by the specified factor.animatedZoom
(TLcdMapScale aMapScale, TLcdMapScale.ScaleLocation aScaleLocation) Creates ananimation
that zooms from the view's current map scale to the given map scale.animatedZoomTo
(ILcdPoint aViewPointDestination, double aFactor) Starts anILcdAnimation
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
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
(ILcdBounds aBounds, ILcdGeoReference aGeoReference) Fits the view on the specified bounds.void
Fits the view on the specified layers.void
fit
(Collection<ILspLayer> aLayers) Fits the view on the specified layers.void
fitOnModelBounds
(ILcdBounds aBounds, ILcdModelReference aReference) Fits the view on the specified bounds.double
Returns the animation speedup used by all (non-continuous animations offered by this class).double
Returns the margin that is added to the bounds passed tofit(com.luciad.view.lightspeed.layer.ILspLayer...)
oranimatedFit(com.luciad.shape.ILcdBounds, com.luciad.reference.ILcdGeoReference)
.boolean
Returns true if (non-continuous) animations should be started as soon as they are created.void
Pans the view so that the world point visible underaViewPointStart
is visible underaViewPointDestination
instead.void
Rotates the view aroundaRotateCenter
.void
Rotates the view aroundaRotateCenter
.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 tofit(com.luciad.view.lightspeed.layer.ILspLayer...)
oranimatedFit(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
Zooms in or out onaViewPointCenter
with the specified factor.void
zoom
(TLcdMapScale aMapScale, TLcdMapScale.ScaleLocation aScaleLocation) Zooms to the given map scale.
-
Constructor Details
-
TLspViewNavigationUtil
Constructor for newTLspViewNavigationUtil
.- Parameters:
aView
- the view to navigate on.
-
-
Method Details
-
getAnimationSpeedUp
public double getAnimationSpeedUp()Returns the animation speedup used by all (non-continuous animations offered by this class).- Returns:
- the animation speedup.
-
setAnimationSpeedUp
public void setAnimationSpeedUp(double aAnimationSpeedUp) Sets the animation speed used by all (non-continuous animations offered by this class). The default value is1.0
. A value of2.0
means animation will run twice as fast, a value of0.5
means they take twice as long.- Parameters:
aAnimationSpeedUp
- the animation speed up to use.
-
isAutoStartAnimations
public boolean isAutoStartAnimations()Returns true if (non-continuous) animations should be started as soon as they are created.- Returns:
- true if animations are started automatically, false otherwise.
-
setAutoStartAnimations
public void setAutoStartAnimations(boolean aAutoStartAnimations) Enables or disables automatically starting (non-continuous) animations. By default this is set totrue
.- Parameters:
aAutoStartAnimations
- true if animations should be started automatically, false otherwise.- See Also:
-
pan
Pans the view so that the world point visible underaViewPointStart
is visible underaViewPointDestination
instead.- Parameters:
aViewPointStart
- the start of the pan action, in view coordinates.aViewPointDestination
- the destination of the pan action, in view coordinates.
-
rotate
Rotates the view aroundaRotateCenter
. The passed values are added to the current yaw and pitch angle.- Parameters:
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).
-
rotateTo
Rotates the view aroundaRotateCenter
. The yaw and pitch are set to the passed values.- Parameters:
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).
-
zoom
public void zoom(double aFactor) Zoom in or out on the center of the view with the specified factor.- Parameters:
aFactor
- the zoom factor with which to multiply theview scale
. Values larger than 1 zoom in, smaller values zoom out.
-
zoom
Zooms in or out onaViewPointCenter
with the specified factor.- Parameters:
aViewPointCenter
- the point to zoom in or out on, in view coordinates.aFactor
- the zoom factor with which to multiply theview scale
. Values larger than 1 zoom in, smaller values zoom out.
-
zoom
Zooms to the given map scale.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.- Parameters:
aMapScale
- the target map scale to zoom in or out toaScaleLocation
- where the map scale should be measured- Since:
- 2021.0
-
animatedPan
Returns an animation with the specifiedaDuration
that pans the view fromaViewPointStart
toaViewPointDestination
.If the
auto start property
is true, the animation will be started before the method returns, and already running navigation animations are cancelled.- Parameters:
aViewPointStart
- the start of the pan action, in view coordinates.aViewPointDestination
- the destination of the pan action, in view coordinates.- Returns:
- a pan animation
-
animatedContinuousPan
Returns an animation that pans the view until stopped with a direction and speed specified byaSpeedX
andaSpeedY
.This method will not start this animation. The user should call
putAnimation
with the view'sALspViewXYZWorldTransformation
as key. Note that this animation will run indefinitely until manually removed for the animation manager.- Parameters:
aSpeedX
- the x pan speed, in pixels per second.aSpeedY
- the y pan speed, in pixels per second.- Returns:
- an animation panning the view when started until it is stopped.
-
animatedRotate
Returns an animation with the specifiedaDuration
that rotates the view aroundaRotateCenter
.If the
auto start property
is true, the animation is started before the method returns, and already running navigation animations are cancelled.- Parameters:
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.- Returns:
- a rotate animation
-
animatedContinuousRotate
public ILcdAnimation animatedContinuousRotate(ILcdPoint aRotateCenter, double aYawSpeed, double aPitchSpeed) Returns an animation that rotates the view aroundaRotateCenter
until stopped. The speed is defined byaYawSpeed
andaPitchSpeed
.This method will not start this animation. The user should call
putAnimation
with the view'sALspViewXYZWorldTransformation
as key.- Parameters:
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.- Returns:
- an animation rotating the view when started until it is stopped.
-
animatedZoom
Starts anILcdAnimation
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.- Parameters:
aFactor
- the zoom factor with which to multiply theview scale
- Returns:
- a zoom animation
-
animatedZoom
public ALcdAnimation animatedZoom(TLcdMapScale aMapScale, TLcdMapScale.ScaleLocation aScaleLocation) Creates ananimation
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.- Parameters:
aMapScale
- the target map scale to zoom in or out toaScaleLocation
- where the map scale should be measured- Returns:
- a zoom animation
- Since:
- 2022.0
-
animatedContinuousZoom
Returns an animation that zooms the view in or out onaViewPointCenter
until stopped. The speed is defined byaZoomSpeed
.This method will not start this animation. The user should call
putAnimation
with the view'sALspViewXYZWorldTransformation
as key.- Parameters:
aViewPointCenter
- the point to zoom in on.aZoomSpeed
- the zoom speed, every second the view is zoomed with this factor by multiplying it with theview scale
- Returns:
- an animation zooming on the view when started until it is stopped.
-
animatedZoom
Starts anILcdAnimation
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, useanimatedZoomTo(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.- Parameters:
aFactor
- the zoom factor with which to multiply theview scale
aViewPointCenter
- the point to zoom in on or zoom out from, in view coordinates- Returns:
- a zoom animation
-
animatedZoomTo
Starts anILcdAnimation
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.- Parameters:
aViewPointDestination
- the location to center on, in view coordinatesaFactor
- the zoom factor with which to multiply theview scale
- Returns:
- a zoom animation
-
getFitMargin
public double getFitMargin()Returns the margin that is added to the bounds passed tofit(com.luciad.view.lightspeed.layer.ILspLayer...)
oranimatedFit(com.luciad.shape.ILcdBounds, com.luciad.reference.ILcdGeoReference)
.- Returns:
- the margin of the bounds.
- See Also:
-
setFitMargin
public void setFitMargin(double aMargin) Sets a margin on the bounds passed to
fit(com.luciad.view.lightspeed.layer.ILspLayer...)
oranimatedFit(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 is0.1
, both the width and height of the bounds are enlarged by20%
.By default, this value is 0.05.
- Parameters:
aMargin
- the margin used to enlarge the bounds on which to fit.
-
animatedFit
public ILcdAnimation animatedFit(ILcdBounds aBounds, ILcdGeoReference aBoundsReference) throws TLcdOutOfBoundsException Starts an animation that fits the view on the specified bounds.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.- Parameters:
aBounds
- the bounds to which to fit on.aBoundsReference
- the reference of the given bounds,null
if it's the view's world reference.- Returns:
- a fit animation
- Throws:
TLcdOutOfBoundsException
- when fitting on the given bounds isn't possible, for instance when the bounds aren't visible in the current projection.
-
animatedFitOnModelBounds
public ILcdAnimation animatedFitOnModelBounds(ILcdBounds aBounds, ILcdModelReference aBoundsReference) throws TLcdOutOfBoundsException Returns an animation that fits the view on the specified bounds.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.- Parameters:
aBounds
- the bounds to which to fit on.aBoundsReference
- the reference of the given bounds,null
if it's the view's world reference.- Returns:
- a fit animation
- Throws:
TLcdOutOfBoundsException
- when fitting on the given bounds isn't possible, for instance when the bounds aren't visible in the current projection.
-
animatedFit
public ILcdAnimation animatedFit(Collection<ILspLayer> aLayers) throws TLcdNoBoundsException, TLcdOutOfBoundsException Returns an animation that fits the view on the specified layers.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.- Parameters:
aLayers
- the layers to fit on.- Returns:
- a fit animation
- Throws:
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.
-
fit
Fits the view on the specified layers.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.
- Parameters:
aLayers
- the layers on which to fit- Throws:
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.
-
fit
public void fit(Collection<ILspLayer> aLayers) throws TLcdNoBoundsException, TLcdOutOfBoundsException Fits the view on the specified layers.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.
- Parameters:
aLayers
- the layers on which to fit- Throws:
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.
-
fit
Fits the view on the specified bounds.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.
- Parameters:
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.- Throws:
TLcdOutOfBoundsException
- when fitting on the given bounds isn't possible, for instance when the bounds aren't visible in the current projection.
-
fitOnModelBounds
public void fitOnModelBounds(ILcdBounds aBounds, ILcdModelReference aReference) throws TLcdOutOfBoundsException Fits the view on the specified bounds.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.
- Parameters:
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.- Throws:
TLcdOutOfBoundsException
- when fitting on the given bounds isn't possible, for instance when the bounds aren't visible in the current projection.
-
center
Moves the view to the middle of data of the specified layers. This method does not zoom the view, so the scale will not be changed,This method cancels already running view navigation animations.
- Parameters:
aLayers
- the layers to center on- Throws:
TLcdNoBoundsException
- 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.
-
center
public void center(ILcdBounds aBounds, ILcdGeoReference aGeoReference) throws TLcdOutOfBoundsException Moves the view to the middle of the specified bounds. This method does not zoom the view, so the scale will not be changed.This method cancels already running view navigation animations.
- Parameters:
aBounds
- the bounds to center onaGeoReference
- the reference of the given bounds, or null if the bounds are in the view's world coordinates.- Throws:
TLcdOutOfBoundsException
- when centering on the given bounds isn't possible, for instance when the bounds aren't visible in the current projection.
-
centerOnModelBounds
public void centerOnModelBounds(ILcdBounds aBounds, ILcdModelReference aReference) throws TLcdOutOfBoundsException Moves the view to the middle of the specified bounds. This method does not zoom the view, so the scale will not be changed.This method cancels already running view navigation animations.
- Parameters:
aBounds
- the bounds to center onaReference
- the reference of the given bounds, or null if the bounds are in the view's world coordinates.- Throws:
TLcdOutOfBoundsException
- when centering on the given bounds isn't possible, for instance when the bounds aren't visible in the current projection.
-
animatedCenter
public ILcdAnimation animatedCenter(ILspLayer... aLayers) throws TLcdOutOfBoundsException, TLcdNoBoundsException Starts an animation that moves the view to the middle of data of the specified layers. The animation may zoom out and in if needed, but the target scale is similar to the initial scale.If the
auto start property
is true, the animation is started before the method returns, and already running navigation animations are cancelled.- Parameters:
aLayers
- the layers to center on- Returns:
- a center animation
- Throws:
TLcdNoBoundsException
- 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.
-
animatedCenter
public ILcdAnimation animatedCenter(ILcdBounds aBounds, ILcdGeoReference aGeoReference) throws TLcdOutOfBoundsException Starts an animation that moves the view to the middle of the specified bounds. The animation may zoom out and in if needed, but the target scale is similar to the initial scale.If the
auto start property
is true, the animation is started before the method returns, and already running navigation animations are cancelled.- Parameters:
aBounds
- the bounds to center onaGeoReference
- the reference of the given bounds, or null if the bounds are in the view's world coordinates.- Returns:
- a center animation
- Throws:
TLcdOutOfBoundsException
- when centering on the given bounds isn't possible, for instance when the bounds aren't visible in the current projection.
-
animatedCenterOnModelBounds
public ILcdAnimation animatedCenterOnModelBounds(ILcdBounds aBounds, ILcdModelReference aReference) throws TLcdOutOfBoundsException Starts an animation that moves the view to the middle of the specified bounds. The animation may zoom out and in if needed, but the target scale is similar to the initial scale.If the
auto start property
is true, the animation is started before the method returns, and already running navigation animations are cancelled.- Parameters:
aBounds
- the bounds to center onaReference
- the reference of the given bounds, or null if the bounds are in the view's world coordinates.- Returns:
- a center animation
- Throws:
TLcdOutOfBoundsException
- when centering on the given bounds isn't possible, for instance when the bounds aren't visible in the current projection.
-