org.jfree.chart.title

Class TextTitle

public class TextTitle extends Title implements Serializable, Cloneable, PublicCloneable

A chart title that displays a text string with automatic wrapping as required.
Field Summary
static FontDEFAULT_FONT
The default font.
static PaintDEFAULT_TEXT_PAINT
The default text color.
Constructor Summary
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, RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding)
Creates a new title.
Method Summary
Size2Darrange(Graphics2D g2, RectangleConstraint constraint)
Arranges the contents of the block, within the given constraints, and returns the block size.
protected Size2DarrangeFN(Graphics2D g2, double w)
Arranges the content for this title assuming a fixed width and no bounds on the height, and returns the required size.
protected Size2DarrangeNN(Graphics2D g2)
Arranges the content for this title assuming no bounds on the width or the height, and returns the required size.
protected Size2DarrangeRN(Graphics2D g2, Range widthRange)
Arranges the content for this title assuming a range constraint for the width and no bounds on the height, and returns the required size.
protected Size2DarrangeRR(Graphics2D g2, Range widthRange, Range heightRange)
Returns the content size for the title.
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).
Objectdraw(Graphics2D g2, Rectangle2D area, Object params)
Draws the block within the specified area.
protected voiddrawHorizontal(Graphics2D g2, Rectangle2D area)
Draws a the title horizontally within the specified area.
protected voiddrawVertical(Graphics2D g2, Rectangle2D area)
Draws a the title vertically within the specified area.
booleanequals(Object obj)
Tests this title for equality with another object.
PaintgetBackgroundPaint()
Returns the background paint.
booleangetExpandToFitSpace()
Returns the flag that controls whether or not the title expands to fit the available space.
FontgetFont()
Returns the font used to display the title string.
intgetMaximumLinesToDisplay()
Returns the maximum number of lines to display.
PaintgetPaint()
Returns the paint used to display the title string.
StringgetText()
Returns the title text.
HorizontalAlignmentgetTextAlignment()
Returns the text alignment.
StringgetToolTipText()
Returns the tool tip text.
StringgetURLText()
Returns the URL text.
inthashCode()
Returns a hash code.
voidsetBackgroundPaint(Paint paint)
Sets the background paint and sends a TitleChangeEvent to all registered listeners.
voidsetExpandToFitSpace(boolean expand)
Sets the flag that controls whether the title expands to fit the available space, and sends a TitleChangeEvent to all registered listeners.
voidsetFont(Font font)
Sets the font used to display the title string.
voidsetMaximumLinesToDisplay(int max)
Sets the maximum number of lines to display and sends a TitleChangeEvent to all registered listeners.
voidsetPaint(Paint paint)
Sets the paint used to display the title string.
voidsetText(String text)
Sets the title to the specified text and sends a TitleChangeEvent to all registered listeners.
voidsetTextAlignment(HorizontalAlignment alignment)
Sets the text alignment and sends a TitleChangeEvent to all registered listeners.
voidsetToolTipText(String text)
Sets the tool tip text to the specified text and sends a TitleChangeEvent to all registered listeners.
voidsetURLText(String text)
Sets the URL text to the specified text and sends a TitleChangeEvent to all registered listeners.

Field Detail

DEFAULT_FONT

public static final Font DEFAULT_FONT
The default font.

DEFAULT_TEXT_PAINT

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

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

TextTitle

