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 Details

  • Method Details

    • preferredSize

      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

      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

      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

      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(Graphics2D g2, 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(Graphics2D g2, 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

      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(String key, 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

      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