Package org.jfree.chart.title
Class Title
java.lang.Object
org.jfree.chart.title.Title
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
ImageTitle
,LegendTitle
,TextTitle
public abstract class Title extends Object implements Cloneable, Serializable
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.
- Author:
- David Berry
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static int
BOTTOM
Useful constant for the title position (also used for vertical alignment).static int
CENTER
Useful constant for the title alignment (horizontal or vertical).static org.jfree.ui.HorizontalAlignment
DEFAULT_HORIZONTAL_ALIGNMENT
The default horizontal alignment.static org.jfree.ui.RectangleEdge
DEFAULT_POSITION
The default title position.static org.jfree.ui.Spacer
DEFAULT_SPACER
Default title spacer.static org.jfree.ui.VerticalAlignment
DEFAULT_VERTICAL_ALIGNMENT
The default vertical alignment.static int
EAST
Useful constant for the title position.static int
LEFT
Useful constant for the title position (also used for horizontal alignment).static int
MIDDLE
Useful constant for the title alignment (horizontal or vertical).static int
NORTH
Useful constant for the title position.static int
RIGHT
Useful constant for the title position (also used for horizontal alignment).static int
SOUTH
Useful constant for the title position.static int
TOP
Useful constant for the title position (also used for vertical alignment).static int
WEST
Useful constant for the title position. -
Method Summary
Modifier and Type Method Description 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.org.jfree.ui.HorizontalAlignment
getHorizontalAlignment()
Returns the horizontal alignment of the title.boolean
getNotify()
Returns the flag that indicates whether or not the notification mechanism is enabled.org.jfree.ui.RectangleEdge
getPosition()
Returns the position of the title.abstract float
getPreferredHeight(Graphics2D g2, float width)
Returns the preferred height of the title.abstract float
getPreferredWidth(Graphics2D g2, float height)
Returns the preferred width of the title.org.jfree.ui.Spacer
getSpacer()
Returns the spacer which determines the blank space around the edges of the title.org.jfree.ui.VerticalAlignment
getVerticalAlignment()
Returns the vertical alignment of the title.int
hashCode()
Returns a hashcode for the title.void
removeChangeListener(TitleChangeListener listener)
Unregisters an object for notification of changes to the chart title.void
setHorizontalAlignment(org.jfree.ui.HorizontalAlignment alignment)
Sets the horizontal alignment for the title and sends aTitleChangeEvent
to all registered listeners.void
setNotify(boolean flag)
Sets the flag that indicates whether or not the notification mechanism is enabled.void
setPosition(org.jfree.ui.RectangleEdge position)
Sets the position for the title and sends aTitleChangeEvent
to all registered listeners.void
setSpacer(org.jfree.ui.Spacer spacer)
Sets the spacer for the title and sends aTitleChangeEvent
to all registered listeners.void
setVerticalAlignment(org.jfree.ui.VerticalAlignment alignment)
Sets the vertical alignment for the title, and notifies any registered listeners of the change.
-
Field Details
-
TOP
public static final int TOPUseful constant for the title position (also used for vertical alignment).- See Also:
- Constant Field Values
-
BOTTOM
public static final int BOTTOMUseful constant for the title position (also used for vertical alignment).- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHTUseful constant for the title position (also used for horizontal alignment).- See Also:
- Constant Field Values
-
LEFT
public static final int LEFTUseful constant for the title position (also used for horizontal alignment).- See Also:
- Constant Field Values
-
NORTH
public static final int NORTHUseful constant for the title position.- See Also:
- Constant Field Values
-
SOUTH
public static final int SOUTHUseful constant for the title position.- See Also:
- Constant Field Values
-
EAST
public static final int EASTUseful constant for the title position.- See Also:
- Constant Field Values
-
WEST
public static final int WESTUseful constant for the title position.- See Also:
- Constant Field Values
-
CENTER
public static final int CENTERUseful constant for the title alignment (horizontal or vertical).- See Also:
- Constant Field Values
-
MIDDLE
public static final int MIDDLEUseful constant for the title alignment (horizontal or vertical).- See Also:
- Constant Field Values
-
DEFAULT_POSITION
public static final org.jfree.ui.RectangleEdge DEFAULT_POSITIONThe default title position. -
DEFAULT_HORIZONTAL_ALIGNMENT
public static final org.jfree.ui.HorizontalAlignment DEFAULT_HORIZONTAL_ALIGNMENTThe default horizontal alignment. -
DEFAULT_VERTICAL_ALIGNMENT
public static final org.jfree.ui.VerticalAlignment DEFAULT_VERTICAL_ALIGNMENTThe default vertical alignment. -
DEFAULT_SPACER
public static final org.jfree.ui.Spacer DEFAULT_SPACERDefault title spacer.
-
-
Method Details
-
getPosition
public org.jfree.ui.RectangleEdge getPosition()Returns the position of the title.- Returns:
- the title position (never
null
).
-
setPosition
public void setPosition(org.jfree.ui.RectangleEdge position)Sets the position for the title and sends aTitleChangeEvent
to all registered listeners.- Parameters:
position
- the position (null
not permitted).
-
getHorizontalAlignment
public org.jfree.ui.HorizontalAlignment getHorizontalAlignment()Returns the horizontal alignment of the title.- Returns:
- the horizontal alignment (never
null
).
-
setHorizontalAlignment
public void setHorizontalAlignment(org.jfree.ui.HorizontalAlignment alignment)Sets the horizontal alignment for the title and sends aTitleChangeEvent
to all registered listeners.- Parameters:
alignment
- the horizontal alignment (null
not permitted).
-
getVerticalAlignment
public org.jfree.ui.VerticalAlignment getVerticalAlignment()Returns the vertical alignment of the title.- Returns:
- the vertical alignment (never
null
).
-
setVerticalAlignment
public void setVerticalAlignment(org.jfree.ui.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).
-
getSpacer
public org.jfree.ui.Spacer getSpacer()Returns the spacer which determines the blank space around the edges of the title.- Returns:
- The spacer (never
null
).
-
setSpacer
public void setSpacer(org.jfree.ui.Spacer spacer)Sets the spacer for the title and sends aTitleChangeEvent
to all registered listeners.- Parameters:
spacer
- the new spacer (null
not permitted).
-
getNotify
public boolean getNotify()Returns the flag that indicates whether or not the notification mechanism is enabled.- Returns:
- the flag.
-
setNotify
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.
-
getPreferredWidth
Returns the preferred width of the title. When a title is displayed at the left or right of a chart, the chart will attempt to give the title enough space for it's preferred width.- Parameters:
g2
- the graphics device.height
- the height.- Returns:
- the preferred width of the title.
-
getPreferredHeight
Returns the preferred height of the title. When a title is displayed at the top or bottom of a chart, the chart will attempt to give the title enough space for it's preferred height.- 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).- Parameters:
g2
- the graphics device.area
- the area allocated for the title.
-
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.
-
addChangeListener
Registers an object for notification of changes to the title.- Parameters:
listener
- the object that is being registered.
-
removeChangeListener
Unregisters an object for notification of changes to the chart title.- Parameters:
listener
- the object that is being unregistered.
-
equals
Tests an object for equality with this title. -
hashCode
public int hashCode()Returns a hashcode for the title.
-