Package org.jfree.chart.title
Class PaintScaleLegend
- java.lang.Object
-
- org.jfree.chart.block.AbstractBlock
-
- org.jfree.chart.title.Title
-
- org.jfree.chart.title.PaintScaleLegend
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.EventListener,Block,AxisChangeListener,Drawable,PublicCloneable
public class PaintScaleLegend extends Title implements AxisChangeListener, PublicCloneable
A legend that shows a range of values and their associated colors, driven by an underlyingPaintScaleimplementation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private ValueAxisaxisThe value axis (nevernull).private AxisLocationaxisLocationThe axis location (handles both orientations, nevernull).private doubleaxisOffsetThe offset between the axis and the paint strip (in Java2D units).private java.awt.PaintbackgroundPaintThe background paint (nevernull).private PaintScalescaleThe paint scale (nevernull).(package private) static longserialVersionUIDFor serialization.private java.awt.PaintstripOutlinePaintThe paint used to draw an outline around the paint strip.private java.awt.StrokestripOutlineStrokeThe stroke used to draw an outline around the paint strip.private booleanstripOutlineVisibleA flag that controls whether or not an outline is drawn around the paint strip.private doublestripWidthThe thickness of the paint strip (in Java2D units).private intsubdivisionsThe number of subdivisions for the scale when rendering.-
Fields inherited from class org.jfree.chart.title.Title
DEFAULT_HORIZONTAL_ALIGNMENT, DEFAULT_PADDING, DEFAULT_POSITION, DEFAULT_VERTICAL_ALIGNMENT, visible
-
-
Constructor Summary
Constructors Constructor Description PaintScaleLegend(PaintScale scale, ValueAxis axis)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Size2Darrange(java.awt.Graphics2D g2, RectangleConstraint constraint)Arranges the contents of the block, within the given constraints, and returns the block size.protected Size2DarrangeRR(java.awt.Graphics2D g2, Range widthRange, Range heightRange)Returns the content size for the title.voidaxisChanged(AxisChangeEvent event)Receives notification of an axis change event and responds by firing a title change event.booleancanEqual(java.lang.Object other)Ensures symmetry between super/subclass implementations of equals.voiddraw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)Draws the legend within the specified area.java.lang.Objectdraw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params)Draws the legend within the specified area.booleanequals(java.lang.Object obj)Tests this legend for equality with an arbitrary object.ValueAxisgetAxis()Returns the axis for the paint scale.AxisLocationgetAxisLocation()Returns the axis location.doublegetAxisOffset()Returns the offset between the axis and the paint strip.java.awt.PaintgetBackgroundPaint()Returns the background paint.PaintScalegetScale()Returns the scale used to convert values to colors.java.awt.PaintgetStripOutlinePaint()Returns the paint used to draw the outline of the paint strip.java.awt.StrokegetStripOutlineStroke()Returns the stroke used to draw the outline around the paint strip.doublegetStripWidth()Returns the width of the paint strip, in Java2D units.intgetSubdivisionCount()Returns the number of subdivisions used to draw the scale.inthashCode()Returns a hashcode for the title.booleanisStripOutlineVisible()Returns the flag that controls whether or not an outline is drawn around the paint strip.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.voidsetAxis(ValueAxis axis)Sets the axis for the paint scale and sends aTitleChangeEventto all registered listeners.voidsetAxisLocation(AxisLocation location)Sets the axis location and sends aTitleChangeEventto all registered listeners.voidsetAxisOffset(double offset)Sets the offset between the axis and the paint strip and sends aTitleChangeEventto all registered listeners.voidsetBackgroundPaint(java.awt.Paint paint)Sets the background paint and sends aTitleChangeEventto all registered listeners.voidsetScale(PaintScale scale)Sets the scale and sends aTitleChangeEventto all registered listeners.voidsetStripOutlinePaint(java.awt.Paint paint)Sets the paint used to draw the outline of the paint strip, and sends aTitleChangeEventto all registered listeners.voidsetStripOutlineStroke(java.awt.Stroke stroke)Sets the stroke used to draw the outline around the paint strip and sends aTitleChangeEventto all registered listeners.voidsetStripOutlineVisible(boolean visible)Sets the flag that controls whether or not an outline is drawn around the paint strip, and sends aTitleChangeEventto all registered listeners.voidsetStripWidth(double width)Sets the width of the paint strip and sends aTitleChangeEventto all registered listeners.voidsetSubdivisionCount(int count)Sets the subdivision count and sends aTitleChangeEventto all registered listeners.private voidwriteObject(java.io.ObjectOutputStream stream)Provides serialization support.-
Methods inherited from class org.jfree.chart.title.Title
addChangeListener, clone, getHorizontalAlignment, getNotify, getPosition, getVerticalAlignment, isVisible, notifyListeners, removeChangeListener, setHorizontalAlignment, setNotify, setPosition, setVerticalAlignment, setVisible
-
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
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.chart.block.Block
arrange, getBounds, getID, setBounds, setID
-
Methods inherited from interface org.jfree.chart.util.PublicCloneable
clone
-
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
scale
private PaintScale scale
The paint scale (nevernull).
-
axis
private ValueAxis axis
The value axis (nevernull).
-
axisLocation
private AxisLocation axisLocation
The axis location (handles both orientations, nevernull).
-
axisOffset
private double axisOffset
The offset between the axis and the paint strip (in Java2D units).
-
stripWidth
private double stripWidth
The thickness of the paint strip (in Java2D units).
-
stripOutlineVisible
private boolean stripOutlineVisible
A flag that controls whether or not an outline is drawn around the paint strip.
-
stripOutlinePaint
private transient java.awt.Paint stripOutlinePaint
The paint used to draw an outline around the paint strip.
-
stripOutlineStroke
private transient java.awt.Stroke stripOutlineStroke
The stroke used to draw an outline around the paint strip.
-
backgroundPaint
private transient java.awt.Paint backgroundPaint
The background paint (nevernull).
-
subdivisions
private int subdivisions
The number of subdivisions for the scale when rendering.
-
-
Constructor Detail
-
PaintScaleLegend
public PaintScaleLegend(PaintScale scale, ValueAxis axis)
Creates a new instance.- Parameters:
scale- the scale (nullnot permitted).axis- the axis (nullnot permitted).
-
-
Method Detail
-
getScale
public PaintScale getScale()
Returns the scale used to convert values to colors.- Returns:
- The scale (never
null). - See Also:
setScale(PaintScale)
-
setScale
public void setScale(PaintScale scale)
Sets the scale and sends aTitleChangeEventto all registered listeners.- Parameters:
scale- the scale (nullnot permitted).- See Also:
getScale()
-
getAxis
public ValueAxis getAxis()
Returns the axis for the paint scale.- Returns:
- The axis (never
null). - See Also:
setAxis(ValueAxis)
-
setAxis
public void setAxis(ValueAxis axis)
Sets the axis for the paint scale and sends aTitleChangeEventto all registered listeners.- Parameters:
axis- the axis (nullnot permitted).- See Also:
getAxis()
-
getAxisLocation
public AxisLocation getAxisLocation()
Returns the axis location.- Returns:
- The axis location (never
null). - See Also:
setAxisLocation(AxisLocation)
-
setAxisLocation
public void setAxisLocation(AxisLocation location)
Sets the axis location and sends aTitleChangeEventto all registered listeners.- Parameters:
location- the location (nullnot permitted).- See Also:
getAxisLocation()
-
getAxisOffset
public double getAxisOffset()
Returns the offset between the axis and the paint strip.- Returns:
- The offset between the axis and the paint strip.
- See Also:
setAxisOffset(double)
-
setAxisOffset
public void setAxisOffset(double offset)
Sets the offset between the axis and the paint strip and sends aTitleChangeEventto all registered listeners.- Parameters:
offset- the offset.
-
getStripWidth
public double getStripWidth()
Returns the width of the paint strip, in Java2D units.- Returns:
- The width of the paint strip.
- See Also:
setStripWidth(double)
-
setStripWidth
public void setStripWidth(double width)
Sets the width of the paint strip and sends aTitleChangeEventto all registered listeners.- Parameters:
width- the width.- See Also:
getStripWidth()
-
isStripOutlineVisible
public boolean isStripOutlineVisible()
Returns the flag that controls whether or not an outline is drawn around the paint strip.- Returns:
- A boolean.
- See Also:
setStripOutlineVisible(boolean)
-
setStripOutlineVisible
public void setStripOutlineVisible(boolean visible)
Sets the flag that controls whether or not an outline is drawn around the paint strip, and sends aTitleChangeEventto all registered listeners.- Parameters:
visible- the flag.- See Also:
isStripOutlineVisible()
-
getStripOutlinePaint
public java.awt.Paint getStripOutlinePaint()
Returns the paint used to draw the outline of the paint strip.- Returns:
- The paint (never
null). - See Also:
setStripOutlinePaint(Paint)
-
setStripOutlinePaint
public void setStripOutlinePaint(java.awt.Paint paint)
Sets the paint used to draw the outline of the paint strip, and sends aTitleChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getStripOutlinePaint()
-
getStripOutlineStroke
public java.awt.Stroke getStripOutlineStroke()
Returns the stroke used to draw the outline around the paint strip.- Returns:
- The stroke (never
null). - See Also:
setStripOutlineStroke(Stroke)
-
setStripOutlineStroke
public void setStripOutlineStroke(java.awt.Stroke stroke)
Sets the stroke used to draw the outline around the paint strip and sends aTitleChangeEventto all registered listeners.- Parameters:
stroke- the stroke (nullnot permitted).- See Also:
getStripOutlineStroke()
-
getBackgroundPaint
public java.awt.Paint getBackgroundPaint()
Returns the background paint.- Returns:
- The background paint.
-
setBackgroundPaint
public void setBackgroundPaint(java.awt.Paint paint)
Sets the background paint and sends aTitleChangeEventto all registered listeners.- Parameters:
paint- the paint (nullpermitted).
-
getSubdivisionCount
public int getSubdivisionCount()
Returns the number of subdivisions used to draw the scale.- Returns:
- The subdivision count.
-
setSubdivisionCount
public void setSubdivisionCount(int count)
Sets the subdivision count and sends aTitleChangeEventto all registered listeners.- Parameters:
count- the count.
-
axisChanged
public void axisChanged(AxisChangeEvent event)
Receives notification of an axis change event and responds by firing a title change event.- Specified by:
axisChangedin interfaceAxisChangeListener- Parameters:
event- the event.
-
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:
arrangein interfaceBlock- Overrides:
arrangein classAbstractBlock- Parameters:
g2- the graphics device.constraint- the constraint (nullnot permitted).- Returns:
- The block size (in Java2D units, never
null).
-
arrangeRR
protected Size2D arrangeRR(java.awt.Graphics2D g2, Range widthRange, Range heightRange)
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
public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area)Draws the legend within the specified area.
-
draw
public java.lang.Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params)Draws the legend within the specified area.
-
equals
public boolean equals(java.lang.Object obj)
Tests this legend for equality with an arbitrary object.
-
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.
-
hashCode
public int hashCode()
Description copied from class:TitleReturns a hashcode for the title.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionProvides 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.ClassNotFoundExceptionProvides 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.
-
-