Package org.jfree.chart.block
Class LabelBlock
- java.lang.Object
-
- org.jfree.chart.block.AbstractBlock
-
- org.jfree.chart.block.LabelBlock
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,Block
,Drawable
,PublicCloneable
public class LabelBlock extends AbstractBlock implements Block, PublicCloneable
A block containing a label.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private TextBlockAnchor
contentAlignmentPoint
The content alignment point.static java.awt.Paint
DEFAULT_PAINT
The default color.private java.awt.Font
font
The font.private TextBlock
label
The label.private java.awt.Paint
paint
The paint.(package private) static long
serialVersionUID
For serialization.private java.lang.String
text
The text for the label - retained in case the label needs regenerating (for example, to change the font).private RectangleAnchor
textAnchor
The anchor point for the text.private java.lang.String
toolTipText
The tool tip text (can benull
).private java.lang.String
urlText
The URL text (can benull
).
-
Constructor Summary
Constructors Constructor Description LabelBlock(java.lang.String label)
Creates a new label block.LabelBlock(java.lang.String text, java.awt.Font font)
Creates a new label block.LabelBlock(java.lang.String text, java.awt.Font font, java.awt.Paint paint)
Creates a new label block.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Size2D
arrange(java.awt.Graphics2D g2, RectangleConstraint constraint)
Arranges the contents of the block, within the given constraints, and returns the block size.boolean
canEqual(java.lang.Object other)
Ensures symmetry between super/subclass implementations of equals.java.lang.Object
clone()
Returns a clone of thisLabelBlock
instance.void
draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
Draws the block.java.lang.Object
draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params)
Draws the block within the specified area.boolean
equals(java.lang.Object obj)
Tests thisLabelBlock
for equality with an arbitrary object.TextBlockAnchor
getContentAlignmentPoint()
Returns the content alignment point.java.awt.Font
getFont()
Returns the font.java.awt.Paint
getPaint()
Returns the paint.RectangleAnchor
getTextAnchor()
Returns the text anchor (nevernull
).java.lang.String
getToolTipText()
Returns the tool tip text.java.lang.String
getURLText()
Returns the URL text.int
hashCode()
private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
setContentAlignmentPoint(TextBlockAnchor anchor)
Sets the content alignment point.void
setFont(java.awt.Font font)
Sets the font and regenerates the label.void
setPaint(java.awt.Paint paint)
Sets the paint and regenerates the label.void
setTextAnchor(RectangleAnchor anchor)
Sets the text anchor.void
setToolTipText(java.lang.String text)
Sets the tool tip text.void
setURLText(java.lang.String text)
Sets the URL text.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.-
Methods 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 Detail
-
serialVersionUID
static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
text
private java.lang.String text
The text for the label - retained in case the label needs regenerating (for example, to change the font).
-
label
private TextBlock label
The label.
-
font
private java.awt.Font font
The font.
-
toolTipText
private java.lang.String toolTipText
The tool tip text (can benull
).
-
urlText
private java.lang.String urlText
The URL text (can benull
).
-
DEFAULT_PAINT
public static final java.awt.Paint DEFAULT_PAINT
The default color.
-
paint
private transient java.awt.Paint paint
The paint.
-
contentAlignmentPoint
private TextBlockAnchor contentAlignmentPoint
The content alignment point.
-
textAnchor
private RectangleAnchor textAnchor
The anchor point for the text.
-
-
Constructor Detail
-
LabelBlock
public LabelBlock(java.lang.String label)
Creates a new label block.- Parameters:
label
- the label (null
not permitted).
-
LabelBlock
public LabelBlock(java.lang.String text, java.awt.Font font)
Creates a new label block.- Parameters:
text
- the text for the label (null
not permitted).font
- the font (null
not permitted).
-
LabelBlock
public LabelBlock(java.lang.String text, java.awt.Font font, java.awt.Paint paint)
Creates a new label block.- Parameters:
text
- the text for the label (null
not permitted).font
- the font (null
not permitted).paint
- the paint (null
not permitted).
-
-
Method Detail
-
getFont
public java.awt.Font getFont()
Returns the font.- Returns:
- The font (never
null
). - See Also:
setFont(Font)
-
setFont
public void setFont(java.awt.Font font)
Sets the font and regenerates the label.- Parameters:
font
- the font (null
not permitted).- See Also:
getFont()
-
getPaint
public java.awt.Paint getPaint()
Returns the paint.- Returns:
- The paint (never
null
). - See Also:
setPaint(Paint)
-
setPaint
public void setPaint(java.awt.Paint paint)
Sets the paint and regenerates the label.- Parameters:
paint
- the paint (null
not permitted).- See Also:
getPaint()
-
getToolTipText
public java.lang.String getToolTipText()
Returns the tool tip text.- Returns:
- The tool tip text (possibly
null
). - See Also:
setToolTipText(String)
-
setToolTipText
public void setToolTipText(java.lang.String text)
Sets the tool tip text.- Parameters:
text
- the text (null
permitted).- See Also:
getToolTipText()
-
getURLText
public java.lang.String getURLText()
Returns the URL text.- Returns:
- The URL text (possibly
null
). - See Also:
setURLText(String)
-
setURLText
public void setURLText(java.lang.String text)
Sets the URL text.- Parameters:
text
- the text (null
permitted).- See Also:
getURLText()
-
getContentAlignmentPoint
public TextBlockAnchor getContentAlignmentPoint()
Returns the content alignment point.- Returns:
- The content alignment point (never
null
).
-
setContentAlignmentPoint
public void setContentAlignmentPoint(TextBlockAnchor anchor)
Sets the content alignment point.- Parameters:
anchor
- the anchor used to determine the alignment point (nevernull
).
-
getTextAnchor
public RectangleAnchor getTextAnchor()
Returns the text anchor (nevernull
).- Returns:
- The text anchor.
-
setTextAnchor
public void setTextAnchor(RectangleAnchor anchor)
Sets the text anchor.- Parameters:
anchor
- the anchor (null
not permitted).
-
arrange
public Size2D arrange(java.awt.Graphics2D g2, RectangleConstraint constraint)
Arranges the contents of the block, within the given constraints, and returns the block size.- Specified by:
arrange
in interfaceBlock
- Overrides:
arrange
in classAbstractBlock
- Parameters:
g2
- the graphics device.constraint
- the constraint (null
not permitted).- Returns:
- The block size (in Java2D units, never
null
).
-
draw
public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)
Draws the block.
-
draw
public java.lang.Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params)
Draws the block within the specified area.
-
equals
public boolean equals(java.lang.Object obj)
Tests thisLabelBlock
for equality with an arbitrary object.- Overrides:
equals
in classAbstractBlock
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
canEqual
public boolean canEqual(java.lang.Object other)
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()
- Overrides:
hashCode
in classAbstractBlock
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of thisLabelBlock
instance.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractBlock
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if there is a problem cloning.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
Provides serialization support.- Parameters:
stream
- the output stream.- Throws:
java.io.IOException
- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Provides serialization support.- Parameters:
stream
- the input stream.- Throws:
java.io.IOException
- if there is an I/O error.java.lang.ClassNotFoundException
- if there is a classpath problem.
-
-