public class TacticalGraphicUtil extends Object
| Constructor and Description |
|---|
TacticalGraphicUtil() |
| Modifier and Type | Method and Description |
|---|---|
static List<Position> |
asPositionList(Globe globe,
Vec4... points)
Convert a list of cartesian points to Positions.
|
static Vec4 |
bezierCurve(Vec4[] controlPoints,
double t,
int[] coefficients)
Compute a point along a Bezier curve defined by a list of control points.
|
protected static void |
binomial(int n,
int[] coefficients)
Compute binomial coefficients for a polynomial of order n.
|
static Object[] |
getAltitudeRange(TacticalGraphic graphic)
Get the altitude range from the graphic's modifiers.
|
static Object[] |
getDateRange(TacticalGraphic graphic)
Get the date range from a graphic's modifiers.
|
static void |
placeLabelsOnPath(DrawContext dc,
Iterable<? extends Position> positions,
TacticalGraphicLabel label1,
TacticalGraphicLabel label2,
double distance)
Position one or two labels some distance along the path.
|
public static List<Position> asPositionList(Globe globe, Vec4... points)
globe - Globe used to convert points to positions.points - Points to convert.public static Vec4 bezierCurve(Vec4[] controlPoints, double t, int[] coefficients)
Vec4[] controlPoints = ... // Determine control points appropriate for your curve ListcurvePositions = new ArrayList (); int[] coefficients = new int[controlPoints.length]; int intervals = 32; double delta = 1.0 / intervals; for (int i = 0; i < intervals; i++) { double t = i * delta; Vec4 pt = TacticalGraphicUtil.bezierCurve(controlPoints, t, coefficients); Position pos = globe.computePositionFromPoint(p); curvePositions.add(pos); }
controlPoints - Control points for the curve.t - Interpolation parameter in the range [0..1].coefficients - Array to store binomial coefficients between invocations of this function. On the first
invocation, pass an int[] with length equal to the controlPoints array. bezierCurve will
populate the array on the first invocation, and reuse the computed values on subsequent
invocations.protected static void binomial(int n,
int[] coefficients)
n - Order of polynomial for which to calculate coefficients.coefficients - Array to receive coefficients. The length of this array must be n + 1.public static Object[] getAltitudeRange(TacticalGraphic graphic)
AVKey.ALTITUDE modifier, and returns the results as a two element array. If the value of the
modifier is an Iterable, then this method returns the first two values of the iteration. If the
value of the modifier is a single object, this method returns an array containing that object and
null.graphic - Graphic from which to retrieve dates.public static Object[] getDateRange(TacticalGraphic graphic)
AVKey.DATE_TIME
modifier, and returns the results as a two element array. If the value of the modifier is an
Iterable, then this method returns the first two values of the iteration. If the value of the
modifier is a single object, this method returns an array containing that object and null.graphic - Graphic from which to retrieve dates.public static void placeLabelsOnPath(DrawContext dc, Iterable<? extends Position> positions, TacticalGraphicLabel label1, TacticalGraphicLabel label2, double distance)
dc - Current draw context.positions - Positions that describe the path.label1 - First label to position.label2 - Second label to position. (May be null.)distance - Distance along the path at which to position the labels.