Module org.jfree.chart3d
Package org.jfree.chart3d.table

# Class TextElement

java.lang.Object
org.jfree.chart3d.table.AbstractTableElement
org.jfree.chart3d.table.TextElement

All Implemented Interfaces:
  `Serializable`, `TableElement`

public class TextElement extends AbstractTableElement implements TableElement, Serializable
A table element consisting of some text that will be drawn on one line.
NOTE: This class is serializable, but the serialization format is subject to change in future releases and should not be relied upon for persisting instances of this class.

See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`static final Font`
`DEFAULT_FONT`
The default font.

### Fields inherited from interface org.jfree.chart3d.table.TableElement

`CLASS`

## Constructor Summary

Constructors
Constructor
Description
`TextElement(String text)`
Creates a new element that will display the specified text using the default font (`DEFAULT_FONT`).
`TextElement(String text, Font font)`
Creates a new instance.

## 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.
`boolean`
`equals(Object obj)`
Tests this element for equality with an arbitrary object.
`Color`
`getColor()`
Returns the foreground color for the text element.
`Font`
`getFont()`
Returns the font.
`HAlign`
`getHorizontalAlignment()`
Returns the horizontal alignment that will be used when rendering the text.
`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, Map<String,Object> constraints)`
Returns the preferred size of the element (including insets).
`void`
`receive(TableElementVisitor visitor)`
Receives a visitor.
`void`
`setColor(Color color)`
Sets the foreground color for the text element.
`void`
`setFont(Font font)`
Sets the font.
`void`
`setHorizontalAligment(HAlign align)`
Sets the horizontal alignment.
`String`
`toString()`

### Methods inherited from class org.jfree.chart3d.table.AbstractTableElement

`getBackground, getInsets, getProperty, getRefPoint, getTag, preferredSize, setBackground, setBackgroundColor, setInsets, setProperty, setRefPoint, setTag`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.jfree.chart3d.table.TableElement

`getProperty, getRefPoint, preferredSize, setProperty`

## Field Details

### DEFAULT_FONT

public static final Font DEFAULT_FONT
The default font.

Since:
  1.1

## Constructor Details

### TextElement

public TextElement(String text)
Creates a new element that will display the specified text using the default font (`DEFAULT_FONT`).

Parameters:
  `text` - the text (`null` not permitted).

### TextElement

public TextElement(String text, Font font)
Creates a new instance.

Parameters:
  `text` - the text (`null` not permitted).
  `font` - the font (`null` not permitted).

## Method Details

### getFont

public Font getFont()
Returns the font. The default value is `DEFAULT_FONT`.

Returns:
  The font (never `null`).

### setFont

public void setFont(Font font)
Sets the font.

Parameters:
  `font` - the font (`null` not permitted).

### getColor

public Color getColor()
Returns the foreground color for the text element. The default value is `Color#BLACK`.

Returns:
  The foreground color (never `null`).

### setColor

public void setColor(Color color)
Sets the foreground color for the text element.

Parameters:
  `color` - the new color (`null` not permitted).

### getHorizontalAlignment

public HAlign getHorizontalAlignment()
Returns the horizontal alignment that will be used when rendering the text. The default value is `LEFT`.

Returns:
  The horizontal alignment (never `null`).

### setHorizontalAligment

public void setHorizontalAligment(HAlign align)
Sets the horizontal alignment.

Parameters:
  `align` - the alignment (`null` not permitted).

### preferredSize

public Dimension2D preferredSize(Graphics2D g2, Rectangle2D bounds, Map<String,Object> constraints)
Returns the preferred size of the element (including insets).

Specified by:
  `preferredSize` in interface `TableElement`
Specified by:
  `preferredSize` in class `AbstractTableElement`
Parameters:
  `g2` - the graphics target.
  `bounds` - the bounds.
  `constraints` - the constraints (ignored for now).
Returns:
  The preferred size.

### layoutElements

public 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.

Specified by:
  `layoutElements` in interface `TableElement`
Parameters:
  `g2` - the graphics target.
  `bounds` - the bounds.
  `constraints` - the constraints (if any).
Returns:
  A list containing the bounding rectangle for the text (as the only item in the list).

### receive

public void receive(TableElementVisitor visitor)
Receives a visitor.

Specified by:
  `receive` in interface `TableElement`
Parameters:
  `visitor` - the visitor (`null` not permitted).
Since:
  1.2

### draw

public void draw(Graphics2D g2, Rectangle2D bounds)
Draws the element within the specified bounds.

Specified by:
  `draw` in interface `TableElement`
Parameters:
  `g2` - the graphics target.
  `bounds` - the bounds.

### draw

public void draw(Graphics2D g2, Rectangle2D bounds, TableElementOnDraw onDrawHandler)
Draws the element within the specified bounds. If the `recordBounds` flag is set, this element and each of its children will have their `BOUNDS_2D` property updated with the current bounds.

Specified by:
  `draw` in interface `TableElement`
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).

### equals

public boolean equals(Object obj)
Tests this element for equality with an arbitrary object.

Overrides:
  `equals` in class `AbstractTableElement`
Parameters:
  `obj` - the object (`null` permitted).
Returns:
  A boolean.

### toString

public String toString()

Overrides:
  `toString` in class `Object`