public class DraggableSupport
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
altitudeMode
The altitude mode of the object to be dragged.
|
protected double |
convergenceThreshold
This instances convergence threshold for the solver used to determine the position of objects using the
WorldWind.RELATIVE_TO_GROUND altitude mode. |
static double |
DEFAULT_CONVERGENCE_THRESHOLD
The
computeRelativePoint(Line, Globe, SceneController, double) method uses a numeric
search method to determine the coordinates of the desired position. |
static int |
DEFAULT_STEP_LIMIT
The
computeRelativePoint(Line, Globe, SceneController, double) method uses a numeric
search method to determine the coordinates of the desired position. |
protected java.lang.Object |
dragObject
The object that will be subject to the drag operations.
|
protected Vec4 |
initialEllipsoidalReferencePoint
Initial drag operation cartesian coordinates of the objects reference position.
|
protected Vec4 |
initialEllipsoidalScreenPoint
Initial drag operation cartesian coordinates of the initial screen point.
|
protected Vec4 |
initialScreenPointOffset
Initial drag operation offset in x and y screen coordinates, between the object reference position and the screen
point.
|
protected int |
stepLimit
This instances step limit when using the solver to determine the position of objects using the
WorldWind.RELATIVE_TO_GROUND altitude mode. |
Constructor and Description |
---|
DraggableSupport(java.lang.Object dragObject,
int altitudeMode)
Provides persistence of initial values of a drag operation to increase dragging precision and provide better
dragging behavior.
|
Modifier and Type | Method and Description |
---|---|
protected Vec4 |
computeEllipsoidalPointFromScreen(DragContext dragContext,
java.awt.Point screenPoint,
double altitude,
boolean utilizeSearchMethod)
Determines the cartesian coordinate of a screen point given the altitude mode.
|
protected Vec4 |
computeGlobeIntersection(Line ray,
double altitude,
boolean useSearchMethod,
Globe globe,
SceneController sceneController)
|
protected Vec4 |
computeRelativePoint(Line ray,
Globe globe,
SceneController sceneController,
double altitude)
Attempts to find a position with the altitude specified for objects which are
WorldWind.RELATIVE_TO_GROUND . |
protected Vec4 |
computeScreenOffsetFromReferencePosition(Position dragObjectReferencePosition,
DragContext dragContext)
Determines the offset in screen coordinates from the previous screen point (
DragContext.getInitialPoint()
and the objects Movable.getReferencePosition() or Movable2.getReferencePosition() methods. |
protected void |
doMove(Position movePosition,
Globe globe)
Executes the
Movable2.moveTo(Globe, Position) or Movable.moveTo(Position) methods with the
provided data. |
void |
dragGlobeSizeConstant(DragContext dragContext)
Converts the screen position inputs to geographic movement information.
|
void |
dragScreenSizeConstant(DragContext dragContext)
Converts the screen position inputs to geographic movement information.
|
int |
getAltitudeMode()
Returns the current altitude mode being used by the dragging calculations.
|
double |
getConvergenceThreshold()
Returns the convergence threshold used by the solver when an a screen size constant object using a
WorldWind.RELATIVE_TO_GROUND altitude mode needs to determine a position. |
protected Position |
getReferencePosition()
|
int |
getStepLimit()
Returns the step limit used by the position solver method for objects using a screen size constant drag approach
and a
WorldWind.RELATIVE_TO_GROUND altitude mode. |
void |
setAltitudeMode(int altitudeMode)
Sets the altitude mode to be used during dragging calculations.
|
void |
setConvergenceThreshold(double convergenceThreshold)
Sets the convergence threshold for the screen size constant object using a
WorldWind.RELATIVE_TO_GROUND
altitude mode. |
void |
setStepLimit(int stepLimit)
Sets the step limit to use for the position solver.
|
protected int altitudeMode
protected double convergenceThreshold
WorldWind.RELATIVE_TO_GROUND
altitude mode. Decreasing this value will increase solver runtime and may
cause the event loop to hang. If the solver does not converge to the threshold specified here, it will fall back
to using a position calculated by intersection with the ellipsoid.public static final double DEFAULT_CONVERGENCE_THRESHOLD
computeRelativePoint(Line, Globe, SceneController, double)
method uses a numeric
search method to determine the coordinates of the desired position. The numeric solver will stop at a defined
threshold or step limit. The default threshold is provided here. This value is utilized when using the static
drag functions provided by this class.public static final int DEFAULT_STEP_LIMIT
computeRelativePoint(Line, Globe, SceneController, double)
method uses a numeric
search method to determine the coordinates of the desired position. The numeric solver will stop at a defined
threshold or step limit. The default step limit is provided here. This value is utilized when using the static
drag functions provided by this class.protected final java.lang.Object dragObject
protected Vec4 initialEllipsoidalReferencePoint
protected Vec4 initialEllipsoidalScreenPoint
protected Vec4 initialScreenPointOffset
protected int stepLimit
WorldWind.RELATIVE_TO_GROUND
altitude mode. Increasing this value will increase solver runtime and may
cause the event loop to hang. If the solver exceeds the number of steps specified here, it will fall back to
using a position calculated by intersection with the ellipsoid.public DraggableSupport(java.lang.Object dragObject, int altitudeMode)
dragObject
- the object to be dragged.altitudeMode
- the altitude mode.java.lang.IllegalArgumentException
- if the object is null.protected Vec4 computeEllipsoidalPointFromScreen(DragContext dragContext, java.awt.Point screenPoint, double altitude, boolean utilizeSearchMethod)
dragContext
- the current DragContext
of the dragging event.screenPoint
- the Point
of the screen to determine the position.altitude
- the altitude in meters.utilizeSearchMethod
- if the altitude mode is WorldWind.RELATIVE_TO_GROUND
, this determines if the
search method will be used to determine the position, please see the computeRelativePoint(Line, Globe, SceneController, double)
for more
information.protected Vec4 computeGlobeIntersection(Line ray, double altitude, boolean useSearchMethod, Globe globe, SceneController sceneController)
Line
with the Globe
while accounting for the altitude
mode. If a Globe2D
is specified, then the intersection is calculated using the globe objects method.ray
- the Line
to calculate the intersection of the Globe
.altitude
- the altitude mode for the intersection calculation.useSearchMethod
- if the altitude mode is WorldWind.RELATIVE_TO_GROUND
, this determines if the
search method will be used to determine the position, please see the computeRelativePoint(Line, Globe, SceneController, double)
for more
information.globe
- the Globe
to intersect.sceneController
- if an altitude mode other than WorldWind.ABSOLUTE
is specified, the SceneController
which will provide terrain information.Globe
s coordinate system or null if
the intersection couldn't be calculated.protected Vec4 computeRelativePoint(Line ray, Globe globe, SceneController sceneController, double altitude)
WorldWind.RELATIVE_TO_GROUND
. Using the provided Line
, conducts a bisectional search along the Line
for a Position
which is within the convergenceThreshold
of the requested altitude
provided. The stepLimit
limits the number of bisections the function will attempt. If the search does not
find a position within the stepLimit
or within the convergenceThreshold
it will provide an
intersection with the ellipsoid at the provided altitude.ray
- the Line
from the eye point and direction in globe coordinates.globe
- the current Globe
.sceneController
- the current SceneController
.altitude
- the target altitude.Vec4
of the point in globe coordinates.protected Vec4 computeScreenOffsetFromReferencePosition(Position dragObjectReferencePosition, DragContext dragContext)
DragContext.getInitialPoint()
and the objects Movable.getReferencePosition()
or Movable2.getReferencePosition()
methods. If the
object doesn't implement either of the interfaces, or there is an error determining the offset, this function
will return null.dragObjectReferencePosition
- the Movable
or Movable2
reference position Position
.dragContext
- the current DragContext
of this drag event.Vec4
containing the x and y offsets in screen coordinates from the reference position and the
previous screen point.protected void doMove(Position movePosition, Globe globe)
Movable2.moveTo(Globe, Position)
or Movable.moveTo(Position)
methods with the
provided data. If the object implements both interfaces, the Movable2
is used. If the object doesn't
implement either, it is ignored.movePosition
- the Position
to provide to the Movable2.moveTo(gov.nasa.worldwind.globes.Globe, gov.nasa.worldwind.geom.Position)
method.globe
- the globe reference, may be null if the object only implements the Movable
interface.public void dragGlobeSizeConstant(DragContext dragContext)
DragContext
object and attempts to move the object using the Movable2
or Movable
interface. This method maintains a constant geographic distance between the cursor and the reference point of the
object being dragged. It is suited for objects which maintain a constant model space or geographic size.dragContext
- the current DragContext
for this object.java.lang.IllegalArgumentException
- if the DragContext
is null.public void dragScreenSizeConstant(DragContext dragContext)
DragContext
object and attempts to move the object using the Movable2
or Movable
interface. This method maintains a constant screen offset from the cursor to the reference point of the object
being dragged. It is suited for objects maintaining a constant screen size presentation like,
TacticalSymbols
or
PointPlacemark
.dragContext
- the current DragContext
for this object.java.lang.IllegalArgumentException
- if the DragContext
is null.public int getAltitudeMode()
public double getConvergenceThreshold()
WorldWind.RELATIVE_TO_GROUND
altitude mode needs to determine a position. When the solver finds an
altitude within the convergence threshold to the desired altitude, the solver will stop and return the cartesian
position.protected Position getReferencePosition()
Position
from objects implementing Movable
or Movable2
. For
objects implementing both, it utilizes the Movable2
interface method. If the object does not implement
the interfaces, null is returned.Movable.getReferencePosition()
or Movable2.getReferencePosition()
, or null
if the object didn't implement either interface.public int getStepLimit()
WorldWind.RELATIVE_TO_GROUND
altitude mode. If the solver exceeds this value it will utilize an
intersection with the ellipsoid at the specified altitude.public void setAltitudeMode(int altitudeMode)
altitudeMode
- the altitude mode to use for dragging calculations.public void setConvergenceThreshold(double convergenceThreshold)
WorldWind.RELATIVE_TO_GROUND
altitude mode. The solver will test each iterations solution altitude with the desired altitude and if it is
found to be within the convergence threshold, the cartesian solution will be returned. Set this value in
coordination with the step limit.convergenceThreshold
- the convergence threshold to use for the solver.public void setStepLimit(int stepLimit)
WorldWind.RELATIVE_TO_GROUND
altitude mode. The step limit is the maximum steps the solver
will attempt before using an intersection with the ellipsoid at the specified altitude. Set this value in
coordination with the convergence threshold.stepLimit
- the step limit to set for the solver method.