com.orsoncharts.table

## Interface TableElement

- All Known Subinterfaces:
    ContainerElement
  All Known Implementing Classes:
    ColorScaleElement, FlowElement, GridElement, ShapeElement, TextElement, VerticalFlowElement

      public interface TableElement

  An element (typically a single cell) in a table. This interface defines methods for determining the preferred size of the element, for laying out the element (including sub-elements if there are any), and drawing the element within specified bounds. Various kinds of table elements will be used to construct interesting tables.
  It is important that these methods are implemented in a stateless manner. There is some redundancy in calculation between the layout and drawing methods in order to preserve the statelessness, but it is important to ensure that table elements can be rendered to multiple targets simultaneously.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `CLASS` A property key for the class of a table element.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds)` Draws the element within the specified bounds.
    `void` | `draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds, TableElementOnDraw onDrawHandler)` Draws the element within the specified bounds.
    `java.lang.Object` | `getProperty(java.lang.String key)` Returns the value of the property with the specified key, or `null`.
    `RefPt2D` | `getRefPoint()` Returns the reference point used to align the element with the bounding rectangle within which it is drawn.
    `java.util.List<java.awt.geom.Rectangle2D>` | `layoutElements(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds, java.util.Map<java.lang.String,java.lang.Object> constraints)` Performs a layout of this table element, returning a list of bounding rectangles for the element and its subelements.
    `java.awt.geom.Dimension2D` | `preferredSize(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds)` Calculates the preferred size for the element, with reference to the specified bounds.
    `java.awt.geom.Dimension2D` | `preferredSize(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D bounds, java.util.Map<java.lang.String,java.lang.Object> constraints)` Returns the preferred size of the element, subject to the supplied constraints.
    `void` | `receive(TableElementVisitor visitor)` Receives a `TableElementVisitor`.
    `void` | `setProperty(java.lang.String key, java.lang.Object value)` Sets the value of the property with the specified key.

- - ### Field Detail

    - #### CLASS

          static final java.lang.String CLASS

      A property key for the class of a table element.
      Since:
        1.3
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### preferredSize

          java.awt.geom.Dimension2D preferredSize(java.awt.Graphics2D g2,
                                                  java.awt.geom.Rectangle2D bounds)

      Calculates the preferred size for the element, with reference to the specified bounds. The preferred size can exceed the bounds, but the bounds might influence how sub-elements are sized and/or positioned. For example, in a `FlowElement`, the width of the bounds will determine when the flow layout wraps.
      Parameters:
        `g2` - the graphics target (`null` not permitted).
        `bounds` - the bounds (`null` not permitted).
      Returns:
        The preferred size (never `null`).

    - #### preferredSize

          java.awt.geom.Dimension2D preferredSize(java.awt.Graphics2D g2,
                                                  java.awt.geom.Rectangle2D bounds,
                                                  java.util.Map<java.lang.String,java.lang.Object> constraints)

      Returns the preferred size of the element, subject to the supplied constraints.
      Parameters:
        `g2` - the graphics target (`null` not permitted).
        `bounds` - the bounds (`null` not permitted).
        `constraints` - the constraints (`null` permitted).
      Returns:
        The preferred size.

    - #### getRefPoint

          RefPt2D getRefPoint()

      Returns the reference point used to align the element with the bounding rectangle within which it is drawn.
      Returns:
        The anchor point (never `null`).

    - #### layoutElements

          java.util.List<java.awt.geom.Rectangle2D> layoutElements(java.awt.Graphics2D g2,
                                                                   java.awt.geom.Rectangle2D bounds,
                                                                   java.util.Map<java.lang.String,java.lang.Object> constraints)

      Performs a layout of this table element, returning a list of bounding rectangles for the element and its subelements. This method is typically called by the `draw(java.awt.Graphics2D, java.awt.geom.Rectangle2D)` method.
      Parameters:
        `g2` - the graphics target (`null` not permitted).
        `bounds` - the bounds (`null` not permitted).
        `constraints` - the constraints (if any).
      Returns:
        A list of bounding rectangles.

    - #### draw

          void draw(java.awt.Graphics2D g2,
                    java.awt.geom.Rectangle2D bounds)

      Draws the element within the specified bounds.
      Parameters:
        `g2` - the graphics target (`null` not permitted).
        `bounds` - the bounds (`null` not permitted).

    - #### draw

          void draw(java.awt.Graphics2D g2,
                    java.awt.geom.Rectangle2D bounds,
                    TableElementOnDraw onDrawHandler)

      Draws the element within the specified bounds. The `onDrawHandler` provides (optional) access to all elements before and after they are rendered.
      Parameters:
        `g2` - the graphics target (`null` not permitted).
        `bounds` - the bounds (`null` not permitted).
        `onDrawHandler` - an object that will receive notification before and after the element is drawn (`null` permitted).
      Since:
        1.3

    - #### getProperty

          java.lang.Object getProperty(java.lang.String key)

      Returns the value of the property with the specified key, or `null`.
      Parameters:
        `key` - the key (`null` not permitted).
      Returns:
        The property value or `null`.
      Since:
        1.3

    - #### setProperty

          void setProperty(java.lang.String key,
                           java.lang.Object value)

      Sets the value of the property with the specified key.
      Parameters:
        `key` - the key (`null` not permitted).
        `value` - the value (`null` permitted).
      Since:
        1.3

    - #### receive

          void receive(TableElementVisitor visitor)

      Receives a `TableElementVisitor`. The visitor will have its `visit(TableElement)` method called for each child element of this table element (if it has children) and then for this element.
      Parameters:
        `visitor` - the visitor (`null` not permitted).
      Since:
        1.2