org.jfree.ui

## Class RectangleInsets

- java.lang.Object
- - org.jfree.ui.RectangleInsets

All Implemented Interfaces:
  java.io.Serializable

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

Represents the insets for a rectangle, specified in absolute or relative terms. This class is immutable.

Author:
  David Gilbert
See Also:
  Serialized Form

### Field Summary

Fields
`static RectangleInsets` `ZERO_INSETS` A useful constant representing zero insets.

### Constructor Summary

Constructors
Constructor and Description
`RectangleInsets()` Creates a new instance with all insets initialised to `1.0`.
`RectangleInsets(double top, double left, double bottom, double right)` Creates a new instance with the specified insets (as 'absolute' units).
`RectangleInsets(UnitType unitType, double top, double left, double bottom, double right)` Creates a new instance.

### Method Summary

Methods
`double` `calculateBottomInset(double height)` Returns the bottom margin.
`double` `calculateBottomOutset(double height)` Returns the bottom margin.
`double` `calculateLeftInset(double width)` Returns the left margin.
`double` `calculateLeftOutset(double width)` Returns the left margin.
`double` `calculateRightInset(double width)` Returns the right margin.
`double` `calculateRightOutset(double width)` Returns the right margin.
`double` `calculateTopInset(double height)` Returns the top margin.
`double` `calculateTopOutset(double height)` Returns the top margin.
`java.awt.geom.Rectangle2D` `createAdjustedRectangle(java.awt.geom.Rectangle2D base, LengthAdjustmentType horizontal, LengthAdjustmentType vertical)` Creates an adjusted rectangle using the supplied rectangle, the insets specified by this instance, and the horizontal and vertical adjustment types.
`java.awt.geom.Rectangle2D` `createInsetRectangle(java.awt.geom.Rectangle2D base)` Creates an 'inset' rectangle.
`java.awt.geom.Rectangle2D` `createInsetRectangle(java.awt.geom.Rectangle2D base, boolean horizontal, boolean vertical)` Creates an 'inset' rectangle.
`java.awt.geom.Rectangle2D` `createOutsetRectangle(java.awt.geom.Rectangle2D base)` Creates an outset rectangle.
`java.awt.geom.Rectangle2D` `createOutsetRectangle(java.awt.geom.Rectangle2D base, boolean horizontal, boolean vertical)` Creates an outset rectangle.
`boolean` `equals(java.lang.Object obj)` Tests this instance for equality with an arbitrary object.
`double` `extendHeight(double height)` Extends the given height to allow for the insets.
`double` `extendWidth(double width)` Extends the given width to allow for the insets.
`double` `getBottom()` Returns the bottom insets.
`double` `getLeft()` Returns the left insets.
`double` `getRight()` Returns the right insets.
`double` `getTop()` Returns the top insets.
`UnitType` `getUnitType()` Returns the unit type (absolute or relative).
`int` `hashCode()` Returns a hash code for the object.
`java.lang.String` `toString()` Returns a textual representation of this instance, useful for debugging purposes.
`void` `trim(java.awt.geom.Rectangle2D area)` Shrinks the given rectangle by the amount of these insets.
`double` `trimHeight(double height)` Trims the given height to allow for the insets.
`double` `trimWidth(double width)` Trims the given width to allow for the insets.

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

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

### Field Detail

#### ZERO_INSETS

    public static final RectangleInsets ZERO_INSETS

A useful constant representing zero insets.

### Constructor Detail

#### RectangleInsets

    public RectangleInsets()

Creates a new instance with all insets initialised to `1.0`.

Since:
  1.0.9

#### RectangleInsets

    public RectangleInsets(double top,
                   double left,
                   double bottom,
                   double right)

Creates a new instance with the specified insets (as 'absolute' units).

Parameters:
  `top` - the top insets.
  `left` - the left insets.
  `bottom` - the bottom insets.
  `right` - the right insets.

#### RectangleInsets

    public RectangleInsets(UnitType unitType,
                   double top,
                   double left,
                   double bottom,
                   double right)

Creates a new instance.

Parameters:
  `unitType` - absolute or relative units (`null` not permitted).
  `top` - the top insets.
  `left` - the left insets.
  `bottom` - the bottom insets.
  `right` - the right insets.

### Method Detail

#### getUnitType

    public UnitType getUnitType()

Returns the unit type (absolute or relative). This specifies whether the insets are measured as Java2D units or percentages.

Returns:
  The unit type (never `null`).

#### getTop

    public double getTop()

Returns the top insets.

Returns:
  The top insets.

#### getBottom

    public double getBottom()

Returns the bottom insets.

Returns:
  The bottom insets.

#### getLeft

    public double getLeft()

Returns the left insets.

Returns:
  The left insets.

#### getRight

    public double getRight()

Returns the right insets.

Returns:
  The right insets.

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

