org.jfree.chart
Class Spacer

java.lang.Object
  |
  +--org.jfree.chart.Spacer
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Spacer
extends java.lang.Object
implements java.lang.Cloneable, 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.

Immutable.

Author:
David Gilbert
See Also:
Serialized Form

Field Summary
static int ABSOLUTE
          A constant for 'absolute' spacing.
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
 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, 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
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).

getAdjustedWidth

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

Parameters:
width - the original width.
Returns:
the adjusted width.

getAdjustedHeight

public double getAdjustedHeight(double height)
Returns the height after adding the top and bottom spacing amounts.

Parameters:
height - the original height.
Returns:
the adjusted 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.

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.
Returns:
true or false.