com.jrefinery.chart
Class TextTitle

java.lang.Object
  extended by com.jrefinery.chart.AbstractTitle
      extended by com.jrefinery.chart.TextTitle
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
DateTitle

public class TextTitle
extends AbstractTitle

A standard chart title.


Field Summary
static java.awt.Font DEFAULT_FONT
          The default font.
static java.awt.Paint DEFAULT_TEXT_PAINT
          The default text color.
protected  java.awt.Font font
          The font used to display the title.
protected  java.awt.Paint paint
          The paint used to display the title text.
protected  java.lang.String text
          The title text.
 
Fields inherited from class com.jrefinery.chart.AbstractTitle
BOTTOM, CENTER, DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_POSITION, DEFAULT_SPACER, DEFAULT_VERTICAL_ALIGNMENT, EAST, horizontalAlignment, LEFT, listeners, MIDDLE, NORTH, notify, position, RIGHT, SOUTH, spacer, TOP, verticalAlignment, WEST
 
Constructor Summary
TextTitle(java.lang.String text)
          Constructs a new TextTitle, using default attributes where necessary.
TextTitle(java.lang.String text, java.awt.Font font)
          Constructs a new TextTitle, using default attributes where necessary.
TextTitle(java.lang.String text, java.awt.Font font, int horizontalAlignment)
          Constructs a new TextTitle, using default attributes where necessary.
TextTitle(java.lang.String text, java.awt.Font font, java.awt.Paint paint)
          Constructs a new TextTitle, 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).
 java.awt.Font getFont()
          Returns the current title font.
 java.awt.Paint getPaint()
          Returns the paint used to display the title.
 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 title font to the specified font and notifies registered listeners that the title has been modified.
 void setPaint(java.awt.Paint paint)
          Sets the Paint used to display the title and notifies registered listeners that the title has been modified.
 void setText(java.lang.String text)
          Sets the title to the specified text.
 
Methods inherited from class com.jrefinery.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
equals, 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.


text

protected java.lang.String text
The title text.


font

protected java.awt.Font font
The font used to display the title.


paint

protected java.awt.Paint paint
The paint used to display the title text.

Constructor Detail

TextTitle

public TextTitle(java.lang.String text)
Constructs a new TextTitle, using default attributes where necessary.

Parameters:
text - The title text.

TextTitle

public TextTitle(java.lang.String text,
                 java.awt.Font font)
Constructs a new TextTitle, 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)
Constructs a new TextTitle, 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)
Constructs a new TextTitle, using default attributes where necessary.

Parameters:
text - The title text.
font - The title font.
horizontalAlignment - The horizontal alignment (use the constants defined in AbstractTitle).

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.

Parameters:
text - The text for the title.
font - The title font.
paint - The title color.
position - The title position (use the constants defined in AbstractTitle).
horizontalAlignment - The horizontal alignment (use the constants defined in AbstractTitle).
verticalAlignment - The vertical alignment (use the constants defined in AbstractTitle).
spacer - The space to leave around the outside of the title.
Method Detail

getFont

public java.awt.Font getFont()
Returns the current title font.

Returns:
A Font object of the font used to render this title;

setFont

public void setFont(java.awt.Font font)
Sets the title font to the specified font and notifies registered listeners that the title has been modified.

Parameters:
font - A Font object of the new font;

getPaint

public java.awt.Paint getPaint()
Returns the paint used to display the title.

Returns:
An object that implements the Paint interface used to paint this title;

setPaint

public void setPaint(java.awt.Paint paint)
Sets the Paint used to display the title and notifies registered listeners that the title has been modified.

Parameters:
paint - The new paint for displaying the chart title;

getText

public java.lang.String getText()
Returns the title text.

Returns:
A String of the title 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 - A String of the new chart title;

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 or false, indicating whether or not the title can assume the specified position.

getPreferredWidth

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

Specified by:
getPreferredWidth in class AbstractTitle

getPreferredHeight

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

Specified by:
getPreferredHeight in class AbstractTitle

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.


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.