public class Spacer
extends java.lang.Object
implements java.io.Serializable
Instances of this class are immutable.
Modifier and Type | Field and Description |
---|---|
static int |
ABSOLUTE
A constant for 'absolute' spacing.
|
static int |
RELATIVE
A constant for 'relative' spacing.
|
Constructor and Description |
---|
Spacer(int type,
double left,
double top,
double right,
double bottom)
Creates a new Spacer object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Tests this object for equality with another object.
|
double |
getAdjustedHeight(double height)
Returns the height after adding the top and bottom spacing amounts.
|
double |
getAdjustedWidth(double width)
Returns the width after adding the left and right spacing amounts.
|
double |
getBottomSpace(double height)
Returns the amount of space for the bottom of a rectangular area.
|
double |
getLeftSpace(double width)
Returns the amount of space for the left hand side of a rectangular area.
|
double |
getRightSpace(double width)
Returns the amount of space for the right hand side of a rectangular area.
|
double |
getTopSpace(double height)
Returns the amount of space for the top of a rectangular area.
|
void |
trim(java.awt.geom.Rectangle2D area)
Calculates the margins and trims them from the supplied area.
|
double |
trimWidth(double w)
Reduces the specified width according to the left and right space settings.
|
public static final int RELATIVE
public static final int ABSOLUTE
public Spacer(int type, double left, double top, double right, double bottom)
The space can be specified in relative or absolute terms (using the constants
RELATIVE
and ABSOLUTE
for the type
argument.
For relative spacing, the margins are specified as percentages (of the overall height
or width). For absolute spacing, the margins are specified in points (1/72 inch).
type
- the type of spacing (relative or absolute).left
- the left margin.top
- the top margin.right
- the right margin.bottom
- the bottom margin.public double getLeftSpace(double width)
The width argument is only used for calculating 'relative' spacing.
width
- the overall width of the rectangular area.public double getRightSpace(double width)
The width argument is only used for calculating 'relative' spacing.
width
- the overall width of the rectangular area.public double getTopSpace(double height)
The height argument is only used for calculating 'relative' spacing.
height
- the overall height of the rectangular area.public double getBottomSpace(double height)
The height argument is only used for calculating 'relative' spacing.
height
- the overall height of the rectangular area.public double getAdjustedWidth(double width)
width
- the original width.public double getAdjustedHeight(double height)
height
- the original height.public void trim(java.awt.geom.Rectangle2D area)
area
- the area to be trimmed.public double trimWidth(double w)
w
- the width.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the other object.true
or false
.