Module org.jfree.chart3d
Package org.jfree.chart3d.graphics2d

# Class Fit2D

java.lang.Object
org.jfree.chart3d.graphics2d.Fit2D

All Implemented Interfaces:
  `Serializable`

public class Fit2D extends Object implements 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
Description
`static final Fit2D`
`BOTTOM_CENTER_NO_SCALING`
Fits a source rectangle to the bottom center of a target rectangle, without resizing it.
`static final Fit2D`
`BOTTOM_LEFT_NO_SCALING`
Fits a source rectangle to the bottom left of a target rectangle, without resizing it.
`static final Fit2D`
`BOTTOM_RIGHT_NO_SCALING`
Fits a source rectangle to the bottom right of a target rectangle, without resizing it.
`static final Fit2D`
`CENTER_LEFT_NO_SCALING`
Fits a source rectangle to the center left of a target rectangle, without resizing it.
`static final Fit2D`
`CENTER_NO_SCALING`
Aligns a source rectangle to the center of a target rectangle, without resizing it.
`static final Fit2D`
`CENTER_RIGHT_NO_SCALING`
Fits a source rectangle to the center right of a target rectangle, without resizing it.
`static final Fit2D`
`SCALE_TO_FIT_TARGET`
Scale the source rectangle to fit the target rectangle.
`static final Fit2D`
`TOP_CENTER_NO_SCALING`
Fits a source rectangle to the top center of a target rectangle, without resizing it.
`static final Fit2D`
`TOP_LEFT_NO_SCALING`
Fits a source rectangle to the top left of a target rectangle, without resizing it.
`static final Fit2D`
`TOP_RIGHT_NO_SCALING`
Fits a source rectangle to the top right of a target rectangle, without resizing it.

## Constructor Summary

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

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object obj)`
Tests this instance for equality with an arbitrary object.
`Rectangle2D`
`fit(Dimension2D srcDim, 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 Details

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

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

### 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 Rectangle2D fit(Dimension2D srcDim, 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(Object obj)
Tests this instance for equality with an arbitrary object.

Overrides:
  `equals` in class `Object`
Parameters:
  `obj` - the object (`null` permitted).
Returns:
  A boolean.