Class 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.
    • Constructor Summary

      Constructors 
      Constructor Description
      Offset​(int xUnits, double x, int yUnits, double y)
      Constructs an offset instance given specified units and offsets.
      Offset​(Offset offset)
      Creates a new offset of this offset with identical property values.
    • 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()  
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • 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​(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 class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        @NonNull
        public java.lang.String toString()
        Overrides:
        toString in class java.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 pixels
        height - the rectangles height in pixels
        result - 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