Class AbstractBlock

java.lang.Object
org.jfree.chart.block.AbstractBlock
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
BlockContainer, ColorBlock, EmptyBlock, LabelBlock, LegendGraphic, Title

public class AbstractBlock extends Object implements Cloneable, Serializable
A convenience class for creating new classes that implement the Block interface.
See Also:
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Creates a new block.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.jfree.ui.Size2D
    Arranges the contents of the block, with no constraints, and returns the block size.
    org.jfree.ui.Size2D
    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.
    Returns a clone of this block.
    protected void
    Draws the border around the perimeter of the specified area.
    boolean
    Tests this block for equality with an arbitrary object.
    Deprecated.
    Use getFrame() instead.
    Returns the current bounds of the block.
    double
    Returns the x-offset for the content within the block.
    double
    Returns the y-offset for the content within the block.
    Returns the current frame (border).
    double
    Returns the natural height of the block, if this is known in advance.
    Returns the id.
    org.jfree.ui.RectangleInsets
    Returns the margin.
    org.jfree.ui.RectangleInsets
    Returns the padding.
    double
    Returns the natural width of the block, if this is known in advance.
    void
    setBorder(double top, double left, double bottom, double right)
    Sets a black border with the specified line widths.
    void
    Deprecated.
    void
    Sets the bounds of the block.
    void
    Sets the frame (or border).
    void
    setHeight(double height)
    Sets the natural width of the block, if this is known in advance.
    void
    Sets the id for the block.
    void
    setMargin(double top, double left, double bottom, double right)
    Sets the margin.
    void
    setMargin(org.jfree.ui.RectangleInsets margin)
    Sets the margin (use RectangleInsets.ZERO_INSETS for no padding).
    void
    setPadding(double top, double left, double bottom, double right)
    Sets the padding.
    void
    setPadding(org.jfree.ui.RectangleInsets padding)
    Sets the padding (use RectangleInsets.ZERO_INSETS for no padding).
    void
    setWidth(double width)
    Sets the natural width of the block, if this is known in advance.
    Returns a constraint for the content of this block that will result in the bounds of the block matching the specified constraint.
    protected Rectangle2D
    Reduces the specified area by the amount of space consumed by the border.
    protected Rectangle2D
    Reduces the specified area by the amount of space consumed by the margin.
    protected Rectangle2D
    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

    finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getID

      public String getID()
      Returns the id.
      Returns:
      The id (possibly null).
      See Also:
    • setID

      public void setID(String id)
      Sets the id for the block.
      Parameters:
      id - the id (null permitted).
      See Also:
    • 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:
    • 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:
    • 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:
    • 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:
    • getMargin

      public org.jfree.ui.RectangleInsets getMargin()
      Returns the margin.
      Returns:
      The margin (never null).
      See Also:
    • 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).
      See Also:
    • 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:
    • getBorder

      Deprecated.
      Use getFrame() instead.
      Returns the border.
      Returns:
      The border (never null).
    • setBorder

      public void setBorder(BlockBorder border)
      Deprecated.
      Sets the border for the block (use BlockBorder.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.
    • getFrame

      public BlockFrame getFrame()
      Returns the current frame (border).
      Returns:
      The frame.
      Since:
      1.0.5
      See Also:
    • setFrame

      public void setFrame(BlockFrame frame)
      Sets the frame (or border).
      Parameters:
      frame - the frame (null not permitted).
      Since:
      1.0.5
      See Also:
    • getPadding

      public org.jfree.ui.RectangleInsets getPadding()
      Returns the padding.
      Returns:
      The padding (never null).
      See Also:
    • setPadding

      public void setPadding(org.jfree.ui.RectangleInsets padding)
      Sets the padding (use RectangleInsets.ZERO_INSETS for no padding).
      Parameters:
      padding - the padding (null not permitted).
      See Also:
    • 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.
    • getContentXOffset

      public double getContentXOffset()
      Returns the x-offset for the content within the block.
      Returns:
      The x-offset.
      See Also:
    • getContentYOffset

      public double getContentYOffset()
      Returns the y-offset for the content within the block.
      Returns:
      The y-offset.
      See Also:
    • arrange

      public org.jfree.ui.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 org.jfree.ui.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).
    • getBounds

      Returns the current bounds of the block.
      Returns:
      The bounds.
      See Also:
    • setBounds

      public void setBounds(Rectangle2D bounds)
      Sets the bounds of the block.
      Parameters:
      bounds - the bounds (null not permitted).
      See Also:
    • 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:
    • 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:
    • 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 (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

      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

      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

      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(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.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object (null permitted).
      Returns:
      A boolean.
    • clone

      Returns a clone of this block.
      Overrides:
      clone in class Object
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - if there is a problem creating the clone.