Package org.jfree.chart.block
Class AbstractBlock
java.lang.Object
org.jfree.chart.block.AbstractBlock
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
BlockContainer,ColorBlock,EmptyBlock,LabelBlock,LegendGraphic,Title
A convenience class for creating new classes that implement
the
Block interface.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarrange(Graphics2D g2) Arranges the contents of the block, with no constraints, and returns the block size.arrange(Graphics2D g2, RectangleConstraint constraint) Arranges the contents of the block, within the given constraints, and returns the block size.protected doublecalculateTotalHeight(double contentHeight) Adds the margin, border and padding to the specified content height.protected doublecalculateTotalWidth(double contentWidth) Adds the margin, border and padding to the specified content width.booleanEnsures symmetry between super/subclass implementations of equals.clone()Returns a clone of this block.protected voiddrawBorder(Graphics2D g2, Rectangle2D area) Draws the border around the perimeter of the specified area.booleanTests this block for equality with an arbitrary object.Returns the current bounds of the block.doubleReturns the x-offset for the content within the block.doubleReturns the y-offset for the content within the block.getFrame()Returns the current frame (border).doubleReturns the natural height of the block, if this is known in advance.getID()Returns the id.Returns the margin.Returns the padding.doublegetWidth()Returns the natural width of the block, if this is known in advance.inthashCode()voidsetBorder(double top, double left, double bottom, double right) Sets a black border with the specified line widths.voidsetBounds(Rectangle2D bounds) Sets the bounds of the block.voidsetFrame(BlockFrame frame) Sets the frame (or border).voidsetHeight(double height) Sets the natural width of the block, if this is known in advance.voidSets the id for the block.voidsetMargin(double top, double left, double bottom, double right) Sets the margin.voidsetMargin(RectangleInsets margin) Sets the margin (useRectangleInsets.ZERO_INSETSfor no padding).voidsetPadding(double top, double left, double bottom, double right) Sets the padding.voidsetPadding(RectangleInsets padding) Sets the padding (useRectangleInsets.ZERO_INSETSfor no padding).voidsetWidth(double width) Sets the natural width of the block, if this is known in advance.protected RectangleConstraintReturns a constraint for the content of this block that will result in the bounds of the block matching the specified constraint.protected Rectangle2DtrimBorder(Rectangle2D area) Reduces the specified area by the amount of space consumed by the border.protected Rectangle2DtrimMargin(Rectangle2D area) Reduces the specified area by the amount of space consumed by the margin.protected Rectangle2DtrimPadding(Rectangle2D area) Reduces the specified area by the amount of space consumed by the padding.protected doubletrimToContentHeight(double fixedHeight) Calculate the height available for content after subtracting the margin, border and padding space from the specified fixed height.protected doubletrimToContentWidth(double fixedWidth) Calculate the width available for content after subtracting the margin, border and padding space from the specified fixed width.
-
Constructor Details
-
AbstractBlock
protected AbstractBlock()Creates a new block.
-
-
Method Details
-
getID
Returns the id.- Returns:
- The id (possibly
null). - See Also:
-
setID
Sets the id for the block.- Parameters:
id- the id (nullpermitted).- See Also:
-
getWidth
Returns the natural width of the block, if this is known in advance. The actual width of the block may be overridden if layout constraints make this necessary.- Returns:
- The width.
- See Also:
-
setWidth
Sets the natural width of the block, if this is known in advance.- Parameters:
width- the width (in Java2D units)- See Also:
-
getHeight
Returns the natural height of the block, if this is known in advance. The actual height of the block may be overridden if layout constraints make this necessary.- Returns:
- The height.
- See Also:
-
setHeight
Sets the natural width of the block, if this is known in advance.- Parameters:
height- the width (in Java2D units)- See Also:
-
getMargin
Returns the margin.- Returns:
- The margin (never
null). - See Also:
-
setMargin
Sets the margin (useRectangleInsets.ZERO_INSETSfor no padding).- Parameters:
margin- the margin (nullnot permitted).- See Also:
-
setMargin
Sets the margin.- Parameters:
top- the top margin.left- the left margin.bottom- the bottom margin.right- the right margin.- See Also:
-
setBorder
Sets a black border with the specified line widths.- Parameters:
top- the top border line width.left- the left border line width.bottom- the bottom border line width.right- the right border line width.
-
getFrame
Returns the current frame (border).- Returns:
- The frame.
- See Also:
-
setFrame
Sets the frame (or border).- Parameters:
frame- the frame (nullnot permitted).- See Also:
-
getPadding
Returns the padding.- Returns:
- The padding (never
null). - See Also:
-
setPadding
Sets the padding (useRectangleInsets.ZERO_INSETSfor no padding).- Parameters:
padding- the padding (nullnot permitted).- See Also:
-
setPadding
Sets the padding.- Parameters:
top- the top padding.left- the left padding.bottom- the bottom padding.right- the right padding.
-
getContentXOffset
Returns the x-offset for the content within the block.- Returns:
- The x-offset.
- See Also:
-
getContentYOffset
Returns the y-offset for the content within the block.- Returns:
- The y-offset.
- See Also:
-
arrange
Arranges the contents of the block, with no constraints, and returns the block size.- Parameters:
g2- the graphics device.- Returns:
- The block size (in Java2D units, never
null).
-
arrange
Arranges the contents of the block, within the given constraints, and returns the block size.- Parameters:
g2- the graphics device.constraint- the constraint (nullnot permitted).- Returns:
- The block size (in Java2D units, never
null).
-
getBounds
Returns the current bounds of the block.- Returns:
- The bounds.
- See Also:
-
setBounds
Sets the bounds of the block.- Parameters:
bounds- the bounds (nullnot permitted).- See Also:
-
trimToContentWidth
Calculate the width available for content after subtracting the margin, border and padding space from the specified fixed width.- Parameters:
fixedWidth- the fixed width.- Returns:
- The available space.
- See Also:
-
trimToContentHeight
Calculate the height available for content after subtracting the margin, border and padding space from the specified fixed height.- Parameters:
fixedHeight- the fixed height.- Returns:
- The available space.
- See Also:
-
toContentConstraint
Returns a constraint for the content of this block that will result in the bounds of the block matching the specified constraint.- Parameters:
c- the outer constraint (nullnot permitted).- Returns:
- The content constraint.
-
calculateTotalWidth
Adds the margin, border and padding to the specified content width.- Parameters:
contentWidth- the content width.- Returns:
- The adjusted width.
-
calculateTotalHeight
Adds the margin, border and padding to the specified content height.- Parameters:
contentHeight- the content height.- Returns:
- The adjusted height.
-
trimMargin
Reduces the specified area by the amount of space consumed by the margin.- Parameters:
area- the area (nullnot permitted).- Returns:
- The trimmed area.
-
trimBorder
Reduces the specified area by the amount of space consumed by the border.- Parameters:
area- the area (nullnot permitted).- Returns:
- The trimmed area.
-
trimPadding
Reduces the specified area by the amount of space consumed by the padding.- Parameters:
area- the area (nullnot permitted).- Returns:
- The trimmed area.
-
drawBorder
Draws the border around the perimeter of the specified area.- Parameters:
g2- the graphics device.area- the area.
-
equals
Tests this block for equality with an arbitrary object. -
canEqual
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Parameters:
other- Object- Returns:
- true ONLY if the parameter is THIS class type
-
hashCode
-
clone
Returns a clone of this block.- Overrides:
clonein classObject- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if there is a problem creating the clone.
-