org.jfree.chart.block

Class AbstractBlock

public class AbstractBlock extends Object implements Cloneable, Serializable

A convenience class for creating new classes that implement the Block interface.
Constructor Summary
protected AbstractBlock()
Creates a new block.
Method Summary
Size2Darrange(Graphics2D g2)
Arranges the contents of the block, with no constraints, and returns the block size.
Size2Darrange(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.
Objectclone()
Returns a clone of this block.
protected voiddrawBorder(Graphics2D g2, Rectangle2D area)
Draws the border around the perimeter of the specified area.
booleanequals(Object obj)
Tests this block for equality with an arbitrary object.
BlockBordergetBorder()
Returns the border.
Rectangle2DgetBounds()
Returns the current bounds of the block.
doublegetContentXOffset()
Returns the x-offset for the content within the block.
doublegetContentYOffset()
Returns the y-offset for the content within the block.
BlockFramegetFrame()
Returns the current frame (border).
doublegetHeight()
Returns the natural height of the block, if this is known in advance.
StringgetID()
Returns the id.
RectangleInsetsgetMargin()
Returns the margin.
RectangleInsetsgetPadding()
Returns the padding.
doublegetWidth()
Returns the natural width of the block, if this is known in advance.
voidsetBorder(BlockBorder border)
Sets the border for the block (use NONE for no border).
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.
voidsetID(String id)
Sets the id for the block.
voidsetMargin(RectangleInsets margin)
Sets the margin (use RectangleInsets#ZERO_INSETS for no padding).
voidsetMargin(double top, double left, double bottom, double right)
Sets the margin.
voidsetPadding(RectangleInsets padding)
Sets the padding (use RectangleInsets#ZERO_INSETS for no padding).
voidsetPadding(double top, double left, double bottom, double right)
Sets the padding.
voidsetWidth(double width)
Sets the natural width of the block, if this is known in advance.
protected RectangleConstrainttoContentConstraint(RectangleConstraint c)
Returns 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 Detail

AbstractBlock

protected AbstractBlock()
Creates a new block.

Method Detail

arrange

public Size2D arrange(Graphics2D g2)
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

public Size2D arrange(Graphics2D g2, RectangleConstraint constraint)
Arranges the contents of the block, within the given constraints, and returns the block size.

Parameters: g2 the graphics device. constraint the constraint (null not permitted).

Returns: The block size (in Java2D units, never null).

calculateTotalHeight

protected double calculateTotalHeight(double contentHeight)
Adds the margin, border and padding to the specified content height.

Parameters: contentHeight the content height.

Returns: The adjusted height.

calculateTotalWidth

protected double calculateTotalWidth(double contentWidth)
Adds the margin, border and padding to the specified content width.

Parameters: contentWidth the content width.

Returns: The adjusted width.

clone

public Object clone()
Returns a clone of this block.

Returns: A clone.

Throws: CloneNotSupportedException if there is a problem creating the clone.

drawBorder

protected void drawBorder(Graphics2D g2, Rectangle2D area)
Draws the border around the perimeter of the specified area.

Parameters: g2 the graphics device. area the area.

equals

public boolean equals(Object obj)
Tests this block for equality with an arbitrary object.

Parameters: obj the object (null permitted).

Returns: A boolean.

getBorder

public BlockBorder getBorder()

Deprecated: Use getFrame instead.

Returns the border.

Returns: The border (never null).

getBounds

public Rectangle2D getBounds()
Returns the current bounds of the block.

Returns: The bounds.

See Also: setBounds

getContentXOffset

public double getContentXOffset()
Returns the x-offset for the content within the block.

Returns: The x-offset.

See Also: getContentYOffset

getContentYOffset

public double getContentYOffset()
Returns the y-offset for the content within the block.

Returns: The y-offset.

See Also: getContentXOffset

getFrame

public BlockFrame getFrame()
Returns the current frame (border).

Returns: The frame.

Since: 1.0.5

See Also: setFrame

getHeight

public double 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: AbstractBlock

getID

public String getID()
Returns the id.

Returns: The id (possibly null).

See Also: setID

getMargin

public RectangleInsets getMargin()
Returns the margin.

Returns: The margin (never null).

See Also: getMargin

getPadding

public RectangleInsets getPadding()
Returns the padding.

Returns: The padding (never null).

See Also: setPadding

getWidth

public double 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: AbstractBlock

setBorder

public void setBorder(BlockBorder border)

Deprecated: Use setFrame instead.

Sets the border for the block (use NONE for no border).

Parameters: border the border (null not permitted).

See Also:

setBorder

public void setBorder(double top, double left, double bottom, double right)
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.

setBounds

public void setBounds(Rectangle2D bounds)
Sets the bounds of the block.

Parameters: bounds the bounds (null not permitted).

See Also: getBounds

setFrame

public void setFrame(BlockFrame frame)
Sets the frame (or border).

Parameters: frame the frame (null not permitted).

Since: 1.0.5

See Also: getFrame

setHeight

public void setHeight(double height)
Sets the natural width of the block, if this is known in advance.

Parameters: height the width (in Java2D units)

See Also: getHeight

setID

public void setID(String id)
Sets the id for the block.

Parameters: id the id (null permitted).

See Also: getID

setMargin

public void setMargin(RectangleInsets margin)
Sets the margin (use RectangleInsets#ZERO_INSETS for no padding).

Parameters: margin the margin (null not permitted).

See Also: getMargin

setMargin

public void setMargin(double top, double left, double bottom, double right)
Sets the margin.

Parameters: top the top margin. left the left margin. bottom the bottom margin. right the right margin.

See Also: getMargin

setPadding

public void setPadding(RectangleInsets padding)
Sets the padding (use RectangleInsets#ZERO_INSETS for no padding).

Parameters: padding the padding (null not permitted).

See Also: getPadding

setPadding

public void setPadding(double top, double left, double bottom, double right)
Sets the padding.

Parameters: top the top padding. left the left padding. bottom the bottom padding. right the right padding.

setWidth

public void setWidth(double width)
Sets the natural width of the block, if this is known in advance.

Parameters: width the width (in Java2D units)

See Also: getWidth

toContentConstraint

protected RectangleConstraint toContentConstraint(RectangleConstraint c)
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 (null not permitted).

Returns: The content constraint.

trimBorder

protected Rectangle2D trimBorder(Rectangle2D area)
Reduces the specified area by the amount of space consumed by the border.

Parameters: area the area (null not permitted).

Returns: The trimmed area.

trimMargin

protected Rectangle2D trimMargin(Rectangle2D area)
Reduces the specified area by the amount of space consumed by the margin.

Parameters: area the area (null not permitted).

Returns: The trimmed area.

trimPadding

protected Rectangle2D trimPadding(Rectangle2D area)
Reduces the specified area by the amount of space consumed by the padding.

Parameters: area the area (null not permitted).

Returns: The trimmed area.

trimToContentHeight

protected double trimToContentHeight(double fixedHeight)
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: AbstractBlock

trimToContentWidth

protected double trimToContentWidth(double fixedWidth)
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: AbstractBlock

Copyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.