public TextTitle(String text, 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(String text, Font font, Paint paint, RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, 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

arrange

public Size2D arrange(Graphics2D g2, RectangleConstraint constraint)
Arranges the contents of the block, within the given constraints, and returns the block size.

Parameters: g2 the graphics device. constraint the constraint (null not permitted).

Returns: The block size (in Java2D units, never null).

arrangeFN

protected Size2D arrangeFN(Graphics2D g2, double w)
Arranges the content for this title assuming a fixed width and no bounds on the height, and returns the required size. This will reflect the fact that a text title positioned on the left or right of a chart will be rotated by 90 degrees.

Parameters: g2 the graphics target. w the width.

Returns: The content size.

Since: 1.0.9

arrangeNN

protected Size2D arrangeNN(Graphics2D g2)
Arranges the content for this title assuming no bounds on the width or the height, and returns the required size. This will reflect the fact that a text title positioned on the left or right of a chart will be rotated by 90 degrees.

Parameters: g2 the graphics target.

Returns: The content size.

Since: 1.0.9

arrangeRN

protected Size2D arrangeRN(Graphics2D g2, Range widthRange)
Arranges the content for this title assuming a range constraint for the width and no bounds on the height, and returns the required size. This will reflect the fact that a text title positioned on the left or right of a chart will be rotated by 90 degrees.

Parameters: g2 the graphics target. widthRange the range for the width.

Returns: The content size.

Since: 1.0.9

arrangeRR

protected Size2D arrangeRR(Graphics2D g2, Range widthRange, Range heightRange)
Returns the content size for the title. This will reflect the fact that a text title positioned on the left or right of a chart will be rotated 90 degrees.

Parameters: g2 the graphics device. widthRange the width range. heightRange the height range.

Returns: The content size.

clone

public Object clone()
Returns a clone of this object.

Returns: A clone.

Throws: CloneNotSupportedException never.

draw

public void draw(Graphics2D g2, 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 allocated for the title.

draw

public Object draw(Graphics2D g2, Rectangle2D area, Object params)
Draws the block within the specified area.

Parameters: g2 the graphics device. area the area. params if this is an instance of EntityBlockParams it is used to determine whether or not an EntityCollection is returned by this method.

Returns: An EntityCollection containing a chart entity for the title, or null.

drawHorizontal

protected void drawHorizontal(Graphics2D g2, 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(Graphics2D g2, 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(Object obj)
Tests this title for equality with another object.

Parameters: obj the object (null permitted).

Returns: true or false.

getBackgroundPaint

public Paint getBackgroundPaint()
Returns the background paint.

Returns: The paint (possibly null).

getExpandToFitSpace

public boolean getExpandToFitSpace()
Returns the flag that controls whether or not the title expands to fit the available space.

Returns: The flag.

getFont

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

Returns: The font (never null).

See Also: setFont

getMaximumLinesToDisplay

public int getMaximumLinesToDisplay()
Returns the maximum number of lines to display.

Returns: The maximum.

Since: 1.0.10

See Also: TextTitle

getPaint

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

Returns: The paint (never null).

See Also: setPaint

getText

public String getText()
Returns the title text.

Returns: The text (never null).

See Also: setText

getTextAlignment

public HorizontalAlignment getTextAlignment()
Returns the text alignment. This controls how the text is aligned within the title's bounds, whereas the title's horizontal alignment controls how the title's bounding rectangle is aligned within the drawing space.

Returns: The text alignment.

getToolTipText

public String getToolTipText()
Returns the tool tip text.

Returns: The tool tip text (possibly null).

getURLText

public String getURLText()
Returns the URL text.

Returns: The URL text (possibly null).

hashCode

public int hashCode()
Returns a hash code.

Returns: A hash code.

setBackgroundPaint

public void setBackgroundPaint(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).

setExpandToFitSpace

public void setExpandToFitSpace(boolean expand)
Sets the flag that controls whether the title expands to fit the available space, and sends a TitleChangeEvent to all registered listeners.

Parameters: expand the flag.

setFont

public void setFont(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).

See Also: getFont

setMaximumLinesToDisplay

public void setMaximumLinesToDisplay(int max)
Sets the maximum number of lines to display and sends a TitleChangeEvent to all registered listeners.

Parameters: max the maximum.

Since: 1.0.10.

See Also: getMaximumLinesToDisplay

setPaint

public void setPaint(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).

See Also: getPaint

setText

public void setText(String text)
Sets the title to the specified text and sends a TitleChangeEvent to all registered listeners.

Parameters: text the text (null not permitted).

setTextAlignment

public void setTextAlignment(HorizontalAlignment alignment)
Sets the text alignment and sends a TitleChangeEvent to all registered listeners.

Parameters: alignment the alignment (null not permitted).

setToolTipText

public void setToolTipText(String text)
Sets the tool tip text to the specified text and sends a TitleChangeEvent to all registered listeners.

Parameters: text the text (null permitted).

setURLText

public void setURLText(String text)
Sets the URL text to the specified text and sends a TitleChangeEvent to all registered listeners.

Parameters: text the text (null permitted).