## org.jfree.chart.title
Class TextTitle

    java.lang.Object
      org.jfree.chart.block.AbstractBlock
          org.jfree.chart.title.Title
              org.jfree.chart.title.TextTitle

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, Block, org.jfree.ui.Drawable, org.jfree.util.PublicCloneable

Direct Known Subclasses:
  DateTitle

    public class TextTitle

extends Title
implements java.io.Serializable, java.lang.Cloneable, org.jfree.util.PublicCloneable

A chart title that displays a text string.

Author:
  David Berry
See Also:
  Serialized Form

Field Summary
`static java.awt.Font` `DEFAULT_FONT` The default font.
`static java.awt.Paint` `DEFAULT_TEXT_PAINT` The default text color.

Fields inherited from class org.jfree.chart.title.Title
`DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_PADDING, DEFAULT_POSITION, DEFAULT_VERTICAL_ALIGNMENT`

Constructor Summary
`TextTitle()` Creates a new title, using default attributes where necessary.
`TextTitle(java.lang.String text)` Creates a new title, using default attributes where necessary.
`TextTitle(java.lang.String text, java.awt.Font font)` Creates a new title, using default attributes where necessary.
`TextTitle(java.lang.String text, java.awt.Font font, org.jfree.ui.HorizontalAlignment horizontalAlignment)` Creates a new title, using default attributes where necessary.
`TextTitle(java.lang.String text, java.awt.Font font, java.awt.Paint paint)` Creates a new title, using default attributes where necessary.
`TextTitle(java.lang.String text, java.awt.Font font, java.awt.Paint paint, org.jfree.ui.RectangleEdge position, org.jfree.ui.HorizontalAlignment horizontalAlignment, org.jfree.ui.VerticalAlignment verticalAlignment, org.jfree.ui.RectangleInsets padding)` Creates a new title.

Method Summary
`org.jfree.ui.Size2D` `arrange(java.awt.Graphics2D g2, RectangleConstraint constraint)` Arranges the contents of the block, within the given constraints, and returns the block size.
`java.lang.Object` `clone()` Returns a clone of this object.
`void` `draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)` Draws the title on a Java 2D graphics device (such as the screen or a printer).
`protected void` `drawHorizontal(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)` Draws a the title horizontally within the specified area.
`protected void` `drawVertical(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)` Draws a the title vertically within the specified area.
`boolean` `equals(java.lang.Object obj)` Tests this title for equality with another object.
`java.awt.Paint` `getBackgroundPaint()` Returns the background paint.
`java.awt.Font` `getFont()` Returns the font used to display the title string.
`java.awt.Paint` `getPaint()` Returns the paint used to display the title string.
`java.lang.String` `getText()` Returns the title text.
`int` `hashCode()` Returns a hash code.
`void` `setBackgroundPaint(java.awt.Paint paint)` Sets the background paint and sends a `TitleChangeEvent` to all registered listeners.
`void` `setFont(java.awt.Font font)` Sets the font used to display the title string.
`void` `setPaint(java.awt.Paint paint)` Sets the paint used to display the title string.
`void` `setText(java.lang.String text)` Sets the title to the specified text and sends a `TitleChangeEvent` to all registered listeners.

Methods inherited from class org.jfree.chart.title.Title
`addChangeListener, getHorizontalAlignment, getNotify, getPosition, getVerticalAlignment, notifyListeners, removeChangeListener, setHorizontalAlignment, setNotify, setPosition, setVerticalAlignment`

Methods inherited from class org.jfree.chart.block.AbstractBlock
`arrange, calculateTotalHeight, calculateTotalWidth, drawBorder, getBorder, getBounds, getHeight, getID, getMargin, getPadding, getWidth, setBorder, setBounds, setHeight, setID, setMargin, setPadding, setWidth, toContentConstraint, trimBorder, trimMargin, trimPadding, trimToContentHeight, trimToContentWidth`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.jfree.chart.block.Block
`arrange, getBounds, getID, setBounds, setID`

Field Detail

### DEFAULT_FONT

    public static final java.awt.Font DEFAULT_FONT

  The default font.

### DEFAULT_TEXT_PAINT

    public static final java.awt.Paint DEFAULT_TEXT_PAINT

  The default text color.

Constructor Detail

### TextTitle

    public TextTitle()

  Creates a new title, using default attributes where necessary.

### TextTitle

    public TextTitle(java.lang.String text)

  Creates a new title, using default attributes where necessary.

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

### TextTitle

    public TextTitle(java.lang.String text,
                     java.awt.Font font)

  Creates a new title, using default attributes where necessary.

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

### TextTitle

    public TextTitle(java.lang.String text,
                     java.awt.Font font,
                     java.awt.Paint paint)

  Creates a new title, using default attributes where necessary.

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

