Module org.jfree.chart3d
Package org.jfree.chart3d.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
Description
`static final String`
`CLASS`
A property key for the class of a table element.

## Method Summary

Modifier and Type
Method
Description
`void`
`draw(Graphics2D g2, Rectangle2D bounds)`
Draws the element within the specified bounds.
`void`
`draw(Graphics2D g2, Rectangle2D bounds, TableElementOnDraw onDrawHandler)`
Draws the element within the specified bounds.
`Object`
`getProperty(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.
`List<Rectangle2D>`
`layoutElements(Graphics2D g2, Rectangle2D bounds, Map<String,Object> constraints)`
Performs a layout of this table element, returning a list of bounding rectangles for the element and its subelements.
`Dimension2D`
`preferredSize(Graphics2D g2, Rectangle2D bounds)`
Calculates the preferred size for the element, with reference to the specified bounds.
`Dimension2D`
`preferredSize(Graphics2D g2, Rectangle2D bounds, Map<String,Object> constraints)`
Returns the preferred size of the element, subject to the supplied constraints.
`void`
`receive(TableElementVisitor visitor)`
Receives a `TableElementVisitor`.
`void`
`setProperty(String key, Object value)`
Sets the value of the property with the specified key.

## Field Details

### CLASS

static final String CLASS
A property key for the class of a table element.

Since:
  1.3
See Also:
  - Constant Field Values

## Method Details

### preferredSize

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

Dimension2D preferredSize(Graphics2D g2, Rectangle2D bounds, Map<String,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

List<Rectangle2D> layoutElements(Graphics2D g2, Rectangle2D bounds, Map<String,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(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

Object getProperty(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(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

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