#### hashCode

    public int hashCode()

Returns a hash code for the object.

Overrides:
  `hashCode` in class `java.lang.Object`
Returns:
  A hash code.

#### toString

    public java.lang.String toString()

Returns a textual representation of this instance, useful for debugging purposes.

Overrides:
  `toString` in class `java.lang.Object`
Returns:
  A string representing this instance.

#### createAdjustedRectangle

    public java.awt.geom.Rectangle2D createAdjustedRectangle(java.awt.geom.Rectangle2D base,
                                                    LengthAdjustmentType horizontal,
                                                    LengthAdjustmentType vertical)

Creates an adjusted rectangle using the supplied rectangle, the insets specified by this instance, and the horizontal and vertical adjustment types.

Parameters:
  `base` - the base rectangle (`null` not permitted).
  `horizontal` - the horizontal adjustment type (`null` not permitted).
  `vertical` - the vertical adjustment type (`null` not permitted).
Returns:
  The inset rectangle.

#### createInsetRectangle

    public java.awt.geom.Rectangle2D createInsetRectangle(java.awt.geom.Rectangle2D base)

Creates an 'inset' rectangle.

Parameters:
  `base` - the base rectangle (`null` not permitted).
Returns:
  The inset rectangle.

#### createInsetRectangle

    public java.awt.geom.Rectangle2D createInsetRectangle(java.awt.geom.Rectangle2D base,
                                                 boolean horizontal,
                                                 boolean vertical)

Creates an 'inset' rectangle.

Parameters:
  `base` - the base rectangle (`null` not permitted).
  `horizontal` - apply horizontal insets?
  `vertical` - apply vertical insets?
Returns:
  The inset rectangle.

#### createOutsetRectangle

    public java.awt.geom.Rectangle2D createOutsetRectangle(java.awt.geom.Rectangle2D base)

Creates an outset rectangle.

Parameters:
  `base` - the base rectangle (`null` not permitted).
Returns:
  An outset rectangle.

#### createOutsetRectangle

    public java.awt.geom.Rectangle2D createOutsetRectangle(java.awt.geom.Rectangle2D base,
                                                  boolean horizontal,
                                                  boolean vertical)

Creates an outset rectangle.

Parameters:
  `base` - the base rectangle (`null` not permitted).
  `horizontal` - apply horizontal insets?
  `vertical` - apply vertical insets?
Returns:
  An outset rectangle.

#### calculateTopInset

    public double calculateTopInset(double height)

Returns the top margin.

Parameters:
  `height` - the height of the base rectangle.
Returns:
  The top margin (in Java2D units).

#### calculateTopOutset

    public double calculateTopOutset(double height)

Returns the top margin.

Parameters:
  `height` - the height of the base rectangle.
Returns:
  The top margin (in Java2D units).

#### calculateBottomInset

    public double calculateBottomInset(double height)

Returns the bottom margin.

Parameters:
  `height` - the height of the base rectangle.
Returns:
  The bottom margin (in Java2D units).

#### calculateBottomOutset

    public double calculateBottomOutset(double height)

Returns the bottom margin.

Parameters:
  `height` - the height of the base rectangle.
Returns:
  The bottom margin (in Java2D units).

#### calculateLeftInset

    public double calculateLeftInset(double width)

Returns the left margin.

Parameters:
  `width` - the width of the base rectangle.
Returns:
  The left margin (in Java2D units).

#### calculateLeftOutset

    public double calculateLeftOutset(double width)

Returns the left margin.

Parameters:
  `width` - the width of the base rectangle.
Returns:
  The left margin (in Java2D units).

#### calculateRightInset

    public double calculateRightInset(double width)

Returns the right margin.

Parameters:
  `width` - the width of the base rectangle.
Returns:
  The right margin (in Java2D units).

#### calculateRightOutset

    public double calculateRightOutset(double width)

Returns the right margin.

Parameters:
  `width` - the width of the base rectangle.
Returns:
  The right margin (in Java2D units).

#### trimWidth

    public double trimWidth(double width)

Trims the given width to allow for the insets.

Parameters:
  `width` - the width.
Returns:
  The trimmed width.

#### extendWidth

    public double extendWidth(double width)

Extends the given width to allow for the insets.

Parameters:
  `width` - the width.
Returns:
  The extended width.

#### trimHeight

    public double trimHeight(double height)

Trims the given height to allow for the insets.

Parameters:
  `height` - the height.
Returns:
  The trimmed height.

#### extendHeight

    public double extendHeight(double height)

Extends the given height to allow for the insets.

Parameters:
  `height` - the height.
Returns:
  The extended height.

#### trim

    public void trim(java.awt.geom.Rectangle2D area)

Shrinks the given rectangle by the amount of these insets.

Parameters:
  `area` - the area (`null` not permitted).