### TextTitle

    public TextTitle(java.lang.String text,
                     java.awt.Font font,
                     org.jfree.ui.HorizontalAlignment horizontalAlignment)

  Creates a new title, using default attributes where necessary. For the horizontal alignment, use one of the following tokens: `HorizontalAlignment.LEFT`, `HorizontalAlignment.RIGHT` and `HorizontalAlignment.CENTER`.

  Parameters:
    `text` - the title text (`null` not permitted).
    `font` - the title font (`null` not permitted).
    `horizontalAlignment` - the horizontal alignment (`null` not permitted).

### TextTitle

    public TextTitle(java.lang.String text,
                     java.awt.Font font,
                     java.awt.Paint paint,
                     org.jfree.ui.RectangleEdge position,
                     org.jfree.ui.HorizontalAlignment horizontalAlignment,
                     org.jfree.ui.VerticalAlignment verticalAlignment,
                     org.jfree.ui.RectangleInsets padding)

  Creates a new title.

  Parameters:
    `text` - the text for the title (`null` not permitted).
    `font` - the title font (`null` not permitted).
    `paint` - the title paint (`null` not permitted).
    `position` - the title position (`null` not permitted).
    `horizontalAlignment` - the horizontal alignment (`null` not permitted).
    `verticalAlignment` - the vertical alignment (`null` not permitted).
    `padding` - the space to leave around the outside of the title.

Method Detail

### getText

    public java.lang.String getText()

  Returns the title text.

  Returns:
    The text (never `null`).

### setText

    public void setText(java.lang.String text)

  Sets the title to the specified text and sends a `TitleChangeEvent` to all registered listeners.

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

### getFont

    public java.awt.Font getFont()

  Returns the font used to display the title string.

  Returns:
    The font (never `null`).

### setFont

    public void setFont(java.awt.Font font)

  Sets the font used to display the title string. Registered listeners are notified that the title has been modified.

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

### getPaint

    public java.awt.Paint getPaint()

  Returns the paint used to display the title string.

  Returns:
    The paint (never `null`).

### setPaint

    public void setPaint(java.awt.Paint paint)

  Sets the paint used to display the title string. Registered listeners are notified that the title has been modified.

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

### getBackgroundPaint

    public java.awt.Paint getBackgroundPaint()

  Returns the background paint.

  Returns:
    The paint (possibly `null`).

### setBackgroundPaint

    public void setBackgroundPaint(java.awt.Paint paint)

  Sets the background paint and sends a `TitleChangeEvent` to all registered listeners. If you set this attribute to `null`, no background is painted (which makes the title background transparent).

  Parameters:
    `paint` - the background paint (`null` permitted).

### arrange

    public org.jfree.ui.Size2D arrange(java.awt.Graphics2D g2,
                                       RectangleConstraint constraint)

  Arranges the contents of the block, within the given constraints, and returns the block size.

  Specified by:
    `arrange` in interface `Block`
  Overrides:
    `arrange` in class `AbstractBlock`
  Parameters:
    `g2` - the graphics device.
    `constraint` - the constraint (`null` not permitted).
  Returns:
    The block size (in Java2D units, never `null`).

### draw

    public void draw(java.awt.Graphics2D g2,
                     java.awt.geom.Rectangle2D area)

  Draws the title on a Java 2D graphics device (such as the screen or a printer).

  Specified by:
    `draw` in interface `org.jfree.ui.Drawable`
  Specified by:
    `draw` in class `Title`
  Parameters:
    `g2` - the graphics device.
    `area` - the area allocated for the title.

### drawHorizontal

    protected void drawHorizontal(java.awt.Graphics2D g2,
                                  java.awt.geom.Rectangle2D area)

  Draws a the title horizontally within the specified area. This method will be called from the `draw` method.

  Parameters:
    `g2` - the graphics device.
    `area` - the area for the title.

### drawVertical

    protected void drawVertical(java.awt.Graphics2D g2,
                                java.awt.geom.Rectangle2D area)

  Draws a the title vertically within the specified area. This method will be called from the `draw` method.

  Parameters:
    `g2` - the graphics device.
    `area` - the area for the title.

### equals

    public boolean equals(java.lang.Object obj)

  Tests this title for equality with another object.

  Overrides:
    `equals` in class `Title`
  Parameters:
    `obj` - the object (`null` permitted).
  Returns:
    `true` or `false`.

### hashCode

    public int hashCode()

  Returns a hash code.

  Overrides:
    `hashCode` in class `Title`
  Returns:
    A hash code.

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Returns a clone of this object.

  Specified by:
    `clone` in interface `org.jfree.util.PublicCloneable`
  Overrides:
    `clone` in class `Title`
  Returns:
    A clone.
  Throws:
    `java.lang.CloneNotSupportedException` - never.