org.jfree.chart
Class TextTitle

java.lang.Object
  |
  +--org.jfree.chart.AbstractTitle
        |
        +--org.jfree.chart.TextTitle
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable
Direct Known Subclasses:
DateTitle

public class TextTitle
extends AbstractTitle
implements java.io.Serializable

A standard chart title.

Author:
David Gilbert
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.AbstractTitle
BOTTOM, CENTER, DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_POSITION, DEFAULT_SPACER, DEFAULT_VERTICAL_ALIGNMENT, EAST, LEFT, MIDDLE, NORTH, RIGHT, SOUTH, TOP, WEST
 
Constructor Summary
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, int 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, int position, int horizontalAlignment, int verticalAlignment, Spacer spacer)
          Constructs a TextTitle with the specified properties.
 
Method Summary
 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 the title on a Java 2D graphics device (such as the screen or a printer).
 boolean equals(java.lang.Object obj)
          Tests this title for equality with another object.
 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.
 double getPreferredHeight(java.awt.Graphics2D g2)
          Returns the preferred height of the title.
 double getPreferredWidth(java.awt.Graphics2D g2)
          Returns the preferred width of the title.
 java.lang.String getText()
          Returns the title text.
 boolean isValidPosition(int position)
          Returns true for the positions that are valid for TextTitle (TOP and BOTTOM for now) and false for all other positions.
 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.
 
Methods inherited from class org.jfree.chart.AbstractTitle
addChangeListener, clone, getHorizontalAlignment, getNotify, getPosition, getSpacer, getVerticalAlignment, isValidHorizontalAlignment, isValidVerticalAlignment, notifyListeners, removeChangeListener, setHorizontalAlignment, setNotify, setPosition, setSpacer, setVerticalAlignment
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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(java.lang.String text)
Creates a new title, using default attributes where necessary.

Parameters:
text - the title text.

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.
font - the title font.

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.
font - the title font.
paint - the title color.

TextTitle

public TextTitle(java.lang.String text,
                 java.awt.Font font,
                 int horizontalAlignment)
Creates a new title, using default attributes where necessary.

For the horizontal alignment, use the constants (LEFT, RIGHT and CENTER) defined in the AbstractTitle class.

Parameters:
text - the title text.
font - the title font.
horizontalAlignment - the horizontal alignment.

TextTitle

public TextTitle(java.lang.String text,
                 java.awt.Font font,
                 java.awt.Paint paint,
                 int position,
                 int horizontalAlignment,
                 int verticalAlignment,
                 Spacer spacer)
Constructs a TextTitle with the specified properties.

For the titlePosition, horizontalAlignment and verticalAlignment, use the constants defined in the AbstractTitle class.

Parameters:
text - the text for the title.
font - the title font.
paint - the title color.
position - the title position.
horizontalAlignment - the horizontal alignment.
verticalAlignment - the vertical alignment.
spacer - 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.

setText

public void setText(java.lang.String text)
Sets the title to the specified text. This method notifies registered listeners that the title has been modified.

Parameters:
text - the new text.

getFont

public java.awt.Font getFont()
Returns the font used to display the title string.

Returns:
the font.

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.

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

isValidPosition

public boolean isValidPosition(int position)
Returns true for the positions that are valid for TextTitle (TOP and BOTTOM for now) and false for all other positions.

Specified by:
isValidPosition in class AbstractTitle
Parameters:
position - the position.
Returns:
true if position is TOP or BOTTOM.

getPreferredWidth

public double getPreferredWidth(java.awt.Graphics2D g2)
Returns the preferred width of the title.

Specified by:
getPreferredWidth in class AbstractTitle
Parameters:
g2 - the graphics device.
Returns:
the preferred width of the title.

getPreferredHeight

public double getPreferredHeight(java.awt.Graphics2D g2)
Returns the preferred height of the title.

Specified by:
getPreferredHeight in class AbstractTitle
Parameters:
g2 - the graphics device.
Returns:
the preferred height of the title.

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 class AbstractTitle
Parameters:
g2 - the graphics device.
area - the area within which the title (and plot) should be drawn.

drawHorizontal

protected void drawHorizontal(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).

Parameters:
g2 - the graphics device.
area - the area within which the title should be drawn.

equals

public boolean equals(java.lang.Object obj)
Tests this title for equality with another object.

Overrides:
equals in class AbstractTitle
Parameters:
obj - the object.
Returns:
true or false.