com.orsoncharts.util

## Class Anchor2D

- java.lang.Object
- - com.orsoncharts.util.Anchor2D

- All Implemented Interfaces:
    java.io.Serializable

      public final class Anchor2D
      extends java.lang.Object
      implements java.io.Serializable

  Represents an anchor point for a chart title and/or legend. The anchor point is defined relative to a reference rectangle, the dimensions of which are not known in advance (typically the reference rectangle is the bounding rectangle of a chart that is being drawn). Some predefined anchor points are provided in the `TitleAnchor` and `LegendAnchor` classes.
  Instances of this class are immutable.
  NOTE: This class is serializable, but the serialization format is subject to change in future releases and should not be relied upon for persisting instances of this class.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Anchor2D` | `BOTTOM_CENTER` An anchor point at the bottom center with zero offset from the target rectangle bounds.
    `static Anchor2D` | `BOTTOM_LEFT` An anchor point at the bottom left with zero offset from the target rectangle bounds.
    `static Anchor2D` | `BOTTOM_RIGHT` An anchor point at the bottom right with zero offset from the target rectangle bounds.
    `static Anchor2D` | `CENTER` An anchor point at the center of the target rectangle.
    `static Anchor2D` | `CENTER_LEFT` An anchor point at the center left with zero offset from the target rectangle bounds.
    `static Anchor2D` | `CENTER_RIGHT` An anchor point at the center right with zero offset from the target rectangle bounds.
    `static Anchor2D` | `TOP_CENTER` An anchor point at the top center with zero offset from the target rectangle bounds.
    `static Anchor2D` | `TOP_LEFT` An anchor point at the top left with zero offset from the target rectangle bounds.
    `static Anchor2D` | `TOP_RIGHT` An anchor point at the top right with zero offset from the target rectangle bounds.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Anchor2D()` Creates a default instance.
    `Anchor2D(RefPt2D refPt)` Creates a new `Anchor2D` instance with the specified reference point and offsets of `(4.0, 4.0)`.
    `Anchor2D(RefPt2D refPt, Offset2D offset)` Creates a new anchor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object obj)` Tests this instance for equality with an arbitrary object.
    `java.awt.geom.Point2D` | `getAnchorPoint(java.awt.geom.Rectangle2D rect)` Returns the anchor point for the given rectangle.
    `Offset2D` | `getOffset()` Returns the offsets.
    `RefPt2D` | `getRefPt()` Returns the reference point.
    `java.awt.geom.Point2D` | `resolveAnchorWithPercentOffset(double startX, double startY, double endX, double endY)` Resolves the anchor to a specific point relative to a rectangle defined by the points (startX, startY) and (endX, endY).

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TOP_LEFT

          public static final Anchor2D TOP_LEFT

      An anchor point at the top left with zero offset from the target rectangle bounds.
      Since:
        1.1

    - #### TOP_CENTER

          public static final Anchor2D TOP_CENTER

      An anchor point at the top center with zero offset from the target rectangle bounds.
      Since:
        1.1

    - #### TOP_RIGHT

          public static final Anchor2D TOP_RIGHT

      An anchor point at the top right with zero offset from the target rectangle bounds.
      Since:
        1.1

    - #### CENTER_LEFT

          public static final Anchor2D CENTER_LEFT

      An anchor point at the center left with zero offset from the target rectangle bounds.
      Since:
        1.1

    - #### CENTER

          public static final Anchor2D CENTER

      An anchor point at the center of the target rectangle.
      Since:
        1.1

    - #### CENTER_RIGHT

          public static final Anchor2D CENTER_RIGHT

      An anchor point at the center right with zero offset from the target rectangle bounds.
      Since:
        1.1

    - #### BOTTOM_LEFT

          public static final Anchor2D BOTTOM_LEFT

      An anchor point at the bottom left with zero offset from the target rectangle bounds.
      Since:
        1.1

    - #### BOTTOM_CENTER

          public static final Anchor2D BOTTOM_CENTER

      An anchor point at the bottom center with zero offset from the target rectangle bounds.
      Since:
        1.1

    - #### BOTTOM_RIGHT

          public static final Anchor2D BOTTOM_RIGHT

      An anchor point at the bottom right with zero offset from the target rectangle bounds.
      Since:
        1.1

  - ### Constructor Detail

    - #### Anchor2D

          public Anchor2D()

      Creates a default instance.

    - #### Anchor2D

          public Anchor2D(RefPt2D refPt)

      Creates a new `Anchor2D` instance with the specified reference point and offsets of `(4.0, 4.0)`.
      Parameters:
        `refPt` - the reference point (`null` not permitted).

    - #### Anchor2D

          public Anchor2D(RefPt2D refPt,
                          Offset2D offset)

      Creates a new anchor.
      Parameters:
        `refPt` - the reference point (`null` not permitted).
        `offset` - the offset (`null` not permitted).

  - ### Method Detail

    - #### getRefPt

          public RefPt2D getRefPt()

      Returns the reference point.
      Returns:
        The reference point (never `null`).

    - #### getOffset

          public Offset2D getOffset()

      Returns the offsets.
      Returns:
        The offsets (never `null`).

    - #### getAnchorPoint

          public java.awt.geom.Point2D getAnchorPoint(java.awt.geom.Rectangle2D rect)

      Returns the anchor point for the given rectangle.
      Parameters:
        `rect` - the reference rectangle (`null` not permitted).
      Returns:
        The anchor point.

    - #### resolveAnchorWithPercentOffset

          public java.awt.geom.Point2D resolveAnchorWithPercentOffset(double startX,
                                                                      double startY,
                                                                      double endX,
                                                                      double endY)

      Resolves the anchor to a specific point relative to a rectangle defined by the points (startX, startY) and (endX, endY).
      Parameters:
        `startX` - the x-coordinate for the bottom left corner of the target rect.
        `startY` - the y-coordinate for the bottom left corner of the target rect.
        `endX` - the x-coordinate for the top right corner of the target rect.
        `endY` - the y-coordinate for the top right corner of the target rect.
      Returns:
        The resolved point.
      Since:
        1.2

    - #### equals

          public boolean equals(java.lang.Object obj)

      Tests this instance for equality with an arbitrary object.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `obj` - the object (`null` not permitted).
      Returns:
        A boolean.