## org.jfree.chart.block
Class AbstractBlock

    java.lang.Object
      org.jfree.chart.block.AbstractBlock

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  BlockContainer, ColorBlock, EmptyBlock, LabelBlock, LegendGraphic, Title

    public class AbstractBlock

extends java.lang.Object
implements java.io.Serializable

A convenience class for creating new classes that implement the `Block` interface.

See Also:
  Serialized Form

Constructor Summary
`protected` `AbstractBlock()` Creates a new block.

Method Summary
`org.jfree.ui.Size2D` `arrange(java.awt.Graphics2D g2)` Arranges the contents of the block, with no constraints, and returns the block size.
`org.jfree.ui.Size2D` `arrange(java.awt.Graphics2D g2, RectangleConstraint constraint)` Arranges the contents of the block, within the given constraints, and returns the block size.
`protected double` `calculateTotalHeight(double contentHeight)` Adds the margin, border and padding to the specified content height.
`protected double` `calculateTotalWidth(double contentWidth)` Adds the margin, border and padding to the specified content width.
`protected void` `drawBorder(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)` Draws the border around the perimeter of the specified area.
`boolean` `equals(java.lang.Object obj)` Tests this block for equality with an arbitrary object.
`BlockBorder` `getBorder()` Returns the border.
`java.awt.geom.Rectangle2D` `getBounds()` Returns the current bounds of the block.
`double` `getHeight()` Returns the natural height of the block, if this is known in advance.
`java.lang.String` `getID()` Returns the id.
`org.jfree.ui.RectangleInsets` `getMargin()` Returns the margin.
`org.jfree.ui.RectangleInsets` `getPadding()` Returns the padding.
`double` `getWidth()` Returns the natural width of the block, if this is known in advance.
`void` `setBorder(BlockBorder border)` Sets the border for the block.
`void` `setBounds(java.awt.geom.Rectangle2D bounds)` Sets the bounds of the block.
`void` `setHeight(double height)` Sets the natural width of the block, if this is known in advance.
`void` `setID(java.lang.String id)` Sets the id for the block.
`void` `setMargin(org.jfree.ui.RectangleInsets margin)` Sets the margin.
`void` `setPadding(org.jfree.ui.RectangleInsets padding)` Sets the padding.
`void` `setWidth(double width)` Sets the natural width of the block, if this is known in advance.
`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.
`protected java.awt.geom.Rectangle2D` `trimBorder(java.awt.geom.Rectangle2D area)` Reduces the specified area by the amount of space consumed by the border.
`protected java.awt.geom.Rectangle2D` `trimMargin(java.awt.geom.Rectangle2D area)` Reduces the specified area by the amount of space consumed by the margin.
`protected java.awt.geom.Rectangle2D` `trimPadding(java.awt.geom.Rectangle2D area)` Reduces the specified area by the amount of space consumed by the padding.
`protected double` `trimToContentHeight(double fixedHeight)` Calculate the height available for content after subtracting the margin, border and padding space from the specified fixed height.
`protected double` `trimToContentWidth(double fixedWidth)` Calculate the width available for content after subtracting the margin, border and padding space from the specified fixed width.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractBlock

    protected AbstractBlock()

  Creates a new block.

Method Detail

### getID

    public java.lang.String getID()

  Returns the id.

  Returns:
    The id (possibly `null`).

### setID

    public void setID(java.lang.String id)

  Sets the id for the block.

  Parameters:
    `id` - the id (`null` permitted).

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

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

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

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

### getMargin

    public org.jfree.ui.RectangleInsets getMargin()

  Returns the margin.

  Returns:
    The margin (never `null`).

### setMargin

    public void setMargin(org.jfree.ui.RectangleInsets margin)

  Sets the margin. Use `RectangleInsets.ZERO_INSETS` for no padding.

  Parameters:
    `margin` - the margin (`null` not permitted).

### getBorder

    public BlockBorder getBorder()

  Returns the border.

  Returns:
    The border (never `null`).

### setBorder

    public void setBorder(BlockBorder border)

  Sets the border for the block. Use `BlockBorder.NONE` for no border.

  Parameters:
    `border` - the border (`null` not permitted).

### getPadding

    public org.jfree.ui.RectangleInsets getPadding()

  Returns the padding.

  Returns:
    The padding (never `null`).

### setPadding

    public void setPadding(org.jfree.ui.RectangleInsets padding)

  Sets the padding. Use `RectangleInsets.ZERO_INSETS` for no padding.

  Parameters:
    `padding` - the padding (never `null`).

### arrange

    public org.jfree.ui.Size2D arrange(java.awt.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 org.jfree.ui.Size2D arrange(java.awt.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`).

### getBounds

    public java.awt.geom.Rectangle2D getBounds()

  Returns the current bounds of the block.

  Returns:
    The bounds.

### setBounds

    public void setBounds(java.awt.geom.Rectangle2D bounds)

  Sets the bounds of the block.

  Parameters:
    `bounds` - the bounds (`null` not permitted).

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

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

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

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

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

### trimMargin

    protected java.awt.geom.Rectangle2D trimMargin(java.awt.geom.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.

### trimBorder

    protected java.awt.geom.Rectangle2D trimBorder(java.awt.geom.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.

### trimPadding

    protected java.awt.geom.Rectangle2D trimPadding(java.awt.geom.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.

### drawBorder

    protected void drawBorder(java.awt.Graphics2D g2,
                              java.awt.geom.Rectangle2D area)

  Draws the border around the perimeter of the specified area.

  Parameters:
    `g2` - the graphics device.
    `area` - the area.

### equals

    public boolean equals(java.lang.Object obj)

  Tests this block for equality with an arbitrary object.

  Overrides:
    `equals` in class `java.lang.Object`
  Parameters:
    `obj` - the object (`null` permitted).
  Returns:
    A boolean.