public abstract class

Title

extends AbstractBlock
implements Serializable Cloneable Block
java.lang.Object
   ↳ org.jfree.chart.block.AbstractBlock
     ↳ org.jfree.chart.title.Title
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

The base class for all chart titles. A chart can have multiple titles, appearing at the top, bottom, left or right of the chart.

Concrete implementations of this class will render text and images, and hence do the actual work of drawing titles.

Summary

Fields
public static final HorizontalAlignment DEFAULT_HORIZONTAL_ALIGNMENT The default horizontal alignment.
public static final RectangleInsets DEFAULT_PADDING Default title padding.
public static final RectangleEdge DEFAULT_POSITION The default title position.
public static final VerticalAlignment DEFAULT_VERTICAL_ALIGNMENT The default vertical alignment.
public boolean visible A flag that controls whether or not the title is visible.
Protected Constructors
Title()
Creates a new title, using default attributes where necessary.
Title(RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
Creates a new title, using default attributes where necessary.
Title(RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding)
Creates a new title.
Public Methods
void addChangeListener(TitleChangeListener listener)
Registers an object for notification of changes to the title.
Object clone()
Returns a clone of the title.
abstract void draw(Graphics2D g2, Rectangle2D area)
Draws the title on a Java 2D graphics device (such as the screen or a printer).
boolean equals(Object obj)
Tests an object for equality with this title.
HorizontalAlignment getHorizontalAlignment()
Returns the horizontal alignment of the title.
boolean getNotify()
Returns the flag that indicates whether or not the notification mechanism is enabled.
RectangleEdge getPosition()
Returns the position of the title.
VerticalAlignment getVerticalAlignment()
Returns the vertical alignment of the title.
int hashCode()
Returns a hashcode for the title.
boolean isVisible()
Returns a flag that controls whether or not the title should be drawn.
void removeChangeListener(TitleChangeListener listener)
Unregisters an object for notification of changes to the chart title.
void setHorizontalAlignment(HorizontalAlignment alignment)
Sets the horizontal alignment for the title and sends a TitleChangeEvent to all registered listeners.
void setNotify(boolean flag)
Sets the flag that indicates whether or not the notification mechanism is enabled.
void setPosition(RectangleEdge position)
Sets the position for the title and sends a TitleChangeEvent to all registered listeners.
void setVerticalAlignment(VerticalAlignment alignment)
Sets the vertical alignment for the title, and notifies any registered listeners of the change.
void setVisible(boolean visible)
Sets a flag that controls whether or not the title should be drawn, and sends a TitleChangeEvent to all registered listeners.
Protected Methods
void notifyListeners(TitleChangeEvent event)
Notifies all registered listeners that the chart title has changed in some way.
[Expand]
Inherited Methods
From class org.jfree.chart.block.AbstractBlock
From class java.lang.Object
From interface org.jfree.chart.block.Block

Fields

public static final HorizontalAlignment DEFAULT_HORIZONTAL_ALIGNMENT

The default horizontal alignment.

public static final RectangleInsets DEFAULT_PADDING

Default title padding.

public static final RectangleEdge DEFAULT_POSITION

The default title position.

public static final VerticalAlignment DEFAULT_VERTICAL_ALIGNMENT

The default vertical alignment.

public boolean visible

A flag that controls whether or not the title is visible.

Protected Constructors

protected Title ()

Creates a new title, using default attributes where necessary.

protected Title (RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)

Creates a new title, using default attributes where necessary.

Parameters
position the position of the title (null not permitted).
horizontalAlignment the horizontal alignment of the title (null not permitted).
verticalAlignment the vertical alignment of the title (null not permitted).

protected Title (RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding)

Creates a new title.

Parameters
position the position of the title (null not permitted).
horizontalAlignment the horizontal alignment of the title (LEFT, CENTER or RIGHT, null not permitted).
verticalAlignment the vertical alignment of the title (TOP, MIDDLE or BOTTOM, null not permitted).
padding the amount of space to leave around the outside of the title (null not permitted).

Public Methods

public void addChangeListener (TitleChangeListener listener)

Registers an object for notification of changes to the title.

Parameters
listener the object that is being registered.

public Object clone ()

Returns a clone of the title.

One situation when this is useful is when editing the title properties - you can edit a clone, and then it is easier to cancel the changes if necessary.

Returns
  • A clone of the title.
Throws
CloneNotSupportedException not thrown by this class, but it may be thrown by subclasses.

public abstract 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 (subclasses should not draw outside this area).

public boolean equals (Object obj)

Tests an object for equality with this title.

Parameters
obj the object (null not permitted).
Returns
  • true or false.

public HorizontalAlignment getHorizontalAlignment ()

Returns the horizontal alignment of the title.

Returns
  • The horizontal alignment (never null).

public boolean getNotify ()

Returns the flag that indicates whether or not the notification mechanism is enabled.

Returns
  • The flag.

public RectangleEdge getPosition ()

Returns the position of the title.

Returns
  • The title position (never null).

public VerticalAlignment getVerticalAlignment ()

Returns the vertical alignment of the title.

Returns
  • The vertical alignment (never null).

public int hashCode ()

Returns a hashcode for the title.

Returns
  • The hashcode.

public boolean isVisible ()

Returns a flag that controls whether or not the title should be drawn. The default value is true.

Returns
  • A boolean.

public void removeChangeListener (TitleChangeListener listener)

Unregisters an object for notification of changes to the chart title.

Parameters
listener the object that is being unregistered.

public void setHorizontalAlignment (HorizontalAlignment alignment)

Sets the horizontal alignment for the title and sends a TitleChangeEvent to all registered listeners.

Parameters
alignment the horizontal alignment (null not permitted).

public void setNotify (boolean flag)

Sets the flag that indicates whether or not the notification mechanism is enabled. There are certain situations (such as cloning) where you want to turn notification off temporarily.

Parameters
flag the new value of the flag.

public void setPosition (RectangleEdge position)

Sets the position for the title and sends a TitleChangeEvent to all registered listeners.

Parameters
position the position (null not permitted).

public void setVerticalAlignment (VerticalAlignment alignment)

Sets the vertical alignment for the title, and notifies any registered listeners of the change.

Parameters
alignment the new vertical alignment (TOP, MIDDLE or BOTTOM, null not permitted).

public void setVisible (boolean visible)

Sets a flag that controls whether or not the title should be drawn, and sends a TitleChangeEvent to all registered listeners.

Parameters
visible the new flag value.
See Also

Protected Methods

protected void notifyListeners (TitleChangeEvent event)

Notifies all registered listeners that the chart title has changed in some way.

Parameters
event an object that contains information about the change to the title.