com.orsoncharts.table

## Class TextElement

- java.lang.Object
- - com.orsoncharts.table.AbstractTableElement
  - - com.orsoncharts.table.TextElement

- All Implemented Interfaces:
    TableElement, java.io.Serializable

      public class TextElement
      extends AbstractTableElement
      implements TableElement, java.io.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 and Description
    --- | ---
    `static java.awt.Font` | `DEFAULT_FONT` The default font.

    - ### Fields inherited from interface com.orsoncharts.table.TableElement

      `CLASS`

  - ### Constructor Summary

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

  - ### Method Summary

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

    - ### Methods inherited from class com.orsoncharts.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 com.orsoncharts.table.TableElement

      `getProperty, getRefPoint, preferredSize, setProperty`

- - ### Field Detail

    - #### DEFAULT_FONT

          public static final java.awt.Font DEFAULT_FONT

      The default font.
      Since:
        1.1

  - ### Constructor Detail

    - #### TextElement

          public TextElement(java.lang.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(java.lang.String text,
                             java.awt.Font font)

      Creates a new instance.
      Parameters:
        `text` - the text (`null` not permitted).
        `font` - the font (`null` not permitted).

  - ### Method Detail

    - #### getFont

          public java.awt.Font getFont()

      Returns the font. The default value is `DEFAULT_FONT`.
      Returns:
        The font (never `null`).

    - #### setFont

          public void setFont(java.awt.Font font)

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

    - #### getColor

          public java.awt.Color getColor()

    - #### setColor

          public void setColor(java.awt.Color color)

    - #### 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 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 (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 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.
      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(java.awt.Graphics2D g2,
                           java.awt.geom.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(java.awt.Graphics2D g2,
                           java.awt.geom.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(java.lang.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 java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`