Package gov.nasa.worldwind.geom
Class Offset
- java.lang.Object
-
- gov.nasa.worldwind.geom.Offset
-
public class Offset extends java.lang.ObjectSpecifies an offset relative to a rectangle. Used by renderable shapes.
-
-
Field Summary
Fields Modifier and Type Field Description doublexThe offset in the X dimension, interpreted according to this instance's xUnits argument.intxUnitsThe units of this instance's X offset.doubleyThe offset in the Y dimension, interpreted according to this instance's yUnits argument.intyUnitsThe units of this instance's Y offset.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OffsetbottomCenter()This factory method returns a new offset for anchoring a rectangle to its center of its bottom edge.static OffsetbottomLeft()This factory method returns a new offset used for anchoring a rectangle to its bottom-left corner.static OffsetbottomRight()This factory method returns a new offset for anchoring a rectangle to its bottom-right corner.static Offsetcenter()This factory method returns a new offset used for anchoring a rectangle to its center.booleanequals(java.lang.Object o)inthashCode()Vec2offsetForSize(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.Offsetset(Offset offset)Sets this offset to identical property values of the specified offset.static OffsettopCenter()This factory method returns a new offset for anchoring a rectangle to the center of its top edge.static OffsettopLeft()This factory method returns a new offset for anchoring a rectangle its top-left corner.static OffsettopRight()This factory method returns a new offset for anchoring a rectangle to its top-right corner.java.lang.StringtoString()
-
-
-
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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toStringin 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
-
-