org.jfree.ui
Class Spacer

java.lang.Object
  extended by org.jfree.ui.Spacer
All Implemented Interfaces:
java.io.Serializable

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

Represents an amount of blank space inside (or sometimes outside) a rectangle. This class is similar in function to the Insets class, but allows for the space to be specified in relative terms as well as absolute terms. Instances of this class are immutable.

In general, using RectangleInsets is preferred to this class.

See Also:
Serialized Form

Field Summary
static int ABSOLUTE
          A constant for 'absolute' spacing.
static Spacer NO_SPACE
          A spacer that adds no space around a rectangle.
static int RELATIVE
          A constant for 'relative' spacing.
 
Constructor Summary
Spacer(int type, double left, double top, double right, double bottom)
          Creates a new Spacer object.
 
Method Summary
 double calculateExtendedHeight(double height)
          Calculates the extended height after adding the top and bottom spacing amounts.
 double calculateExtendedWidth(double width)
          Returns the width after adding the left and right spacing amounts.
 boolean equals(java.lang.Object obj)
          Tests this object for equality with another object.
 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.
 int hashCode()
          Returns a hashcode for this instance.
 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RELATIVE

public static final int RELATIVE
A constant for 'relative' spacing.

See Also:
Constant Field Values

ABSOLUTE

public static final int ABSOLUTE
A constant for 'absolute' spacing.

See Also:
Constant Field Values

NO_SPACE

public static final Spacer NO_SPACE
A spacer that adds no space around a rectangle.

Constructor Detail

Spacer

public Spacer(int type,
              double left,
              double top,
              double right,
              double bottom)
Creates a new Spacer object.

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

Parameters:
type - the type of spacing (relative or absolute).
left - the left margin.
top - the top margin.
right - the right margin.
bottom - the bottom margin.
Method Detail

getLeftSpace

public double getLeftSpace(double width)
Returns the amount of space for the left hand side of a rectangular area. The width argument is only used for calculating 'relative' spacing.

Parameters:
width - the overall width of the rectangular area.
Returns:
The space (in points).

getRightSpace

public double getRightSpace(double width)
Returns the amount of space for the right hand side of a rectangular area. The width argument is only used for calculating 'relative' spacing.

Parameters:
width - the overall width of the rectangular area.
Returns:
The space (in points).

getTopSpace

public double getTopSpace(double height)
Returns the amount of space for the top of a rectangular area. The height argument is only used for calculating 'relative' spacing.

Parameters:
height - the overall height of the rectangular area.
Returns:
The space (in points).

getBottomSpace

public double getBottomSpace(double height)
Returns the amount of space for the bottom of a rectangular area. The height argument is only used for calculating 'relative' spacing.

Parameters:
height - the overall height of the rectangular area.
Returns:
The space (in points).

calculateExtendedWidth

public double calculateExtendedWidth(double width)
Returns the width after adding the left and right spacing amounts.

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

calculateExtendedHeight

public double calculateExtendedHeight(double height)
Calculates the extended height after adding the top and bottom spacing amounts.

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

trim

public void trim(java.awt.geom.Rectangle2D area)
Calculates the margins and trims them from the supplied area.

Parameters:
area - the area to be trimmed (null not permitted).

trimWidth

public double trimWidth(double w)
Reduces the specified width according to the left and right space settings.

Parameters:
w - the width.
Returns:
The reduced width.

equals

public boolean equals(java.lang.Object obj)
Tests this object for equality with another object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the other object (null permitted).
Returns:
true or false.

hashCode

public int hashCode()
Returns a hashcode for this instance.

Overrides:
hashCode in class java.lang.Object
Returns:
A hashcode.