- 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.
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.getProperty
(String key) Returns the value of the property with the specified key, ornull
.Returns the reference point used to align the element with the bounding rectangle within which it is drawn.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.preferredSize
(Graphics2D g2, Rectangle2D bounds) Calculates the preferred size for the element, with reference to the specified bounds.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 aTableElementVisitor
.void
setProperty
(String key, Object value) Sets the value of the property with the specified key.
-
Field Details
-
CLASS
A property key for the class of a table element.- Since:
- 1.3
- See Also:
-
-
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 aFlowElement
, 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 thedraw(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
Draws the element within the specified bounds.- Parameters:
g2
- the graphics target (null
not permitted).bounds
- the bounds (null
not permitted).
-
draw
Draws the element within the specified bounds. TheonDrawHandler
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, ornull
.- Parameters:
key
- the key (null
not permitted).- Returns:
- The property value or
null
. - Since:
- 1.3
-
setProperty
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 aTableElementVisitor
. The visitor will have itsvisit(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
-