Class Anchor2D

java.lang.Object
org.jfree.chart3d.graphics2d.Anchor2D
All Implemented Interfaces:
Serializable

public final class Anchor2D extends Object implements 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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Anchor2D
    An anchor point at the bottom center with zero offset from the target rectangle bounds.
    static final Anchor2D
    An anchor point at the bottom left with zero offset from the target rectangle bounds.
    static final Anchor2D
    An anchor point at the bottom right with zero offset from the target rectangle bounds.
    static final Anchor2D
    An anchor point at the center of the target rectangle.
    static final Anchor2D
    An anchor point at the center left with zero offset from the target rectangle bounds.
    static final Anchor2D
    An anchor point at the center right with zero offset from the target rectangle bounds.
    static final Anchor2D
    An anchor point at the top center with zero offset from the target rectangle bounds.
    static final Anchor2D
    An anchor point at the top left with zero offset from the target rectangle bounds.
    static final Anchor2D
    An anchor point at the top right with zero offset from the target rectangle bounds.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a default instance.
    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

    Modifier and Type
    Method
    Description
    boolean
    Tests this instance for equality with an arbitrary object.
    Returns the anchor point for the given rectangle.
    Returns the offsets.
    Returns the reference point.
    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 Details

    • 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 Details

    • 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 Details

    • 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

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

      public 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(Object obj)
      Tests this instance for equality with an arbitrary object.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object (null not permitted).
      Returns:
      A boolean.