com.orsoncharts.util

## Class Fit2D

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

- All Implemented Interfaces:
    java.io.Serializable

      public class Fit2D
      extends java.lang.Object
      implements java.io.Serializable

  A specification for the alignment and fitting of one rectangle (the source rectangle) with reference to another (the target rectangle). Instances of this class are immutable.
  One application for this is to specify how the background image for a chart should be aligned and scaled.
  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 Fit2D` | `BOTTOM_CENTER_NO_SCALING` Fits a source rectangle to the bottom center of a target rectangle, without resizing it.
    `static Fit2D` | `BOTTOM_LEFT_NO_SCALING` Fits a source rectangle to the bottom left of a target rectangle, without resizing it.
    `static Fit2D` | `BOTTOM_RIGHT_NO_SCALING` Fits a source rectangle to the bottom right of a target rectangle, without resizing it.
    `static Fit2D` | `CENTER_LEFT_NO_SCALING` Fits a source rectangle to the center left of a target rectangle, without resizing it.
    `static Fit2D` | `CENTER_NO_SCALING` Aligns a source rectangle to the center of a target rectangle, without resizing it.
    `static Fit2D` | `CENTER_RIGHT_NO_SCALING` Fits a source rectangle to the center right of a target rectangle, without resizing it.
    `static Fit2D` | `SCALE_TO_FIT_TARGET` Scale the source rectangle to fit the target rectangle.
    `static Fit2D` | `TOP_CENTER_NO_SCALING` Fits a source rectangle to the top center of a target rectangle, without resizing it.
    `static Fit2D` | `TOP_LEFT_NO_SCALING` Fits a source rectangle to the top left of a target rectangle, without resizing it.
    `static Fit2D` | `TOP_RIGHT_NO_SCALING` Fits a source rectangle to the top right of a target rectangle, without resizing it.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Fit2D(Anchor2D anchor, Scale2D scale)` Creates a new instance.

  - ### Method Summary

    All Methods Static 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.Rectangle2D` | `fit(java.awt.geom.Dimension2D srcDim, java.awt.geom.Rectangle2D target)` Fits a rectangle of the specified dimension to the target rectangle, aligning and scaling according to the attributes of this instance.
    `Anchor2D` | `getAnchor()` Returns the anchor.
    `static Fit2D` | `getNoScalingFitter(RefPt2D refPt)` Returns a fitter for the specified reference point.
    `Scale2D` | `getScale()` Returns the scaling.

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

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

- - ### Field Detail

    - #### CENTER_NO_SCALING

          public static final Fit2D CENTER_NO_SCALING

      Aligns a source rectangle to the center of a target rectangle, without resizing it.
      Since:
        1.1

    - #### TOP_LEFT_NO_SCALING

          public static final Fit2D TOP_LEFT_NO_SCALING

      Fits a source rectangle to the top left of a target rectangle, without resizing it.
      Since:
        1.1

    - #### TOP_CENTER_NO_SCALING

          public static final Fit2D TOP_CENTER_NO_SCALING

      Fits a source rectangle to the top center of a target rectangle, without resizing it.
      Since:
        1.1

    - #### TOP_RIGHT_NO_SCALING

          public static final Fit2D TOP_RIGHT_NO_SCALING

      Fits a source rectangle to the top right of a target rectangle, without resizing it.
      Since:
        1.1

    - #### CENTER_LEFT_NO_SCALING

          public static final Fit2D CENTER_LEFT_NO_SCALING

      Fits a source rectangle to the center left of a target rectangle, without resizing it.
      Since:
        1.1

    - #### CENTER_RIGHT_NO_SCALING

          public static final Fit2D CENTER_RIGHT_NO_SCALING

      Fits a source rectangle to the center right of a target rectangle, without resizing it.
      Since:
        1.1

    - #### BOTTOM_LEFT_NO_SCALING

          public static final Fit2D BOTTOM_LEFT_NO_SCALING

      Fits a source rectangle to the bottom left of a target rectangle, without resizing it.
      Since:
        1.1

    - #### BOTTOM_CENTER_NO_SCALING

          public static final Fit2D BOTTOM_CENTER_NO_SCALING

      Fits a source rectangle to the bottom center of a target rectangle, without resizing it.
      Since:
        1.1

    - #### BOTTOM_RIGHT_NO_SCALING

          public static final Fit2D BOTTOM_RIGHT_NO_SCALING

      Fits a source rectangle to the bottom right of a target rectangle, without resizing it.
      Since:
        1.1

    - #### SCALE_TO_FIT_TARGET

          public static final Fit2D SCALE_TO_FIT_TARGET

      Scale the source rectangle to fit the target rectangle.
      Since:
        1.1

  - ### Constructor Detail

    - #### Fit2D

          public Fit2D(Anchor2D anchor,
                       Scale2D scale)

      Creates a new instance.
      Parameters:
        `anchor` - the anchor point (`null` not permitted).
        `scale` - the scaling (`null` not permitted).

  - ### Method Detail

    - #### getNoScalingFitter

          public static Fit2D getNoScalingFitter(RefPt2D refPt)

      Returns a fitter for the specified reference point.
      Parameters:
        `refPt` - the reference point (`null` not permitted).
      Returns:
        A fitter.
      Since:
        1.1

    - #### getAnchor

          public Anchor2D getAnchor()

      Returns the anchor.
      Returns:
        The anchor (never `null`).
      Since:
        1.1

    - #### getScale

          public Scale2D getScale()

      Returns the scaling.
      Returns:
        The scaling (never `null`).
      Since:
        1.1

    - #### fit

          public java.awt.geom.Rectangle2D fit(java.awt.geom.Dimension2D srcDim,
                                               java.awt.geom.Rectangle2D target)

      Fits a rectangle of the specified dimension to the target rectangle, aligning and scaling according to the attributes of this instance.
      Parameters:
        `srcDim` - the dimensions of the source rectangle (`null` not permitted).
        `target` - the target rectangle (`null` not permitted).
      Returns:
        The bounds of the fitted rectangle (never `null`).

    - #### 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` permitted).
      Returns:
        A boolean.