Package org.jfree.chart.block
Class RectangleConstraint
- java.lang.Object
-
- org.jfree.chart.block.RectangleConstraint
-
public class RectangleConstraint extends java.lang.Object
A description of a constraint for resizing a rectangle. Constraints are immutable.
-
-
Field Summary
Fields Modifier and Type Field Description private double
height
The fixed or maximum height.private LengthConstraintType
heightConstraintType
The constraint type.private Range
heightRange
static RectangleConstraint
NONE
An instance representing no constraint.private double
width
The width.private LengthConstraintType
widthConstraintType
The width constraint type.private Range
widthRange
The width range.
-
Constructor Summary
Constructors Constructor Description RectangleConstraint(double w, double h)
Creates a new "fixed width and height" instance.RectangleConstraint(double w, Range h)
Creates a new constraint with a fixed width and a range for the height.RectangleConstraint(double w, Range widthRange, LengthConstraintType widthConstraintType, double h, Range heightRange, LengthConstraintType heightConstraintType)
Creates a new constraint.RectangleConstraint(Range w, double h)
Creates a new constraint with a range for the width and a fixed height.RectangleConstraint(Range w, Range h)
Creates a new "range width and height" instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Size2D
calculateConstrainedSize(Size2D base)
Returns the new size that reflects the constraints defined by this instance.double
getHeight()
Returns the fixed height.LengthConstraintType
getHeightConstraintType()
Returns the constraint type.Range
getHeightRange()
Returns the width range.double
getWidth()
Returns the fixed width.LengthConstraintType
getWidthConstraintType()
Returns the constraint type.Range
getWidthRange()
Returns the width range.RectangleConstraint
toFixedHeight(double height)
Returns a constraint that matches this one on the width attributes, but has a fixed height constraint.RectangleConstraint
toFixedWidth(double width)
Returns a constraint that matches this one on the height attributes, but has a fixed width constraint.RectangleConstraint
toRangeHeight(Range range)
Returns a constraint that matches this one on the width attributes, but has a range height constraint.RectangleConstraint
toRangeWidth(Range range)
Returns a constraint that matches this one on the height attributes, but has a range width constraint.java.lang.String
toString()
Returns a string representation of this instance, mostly used for debugging purposes.RectangleConstraint
toUnconstrainedHeight()
Returns a constraint that matches this one on the width attributes, but has no height constraint.RectangleConstraint
toUnconstrainedWidth()
Returns a constraint that matches this one on the height attributes, but has no width constraint.
-
-
-
Field Detail
-
NONE
public static final RectangleConstraint NONE
An instance representing no constraint.
-
width
private double width
The width.
-
widthRange
private Range widthRange
The width range.
-
widthConstraintType
private LengthConstraintType widthConstraintType
The width constraint type.
-
height
private double height
The fixed or maximum height.
-
heightRange
private Range heightRange
-
heightConstraintType
private LengthConstraintType heightConstraintType
The constraint type.
-
-
Constructor Detail
-
RectangleConstraint
public RectangleConstraint(double w, double h)
Creates a new "fixed width and height" instance.- Parameters:
w
- the fixed width.h
- the fixed height.
-
RectangleConstraint
public RectangleConstraint(Range w, Range h)
Creates a new "range width and height" instance.- Parameters:
w
- the width range.h
- the height range.
-
RectangleConstraint
public RectangleConstraint(Range w, double h)
Creates a new constraint with a range for the width and a fixed height.- Parameters:
w
- the width range.h
- the fixed height.
-
RectangleConstraint
public RectangleConstraint(double w, Range h)
Creates a new constraint with a fixed width and a range for the height.- Parameters:
w
- the fixed width.h
- the height range.
-
RectangleConstraint
public RectangleConstraint(double w, Range widthRange, LengthConstraintType widthConstraintType, double h, Range heightRange, LengthConstraintType heightConstraintType)
Creates a new constraint.- Parameters:
w
- the fixed or maximum width.widthRange
- the width range.widthConstraintType
- the width type.h
- the fixed or maximum height.heightRange
- the height range.heightConstraintType
- the height type.
-
-
Method Detail
-
getWidth
public double getWidth()
Returns the fixed width.- Returns:
- The width.
-
getWidthRange
public Range getWidthRange()
Returns the width range.- Returns:
- The range (possibly
null
).
-
getWidthConstraintType
public LengthConstraintType getWidthConstraintType()
Returns the constraint type.- Returns:
- The constraint type (never
null
).
-
getHeight
public double getHeight()
Returns the fixed height.- Returns:
- The height.
-
getHeightRange
public Range getHeightRange()
Returns the width range.- Returns:
- The range (possibly
null
).
-
getHeightConstraintType
public LengthConstraintType getHeightConstraintType()
Returns the constraint type.- Returns:
- The constraint type (never
null
).
-
toUnconstrainedWidth
public RectangleConstraint toUnconstrainedWidth()
Returns a constraint that matches this one on the height attributes, but has no width constraint.- Returns:
- A new constraint.
-
toUnconstrainedHeight
public RectangleConstraint toUnconstrainedHeight()
Returns a constraint that matches this one on the width attributes, but has no height constraint.- Returns:
- A new constraint.
-
toFixedWidth
public RectangleConstraint toFixedWidth(double width)
Returns a constraint that matches this one on the height attributes, but has a fixed width constraint.- Parameters:
width
- the fixed width.- Returns:
- A new constraint.
-
toFixedHeight
public RectangleConstraint toFixedHeight(double height)
Returns a constraint that matches this one on the width attributes, but has a fixed height constraint.- Parameters:
height
- the fixed height.- Returns:
- A new constraint.
-
toRangeWidth
public RectangleConstraint toRangeWidth(Range range)
Returns a constraint that matches this one on the height attributes, but has a range width constraint.- Parameters:
range
- the width range (null
not permitted).- Returns:
- A new constraint.
-
toRangeHeight
public RectangleConstraint toRangeHeight(Range range)
Returns a constraint that matches this one on the width attributes, but has a range height constraint.- Parameters:
range
- the height range (null
not permitted).- Returns:
- A new constraint.
-
toString
public java.lang.String toString()
Returns a string representation of this instance, mostly used for debugging purposes.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string.
-
-