Package org.jfree.chart.title
Class TextTitle
java.lang.Object
org.jfree.chart.title.Title
org.jfree.chart.title.TextTitle
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
DateTitle
public class TextTitle extends Title implements Serializable, Cloneable
A chart title that displays a text string.
- Author:
- David Berry
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static FontDEFAULT_FONTThe default font.static PaintDEFAULT_TEXT_PAINTThe default text color.Fields inherited from class org.jfree.chart.title.Title
BOTTOM, CENTER, DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_POSITION, DEFAULT_SPACER, DEFAULT_VERTICAL_ALIGNMENT, EAST, LEFT, MIDDLE, NORTH, RIGHT, SOUTH, TOP, WEST -
Constructor Summary
Constructors Constructor Description TextTitle()Creates a new title, using default attributes where necessary.TextTitle(String text)Creates a new title, using default attributes where necessary.TextTitle(String text, Font font)Creates a new title, using default attributes where necessary.TextTitle(String text, Font font, Paint paint)Creates a new title, using default attributes where necessary.TextTitle(String text, Font font, Paint paint, org.jfree.ui.RectangleEdge position, org.jfree.ui.HorizontalAlignment horizontalAlignment, org.jfree.ui.VerticalAlignment verticalAlignment, org.jfree.ui.Spacer spacer)Creates a new title.TextTitle(String text, Font font, org.jfree.ui.HorizontalAlignment horizontalAlignment)Creates a new title, using default attributes where necessary. -
Method Summary
Modifier and Type Method Description Objectclone()Returns a clone of this object.voiddraw(Graphics2D g2, Rectangle2D area)Draws the title on a Java 2D graphics device (such as the screen or a printer).booleanequals(Object obj)Tests this title for equality with another object.PaintgetBackgroundPaint()Returns the background paint.FontgetFont()Returns the font used to display the title string.PaintgetPaint()Returns the paint used to display the title string.floatgetPreferredHeight(Graphics2D g2, float width)Returns the preferred height of the title.floatgetPreferredWidth(Graphics2D g2, float height)Returns the preferred width of the title.StringgetText()Returns the title text.inthashCode()Returns a hash code.voidsetBackgroundPaint(Paint paint)Sets the background paint and sends aTitleChangeEventto all registered listeners.voidsetFont(Font font)Sets the font used to display the title string.voidsetPaint(Paint paint)Sets the paint used to display the title string.voidsetText(String text)Sets the title to the specified text and sends aTitleChangeEventto all registered listeners.Methods inherited from class org.jfree.chart.title.Title
addChangeListener, getHorizontalAlignment, getNotify, getPosition, getSpacer, getVerticalAlignment, removeChangeListener, setHorizontalAlignment, setNotify, setPosition, setSpacer, setVerticalAlignment
-
Field Details
-
DEFAULT_FONT
The default font. -
DEFAULT_TEXT_PAINT
The default text color.
-
-
Constructor Details
-
TextTitle
public TextTitle()Creates a new title, using default attributes where necessary. -
TextTitle
Creates a new title, using default attributes where necessary.- Parameters:
text- the title text.
-
TextTitle
Creates a new title, using default attributes where necessary.- Parameters:
text- the title text.font- the title font.
-
TextTitle
Creates a new title, using default attributes where necessary.- Parameters:
text- the title text.font- the title font.paint- the title color.
-
TextTitle
Creates a new title, using default attributes where necessary.For the horizontal alignment, use the constants (LEFT, RIGHT and CENTER) defined in the Title class.
- Parameters:
text- the title text.font- the title font.horizontalAlignment- the horizontal alignment.
-
TextTitle
public TextTitle(String text, Font font, Paint paint, org.jfree.ui.RectangleEdge position, org.jfree.ui.HorizontalAlignment horizontalAlignment, org.jfree.ui.VerticalAlignment verticalAlignment, org.jfree.ui.Spacer spacer)Creates a new title.For the titlePosition, horizontalAlignment and verticalAlignment, use the constants defined in the Title class.
- Parameters:
text- the text for the title (nullnot permitted).font- the font (nullnot permitted).paint- the color (nullnot permitted).position- the title position (nullnot permitted).horizontalAlignment- the horizontal alignment (nullnot permitted).verticalAlignment- the vertical alignment (nullnot permitted).spacer- the space to leave around the outside of the title.
-
-
Method Details
-
getText
Returns the title text.- Returns:
- the text (never
null).
-
setText
Sets the title to the specified text and sends aTitleChangeEventto all registered listeners.- Parameters:
text- the text (nullnot permitted).
-
getFont
Returns the font used to display the title string.- Returns:
- the font (never
null).
-
setFont
Sets the font used to display the title string. Registered listeners are notified that the title has been modified.- Parameters:
font- the new font (nullnot permitted).
-
getPaint
Returns the paint used to display the title string.- Returns:
- the paint (never
null).
-
setPaint
Sets the paint used to display the title string. Registered listeners are notified that the title has been modified.- Parameters:
paint- the new paint (nullnot permitted).
-
getBackgroundPaint
Returns the background paint.- Returns:
- the paint (possibly
null).
-
setBackgroundPaint
Sets the background paint and sends aTitleChangeEventto all registered listeners. If you set this attribute tonull, no background is painted (which makes the title background transparent).- Parameters:
paint- the background paint (nullpermitted).
-
getPreferredWidth
Returns the preferred width of the title. This will only be called when the title is being drawn at the left or right of a chart.- Specified by:
getPreferredWidthin classTitle- Parameters:
g2- the graphics device.height- the height.- Returns:
- the preferred width of the title.
-
getPreferredHeight
Returns the preferred height of the title.- Specified by:
getPreferredHeightin classTitle- Parameters:
g2- the graphics device.width- the width.- Returns:
- the preferred height of the title.
-
draw
Draws the title on a Java 2D graphics device (such as the screen or a printer). -
equals
Tests this title for equality with another object. -
hashCode
public int hashCode()Returns a hash code. -
clone
Returns a clone of this object.- Overrides:
clonein classTitle- Returns:
- a clone of this object.
- Throws:
CloneNotSupportedException- never.
-