Package org.jfree.chart.title
Class Title
java.lang.Object
org.jfree.chart.block.AbstractBlock
org.jfree.chart.title.Title
- All Implemented Interfaces:
Serializable
,Cloneable
,Block
,Drawable
- Direct Known Subclasses:
CompositeTitle
,ImageTitle
,LegendTitle
,PaintScaleLegend
,TextTitle
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.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HorizontalAlignment
The default horizontal alignment.static final RectangleInsets
Default title padding.static final RectangleEdge
The default title position.static final VerticalAlignment
The default vertical alignment.private HorizontalAlignment
The horizontal alignment of the title content.private EventListenerList
Storage for registered change listeners.private boolean
A flag that can be used to temporarily disable the listener mechanism.private RectangleEdge
The title position.private static final long
For serialization.private VerticalAlignment
The vertical alignment of the title content.boolean
A flag that controls whether or not the title is visible. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
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.protected
Title
(RectangleEdge position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, RectangleInsets padding) Creates a new title. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(TitleChangeListener listener) Registers an object for notification of changes to the title.boolean
Ensures symmetry between super/subclass implementations of equals.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
Tests an object for equality with this title.Returns the horizontal alignment of the title.boolean
Returns the flag that indicates whether or not the notification mechanism is enabled.Returns the position of the title.Returns the vertical alignment of the title.int
hashCode()
Returns a hashcode for the title.boolean
Returns a flag that controls whether or not the title should be drawn.protected void
notifyListeners
(TitleChangeEvent event) Notifies all registered listeners that the chart title has changed in some way.private void
readObject
(ObjectInputStream stream) Provides serialization support.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 aTitleChangeEvent
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 aTitleChangeEvent
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 aTitleChangeEvent
to all registered listeners.private void
writeObject
(ObjectOutputStream stream) Provides serialization support.Methods inherited from class org.jfree.chart.block.AbstractBlock
arrange, arrange, calculateTotalHeight, calculateTotalWidth, drawBorder, getBounds, getContentXOffset, getContentYOffset, getFrame, getHeight, getID, getMargin, getPadding, getWidth, setBorder, setBounds, setFrame, setHeight, setID, setMargin, setMargin, setPadding, setPadding, setWidth, toContentConstraint, trimBorder, trimMargin, trimPadding, trimToContentHeight, trimToContentWidth
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor serialization.- See Also:
-
DEFAULT_POSITION
The default title position. -
DEFAULT_HORIZONTAL_ALIGNMENT
The default horizontal alignment. -
DEFAULT_VERTICAL_ALIGNMENT
The default vertical alignment. -
DEFAULT_PADDING
Default title padding. -
visible
public boolean visibleA flag that controls whether or not the title is visible. -
position
The title position. -
horizontalAlignment
The horizontal alignment of the title content. -
verticalAlignment
The vertical alignment of the title content. -
listenerList
Storage for registered change listeners. -
notify
private boolean notifyA flag that can be used to temporarily disable the listener mechanism.
-
-
Constructor Details
-
Title
protected Title()Creates a new title, using default attributes where necessary. -
Title
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).
-
Title
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).
-
-
Method Details
-
isVisible
public boolean isVisible()Returns a flag that controls whether or not the title should be drawn. The default value istrue
.- Returns:
- A boolean.
- See Also:
-
setVisible
public void setVisible(boolean visible) Sets a flag that controls whether or not the title should be drawn, and sends aTitleChangeEvent
to all registered listeners.- Parameters:
visible
- the new flag value.- See Also:
-
getPosition
Returns the position of the title.- Returns:
- The title position (never
null
).
-
setPosition
Sets the position for the title and sends aTitleChangeEvent
to all registered listeners.- Parameters:
position
- the position (null
not permitted).
-
getHorizontalAlignment
Returns the horizontal alignment of the title.- Returns:
- The horizontal alignment (never
null
).
-
setHorizontalAlignment
Sets the horizontal alignment for the title and sends aTitleChangeEvent
to all registered listeners.- Parameters:
alignment
- the horizontal alignment (null
not permitted).
-
getVerticalAlignment
Returns the vertical alignment of the title.- Returns:
- The vertical alignment (never
null
).
-
setVerticalAlignment
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).
-
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.
-
draw
Draws the title on a Java 2D graphics device (such as the screen or a printer). -
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.
- Overrides:
clone
in classAbstractBlock
- 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.
-
notifyListeners
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.
-
equals
Tests an object for equality with this title.- Overrides:
equals
in classAbstractBlock
- Parameters:
obj
- the object (null
not permitted).- Returns:
true
orfalse
.
-
canEqual
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance.- Overrides:
canEqual
in classAbstractBlock
- Parameters:
other
- Object- Returns:
- true ONLY if the parameter is THIS class type
-
hashCode
public int hashCode()Returns a hashcode for the title.- Overrides:
hashCode
in classAbstractBlock
- Returns:
- The hashcode.
-
writeObject
Provides serialization support.- Parameters:
stream
- the output stream.- Throws:
IOException
- if there is an I/O error.
-
readObject
Provides serialization support.- Parameters:
stream
- the input stream.- Throws:
IOException
- if there is an I/O error.ClassNotFoundException
- if there is a classpath problem.
-