Package org.jfree.chart.title
Class TextTitle
java.lang.Object
org.jfree.chart.block.AbstractBlock
org.jfree.chart.title.Title
org.jfree.chart.title.TextTitle
- All Implemented Interfaces:
Serializable,Cloneable,Block,Drawable,PublicCloneable
- Direct Known Subclasses:
DateTitle,ShortTextTitle
A chart title that displays a text string with automatic wrapping as
required.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FontThe default font.static final PaintThe default text color.Fields inherited from class org.jfree.chart.title.Title
DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_PADDING, DEFAULT_POSITION, DEFAULT_VERTICAL_ALIGNMENT, visible -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new title, using default attributes where necessary.Creates a new title, using default attributes where necessary.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
Modifier and TypeMethodDescriptionarrange(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.booleanEnsures symmetry between super/subclass implementations of equals.clone()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).draw(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.booleanTests this title for equality with another object.Returns the background paint.booleanReturns the flag that controls whether or not the title expands to fit the available space.getFont()Returns the font used to display the title string.intReturns the maximum number of lines to display.getPaint()Returns the paint used to display the title string.getText()Returns the title text.Returns the text alignment.Returns the tool tip text.Returns the URL text.inthashCode()Returns a hash code.voidsetBackgroundPaint(Paint paint) Sets the background paint and sends aTitleChangeEventto all registered listeners.voidsetExpandToFitSpace(boolean expand) Sets the flag that controls whether the title expands to fit the available space, and sends aTitleChangeEventto all registered listeners.voidSets the font used to display the title string.voidsetMaximumLinesToDisplay(int max) Sets the maximum number of lines to display and sends aTitleChangeEventto all registered listeners.voidSets the paint used to display the title string.voidSets the title to the specified text and sends aTitleChangeEventto all registered listeners.voidsetTextAlignment(HorizontalAlignment alignment) Sets the text alignment and sends aTitleChangeEventto all registered listeners.voidsetToolTipText(String text) Sets the tool tip text to the specified text and sends aTitleChangeEventto all registered listeners.voidsetURLText(String text) Sets the URL text to the specified text and sends aTitleChangeEventto all registered listeners.Methods inherited from class org.jfree.chart.title.Title
addChangeListener, getHorizontalAlignment, getNotify, getPosition, getVerticalAlignment, isVisible, notifyListeners, removeChangeListener, setHorizontalAlignment, setNotify, setPosition, setVerticalAlignment, setVisibleMethods inherited from class org.jfree.chart.block.AbstractBlock
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
-
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 (nullnot permitted).
-
TextTitle
Creates a new title, using default attributes where necessary.- Parameters:
text- the title text (nullnot permitted).font- the title font (nullnot 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 (nullnot permitted).font- the title font (nullnot permitted).paint- the title paint (nullnot permitted).position- the title position (nullnot permitted).horizontalAlignment- the horizontal alignment (nullnot permitted).verticalAlignment- the vertical alignment (nullnot permitted).padding- the space to leave around the outside of the title.
-
-
Method Details
-
getText
Returns the title text.- Returns:
- The text (never
null). - See Also:
-
setText
Sets the title to the specified text and sends aTitleChangeEventto all registered listeners.- Parameters:
text- the text (nullnot permitted).
-
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.
-
setTextAlignment
Sets the text alignment and sends aTitleChangeEventto all registered listeners.- Parameters:
alignment- the alignment (nullnot permitted).
-
getFont
Returns the font used to display the title string.- Returns:
- The font (never
null). - See Also:
-
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).- See Also:
-
getPaint
Returns the paint used to display the title string.- Returns:
- The paint (never
null). - See Also:
-
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).- See Also:
-
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).
-
getToolTipText
Returns the tool tip text.- Returns:
- The tool tip text (possibly
null).
-
setToolTipText
Sets the tool tip text to the specified text and sends aTitleChangeEventto all registered listeners.- Parameters:
text- the text (nullpermitted).
-
getURLText
Returns the URL text.- Returns:
- The URL text (possibly
null).
-
setURLText
Sets the URL text to the specified text and sends aTitleChangeEventto all registered listeners.- Parameters:
text- the text (nullpermitted).
-
getExpandToFitSpace
Returns the flag that controls whether or not the title expands to fit the available space.- Returns:
- The flag.
-
setExpandToFitSpace
Sets the flag that controls whether the title expands to fit the available space, and sends aTitleChangeEventto all registered listeners.- Parameters:
expand- the flag.
-
getMaximumLinesToDisplay
Returns the maximum number of lines to display.- Returns:
- The maximum.
- See Also:
-
setMaximumLinesToDisplay
Sets the maximum number of lines to display and sends aTitleChangeEventto all registered listeners.- Parameters:
max- the maximum.- See Also:
-
arrange
Arranges the contents of the block, within the given constraints, and returns the block size.- Specified by:
arrangein interfaceBlock- Overrides:
arrangein classAbstractBlock- Parameters:
g2- the graphics device.constraint- the constraint (nullnot permitted).- Returns:
- The block size (in Java2D units, never
null).
-
arrangeNN
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.
-
arrangeFN
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.
-
arrangeRN
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.
-
arrangeRR
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.
-
draw
Draws the title on a Java 2D graphics device (such as the screen or a printer). -
draw
Draws the block within the specified area.- Specified by:
drawin interfaceBlock- Parameters:
g2- the graphics device.area- the area.params- if this is an instance ofEntityBlockParamsit is used to determine whether or not anEntityCollectionis returned by this method.- Returns:
- An
EntityCollectioncontaining a chart entity for the title, ornull.
-
drawHorizontal
Draws a the title horizontally within the specified area. This method will be called from thedrawmethod.- Parameters:
g2- the graphics device.area- the area for the title.
-
drawVertical
Draws a the title vertically within the specified area. This method will be called from thedrawmethod.- Parameters:
g2- the graphics device.area- the area for the title.
-
equals
Tests this title for equality with another object. -
canEqual
Ensures symmetry between super/subclass implementations of equals. For more detail, see http://jqno.nl/equalsverifier/manual/inheritance. -
hashCode
Returns a hash code. -
clone
Returns a clone of this object.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classTitle- Returns:
- A clone.
- Throws:
CloneNotSupportedException- never.
-