Package gov.nasa.worldwind.geom
Class Offset
- java.lang.Object
-
- gov.nasa.worldwind.geom.Offset
-
public class Offset extends java.lang.Object
Specifies an offset relative to a rectangle. Used by renderable shapes.
-
-
Field Summary
Fields Modifier and Type Field Description double
x
The offset in the X dimension, interpreted according to this instance's xUnits argument.int
xUnits
The units of this instance's X offset.double
y
The offset in the Y dimension, interpreted according to this instance's yUnits argument.int
yUnits
The units of this instance's Y offset.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Offset
bottomCenter()
This factory method returns a new offset for anchoring a rectangle to its center of its bottom edge.static Offset
bottomLeft()
This factory method returns a new offset used for anchoring a rectangle to its bottom-left corner.static Offset
bottomRight()
This factory method returns a new offset for anchoring a rectangle to its bottom-right corner.static Offset
center()
This factory method returns a new offset used for anchoring a rectangle to its center.boolean
equals(java.lang.Object o)
int
hashCode()
Vec2
offsetForSize(double width, double height, Vec2 result)
Returns this offset's absolute X and Y coordinates in pixels for a rectangle of a specified size in pixels.Offset
set(Offset offset)
Sets this offset to identical property values of the specified offset.static Offset
topCenter()
This factory method returns a new offset for anchoring a rectangle to the center of its top edge.static Offset
topLeft()
This factory method returns a new offset for anchoring a rectangle its top-left corner.static Offset
topRight()
This factory method returns a new offset for anchoring a rectangle to its top-right corner.java.lang.String
toString()
-
-
-
Field Detail
-
x
public double x
The offset in the X dimension, interpreted according to this instance's xUnits argument.
-
y
public double y
The offset in the Y dimension, interpreted according to this instance's yUnits argument.
-
xUnits
public int xUnits
The units of this instance's X offset. See this class' constructor description for a list of the possible values.
-
yUnits
public int yUnits
The units of this instance's Y offset. See this class' constructor description for a list of the possible values.
-
-
Constructor Detail
-
Offset
public Offset(int xUnits, double x, int yUnits, double y)
Constructs an offset instance given specified units and offsets.- Parameters:
xUnits
- The type of units specified for the X dimension. May be one of the following:- [WorldWind.OFFSET_FRACTION]
WorldWind.OFFSET_FRACTION
- [WorldWind.OFFSET_INSET_PIXELS]
WorldWind.OFFSET_INSET_PIXELS
- [WorldWind.OFFSET_PIXELS]
WorldWind.OFFSET_PIXELS
- [WorldWind.OFFSET_FRACTION]
x
- The offset in the X dimension.yUnits
- The type of units specified for the Y dimension, assuming a lower-left Y origin. May be one of the following:- [WorldWind.OFFSET_FRACTION]
WorldWind.OFFSET_FRACTION
- [WorldWind.OFFSET_INSET_PIXELS]
WorldWind.OFFSET_INSET_PIXELS
- [WorldWind.OFFSET_PIXELS]
WorldWind.OFFSET_PIXELS
- [WorldWind.OFFSET_FRACTION]
y
- The offset in the Y dimension.
-
Offset
public Offset(Offset offset)
Creates a new offset of this offset with identical property values.
-
-
Method Detail
-
center
public static Offset center()
This factory method returns a new offset used for anchoring a rectangle to its center.- Returns:
- Offset(WorldWind.OFFSET_FRACTION, 0.5, WorldWind.OFFSET_FRACTION, 0.5)
-
bottomLeft
public static Offset bottomLeft()
This factory method returns a new offset used for anchoring a rectangle to its bottom-left corner.- Returns:
- Offset(WorldWind.OFFSET_FRACTION, 0.0, WorldWind.OFFSET_FRACTION, 0.0)
-
bottomCenter
public static Offset bottomCenter()
This factory method returns a new offset for anchoring a rectangle to its center of its bottom edge.- Returns:
- Offset(WorldWind.OFFSET_FRACTION, 0.5, WorldWind.OFFSET_FRACTION, 0.0)
-
bottomRight
public static Offset bottomRight()
This factory method returns a new offset for anchoring a rectangle to its bottom-right corner.- Returns:
- Offset(WorldWind.OFFSET_FRACTION, 1.0, WorldWind.OFFSET_FRACTION, 0.0)
-
topLeft
public static Offset topLeft()
This factory method returns a new offset for anchoring a rectangle its top-left corner.- Returns:
- Offset(WorldWind.OFFSET_FRACTION, 0.0, WorldWind.OFFSET_FRACTION, 1.0)
-
topCenter
public static Offset topCenter()
This factory method returns a new offset for anchoring a rectangle to the center of its top edge.- Returns:
- Offset(WorldWind.OFFSET_FRACTION, 0.5, WorldWind.OFFSET_FRACTION, 1.0)
-
topRight
public static Offset topRight()
This factory method returns a new offset for anchoring a rectangle to its top-right corner.- Returns:
- Offset(WorldWind.OFFSET_FRACTION, 1.0, WorldWind.OFFSET_FRACTION, 1.0)
-
set
public Offset set(Offset offset)
Sets this offset to identical property values of the specified offset.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
offsetForSize
public Vec2 offsetForSize(double width, double height, Vec2 result)
Returns this offset's absolute X and Y coordinates in pixels for a rectangle of a specified size in pixels. The returned offset is in pixels relative to the rectangle's origin, and is defined in the coordinate system used by the caller.- Parameters:
width
- the rectangle's width in pixelsheight
- the rectangles height in pixelsresult
- a pre-allocated Vec2 in which to return the computed offset relative to the rectangle's origin- Returns:
- the result argument set to the computed offset
-
-