Package org.jfree.chart.ui
Class RectangleInsets
java.lang.Object
org.jfree.chart.ui.RectangleInsets
- All Implemented Interfaces:
Serializable
Represents the insets for a rectangle, specified in absolute or relative
terms. This class is immutable.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RectangleInsetsA useful constant representing zero insets. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with all insets initialised to1.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
Modifier and TypeMethodDescriptiondoublecalculateBottomInset(double height) Returns the bottom margin.doublecalculateBottomOutset(double height) Returns the bottom margin.doublecalculateLeftInset(double width) Returns the left margin.doublecalculateLeftOutset(double width) Returns the left margin.doublecalculateRightInset(double width) Returns the right margin.doublecalculateRightOutset(double width) Returns the right margin.doublecalculateTopInset(double height) Returns the top margin.doublecalculateTopOutset(double height) Returns the top margin.createAdjustedRectangle(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.Creates an 'inset' rectangle.createInsetRectangle(Rectangle2D base, boolean horizontal, boolean vertical) Creates an 'inset' rectangle.Creates an outset rectangle.createOutsetRectangle(Rectangle2D base, boolean horizontal, boolean vertical) Creates an outset rectangle.booleanTests this instance for equality with an arbitrary object.doubleextendHeight(double height) Extends the given height to allow for the insets.doubleextendWidth(double width) Extends the given width to allow for the insets.doubleReturns the bottom insets.doublegetLeft()Returns the left insets.doublegetRight()Returns the right insets.doublegetTop()Returns the top insets.Returns the unit type (absolute or relative).inthashCode()Returns a hash code for the object.toString()Returns a textual representation of this instance, useful for debugging purposes.voidtrim(Rectangle2D area) Shrinks the given rectangle by the amount of these insets.doubletrimHeight(double height) Trims the given height to allow for the insets.doubletrimWidth(double width) Trims the given width to allow for the insets.
-
Field Details
-
ZERO_INSETS
A useful constant representing zero insets.
-
-
Constructor Details
-
RectangleInsets
public RectangleInsets()Creates a new instance with all insets initialised to1.0. -
RectangleInsets
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
Creates a new instance.- Parameters:
unitType- absolute or relative units (nullnot permitted).top- the top insets.left- the left insets.bottom- the bottom insets.right- the right insets.
-
-
Method Details
-
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
Returns the top insets.- Returns:
- The top insets.
-
getBottom
Returns the bottom insets.- Returns:
- The bottom insets.
-
getLeft
Returns the left insets.- Returns:
- The left insets.
-
getRight
Returns the right insets.- Returns:
- The right insets.
-
equals
Tests this instance for equality with an arbitrary object. -
hashCode
Returns a hash code for the object. -
toString
Returns a textual representation of this instance, useful for debugging purposes. -
createAdjustedRectangle
public Rectangle2D createAdjustedRectangle(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 (nullnot permitted).horizontal- the horizontal adjustment type (nullnot permitted).vertical- the vertical adjustment type (nullnot permitted).- Returns:
- The inset rectangle.
-
createInsetRectangle
Creates an 'inset' rectangle.- Parameters:
base- the base rectangle (nullnot permitted).- Returns:
- The inset rectangle.
-
createInsetRectangle
Creates an 'inset' rectangle.- Parameters:
base- the base rectangle (nullnot permitted).horizontal- apply horizontal insets?vertical- apply vertical insets?- Returns:
- The inset rectangle.
-
createOutsetRectangle
Creates an outset rectangle.- Parameters:
base- the base rectangle (nullnot permitted).- Returns:
- An outset rectangle.
-
createOutsetRectangle
Creates an outset rectangle.- Parameters:
base- the base rectangle (nullnot permitted).horizontal- apply horizontal insets?vertical- apply vertical insets?- Returns:
- An outset rectangle.
-
calculateTopInset
Returns the top margin.- Parameters:
height- the height of the base rectangle.- Returns:
- The top margin (in Java2D units).
-
calculateTopOutset
Returns the top margin.- Parameters:
height- the height of the base rectangle.- Returns:
- The top margin (in Java2D units).
-
calculateBottomInset
Returns the bottom margin.- Parameters:
height- the height of the base rectangle.- Returns:
- The bottom margin (in Java2D units).
-
calculateBottomOutset
Returns the bottom margin.- Parameters:
height- the height of the base rectangle.- Returns:
- The bottom margin (in Java2D units).
-
calculateLeftInset
Returns the left margin.- Parameters:
width- the width of the base rectangle.- Returns:
- The left margin (in Java2D units).
-
calculateLeftOutset
Returns the left margin.- Parameters:
width- the width of the base rectangle.- Returns:
- The left margin (in Java2D units).
-
calculateRightInset
Returns the right margin.- Parameters:
width- the width of the base rectangle.- Returns:
- The right margin (in Java2D units).
-
calculateRightOutset
Returns the right margin.- Parameters:
width- the width of the base rectangle.- Returns:
- The right margin (in Java2D units).
-
trimWidth
Trims the given width to allow for the insets.- Parameters:
width- the width.- Returns:
- The trimmed width.
-
extendWidth
Extends the given width to allow for the insets.- Parameters:
width- the width.- Returns:
- The extended width.
-
trimHeight
Trims the given height to allow for the insets.- Parameters:
height- the height.- Returns:
- The trimmed height.
-
extendHeight
Extends the given height to allow for the insets.- Parameters:
height- the height.- Returns:
- The extended height.
-
trim
Shrinks the given rectangle by the amount of these insets.- Parameters:
area- the area (nullnot permitted).
-