org.jfree.chart.axis

Class SymbolAxis

Implemented Interfaces:
Cloneable, PublicCloneable, Serializable

public class SymbolAxis
extends NumberAxis
implements Serializable

A standard linear value axis that replaces integer values with symbols.

Field Summary

static Paint
DEFAULT_GRID_BAND_PAINT
The default grid band paint.

Fields inherited from class org.jfree.chart.axis.NumberAxis

DEFAULT_AUTO_RANGE_INCLUDES_ZERO, DEFAULT_AUTO_RANGE_STICKY_ZERO, DEFAULT_TICK_UNIT, DEFAULT_VERTICAL_TICK_LABELS

Fields inherited from class org.jfree.chart.axis.ValueAxis

DEFAULT_AUTO_RANGE, DEFAULT_AUTO_RANGE_MINIMUM_SIZE, DEFAULT_AUTO_TICK_UNIT_SELECTION, DEFAULT_INVERTED, DEFAULT_LOWER_BOUND, DEFAULT_LOWER_MARGIN, DEFAULT_RANGE, DEFAULT_UPPER_BOUND, DEFAULT_UPPER_MARGIN, MAXIMUM_TICK_COUNT

Fields inherited from class org.jfree.chart.axis.Axis

DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_AXIS_LINE_PAINT, DEFAULT_AXIS_LINE_STROKE, DEFAULT_AXIS_VISIBLE, DEFAULT_TICK_LABELS_VISIBLE, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_MARKS_VISIBLE, DEFAULT_TICK_MARK_INSIDE_LENGTH, DEFAULT_TICK_MARK_OUTSIDE_LENGTH, DEFAULT_TICK_MARK_PAINT, DEFAULT_TICK_MARK_STROKE

Constructor Summary

SymbolAxis(String label, String[] sv)
Constructs a symbol axis, using default attribute values where necessary.

Method Summary

protected void
autoAdjustRange()
Rescales the axis to ensure that all data is visible.
AxisState
draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState)
Draws the axis on a Java 2D graphics device (such as the screen or a printer).
protected void
drawGridBands(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, List ticks)
Draws the grid bands.
protected void
drawGridBandsHorizontal(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, boolean firstGridBandIsDark, List ticks)
Draws the grid bands for the axis when it is at the top or bottom of the plot.
protected void
drawGridBandsVertical(Graphics2D g2, Rectangle2D drawArea, Rectangle2D plotArea, boolean firstGridBandIsDark, List ticks)
Draws the grid bands for the axis when it is at the top or bottom of the plot.
boolean
equals(Object obj)
Tests this axis for equality with an arbitrary object.
Paint
getGridBandPaint()
Returns the paint used to color the grid bands.
String[]
getSymbols()
Returns an array of the symbols for the axis.
boolean
isGridBandsVisible()
Returns true if the grid bands are showing, and false otherwise.
List
refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
protected List
refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
protected List
refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
protected void
selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge)
This operation is not supported by this axis.
void
setGridBandPaint(Paint paint)
Sets the grid band paint and sends an AxisChangeEvent to all registered listeners.
void
setGridBandsVisible(boolean flag)
Sets the visibility of the grid bands and notifies registered listeners that the axis has been modified.
String
valueToString(double value)
Converts a value to a string, using the list of symbols.

Methods inherited from class org.jfree.chart.axis.NumberAxis

autoAdjustRange, calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, clone, configure, createIntegerTickUnits, createIntegerTickUnits, createStandardTickUnits, createStandardTickUnits, draw, equals, estimateMaximumTickLabelHeight, estimateMaximumTickLabelWidth, getAutoRangeIncludesZero, getAutoRangeStickyZero, getMarkerBand, getNumberFormatOverride, getRangeType, getTickUnit, hashCode, java2DToValue, refreshTicks, refreshTicksHorizontal, refreshTicksVertical, selectAutoTickUnit, selectHorizontalAutoTickUnit, selectVerticalAutoTickUnit, setAutoRangeIncludesZero, setAutoRangeStickyZero, setMarkerBand, setNumberFormatOverride, setRangeType, setTickUnit, setTickUnit, valueToJava2D

Methods inherited from class org.jfree.chart.axis.ValueAxis

autoAdjustRange, calculateAnchorPoint, centerRange, clone, drawAxisLine, drawTickMarksAndLabels, equals, findMaximumTickLabelHeight, findMaximumTickLabelWidth, getAutoRangeMinimumSize, getAutoTickIndex, getDefaultAutoRange, getDownArrow, getFixedAutoRange, getLeftArrow, getLowerBound, getLowerMargin, getRange, getRightArrow, getStandardTickUnits, getUpArrow, getUpperBound, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, isNegativeArrowVisible, isPositiveArrowVisible, isVerticalTickLabels, java2DToValue, lengthToJava2D, reserveSpace, resizeRange, resizeRange, setAutoRange, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setDefaultAutoRange, setDownArrow, setFixedAutoRange, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setNegativeArrowVisible, setPositiveArrowVisible, setRange, setRange, setRange, setRangeAboutValue, setRangeWithMargins, setRangeWithMargins, setRangeWithMargins, setRightArrow, setStandardTickUnits, setUpArrow, setUpperBound, setUpperMargin, setVerticalTickLabels, valueToJava2D, zoomRange

Methods inherited from class org.jfree.chart.axis.Axis

addChangeListener, clone, configure, draw, drawAxisLine, drawLabel, equals, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelEnclosure, getLabelFont, getLabelInsets, getLabelPaint, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, hasListener, isAxisLineVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, refreshTicks, removeChangeListener, reserveSpace, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible

Field Details

DEFAULT_GRID_BAND_PAINT

public static final Paint DEFAULT_GRID_BAND_PAINT
The default grid band paint.

Constructor Details

SymbolAxis

public SymbolAxis(String label,
                  String[] sv)
Constructs a symbol axis, using default attribute values where necessary.
Parameters:
label - the axis label (null permitted).
sv - the list of symbols to display instead of the numeric values.

Method Details

autoAdjustRange

protected void autoAdjustRange()
Rescales the axis to ensure that all data is visible.
Overrides:
autoAdjustRange in interface NumberAxis

draw

public AxisState draw(Graphics2D g2,
                      double cursor,
                      Rectangle2D plotArea,
                      Rectangle2D dataArea,
                      RectangleEdge edge,
                      PlotRenderingInfo plotState)
Draws the axis on a Java 2D graphics device (such as the screen or a printer).
Overrides:
draw in interface NumberAxis
Parameters:
g2 - the graphics device (null not permitted).
cursor - the cursor location.
plotArea - the area within which the plot and axes should be drawn (null not permitted).
dataArea - the area within which the data should be drawn (null not permitted).
edge - the axis location (null not permitted).
plotState - collects information about the plot (null permitted).
Returns:
The axis state (never null).

drawGridBands

protected void drawGridBands(Graphics2D g2,
                             Rectangle2D plotArea,
                             Rectangle2D dataArea,
                             RectangleEdge edge,
                             List ticks)
Draws the grid bands. Alternate bands are colored using gridBandPaint (DEFAULT_GRID_BAND_PAINT by default).
Parameters:
g2 - the graphics device.
plotArea - the area within which the chart should be drawn.
dataArea - the area within which the plot should be drawn (a subset of the drawArea).
edge - the axis location.
ticks - the ticks.

drawGridBandsHorizontal

protected void drawGridBandsHorizontal(Graphics2D g2,
                                       Rectangle2D plotArea,
                                       Rectangle2D dataArea,
                                       boolean firstGridBandIsDark,
                                       List ticks)
Draws the grid bands for the axis when it is at the top or bottom of the plot.
Parameters:
g2 - the graphics device.
plotArea - the area within which the chart should be drawn.
dataArea - the area within which the plot should be drawn (a subset of the drawArea).
firstGridBandIsDark - True: the first grid band takes the color of gridBandPaint. False: the second grid band takes the color of gridBandPaint.
ticks - the ticks.

drawGridBandsVertical

protected void drawGridBandsVertical(Graphics2D g2,
                                     Rectangle2D drawArea,
                                     Rectangle2D plotArea,
                                     boolean firstGridBandIsDark,
                                     List ticks)
Draws the grid bands for the axis when it is at the top or bottom of the plot.
Parameters:
g2 - the graphics device.
drawArea - the area within which the chart should be drawn.
plotArea - the area within which the plot should be drawn (a subset of the drawArea).
firstGridBandIsDark - True: the first grid band takes the color of gridBandPaint. False: the second grid band takes the color of gridBandPaint.
ticks - a list of ticks.

equals

public boolean equals(Object obj)
Tests this axis for equality with an arbitrary object.
Overrides:
equals in interface NumberAxis
Parameters:
obj - the object (null permitted).
Returns:
A boolean.

getGridBandPaint

public Paint getGridBandPaint()
Returns the paint used to color the grid bands.
Returns:
The grid band paint (never null).

getSymbols

public String[] getSymbols()
Returns an array of the symbols for the axis.
Returns:
The symbols.

isGridBandsVisible

public boolean isGridBandsVisible()
Returns true if the grid bands are showing, and false otherwise.
Returns:
true if the grid bands are showing, and false otherwise.

refreshTicks

public List refreshTicks(Graphics2D g2,
                         AxisState state,
                         Rectangle2D dataArea,
                         RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
Overrides:
refreshTicks in interface NumberAxis
Parameters:
g2 - the graphics device.
state - the axis state.
dataArea - the area in which the data should be drawn.
edge - the location of the axis.
Returns:
A list of ticks.

refreshTicksHorizontal

protected List refreshTicksHorizontal(Graphics2D g2,
                                      Rectangle2D dataArea,
                                      RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
Overrides:
refreshTicksHorizontal in interface NumberAxis
Parameters:
g2 - the graphics device.
dataArea - the area in which the data should be drawn.
edge - the location of the axis.
Returns:
The ticks.

refreshTicksVertical

protected List refreshTicksVertical(Graphics2D g2,
                                    Rectangle2D dataArea,
                                    RectangleEdge edge)
Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
Overrides:
refreshTicksVertical in interface NumberAxis
Parameters:
g2 - the graphics device.
dataArea - the area in which the plot should be drawn.
edge - the location of the axis.
Returns:
The ticks.

selectAutoTickUnit

protected void selectAutoTickUnit(Graphics2D g2,
                                  Rectangle2D dataArea,
                                  RectangleEdge edge)
This operation is not supported by this axis.
Overrides:
selectAutoTickUnit in interface NumberAxis
Parameters:
g2 - the graphics device.
dataArea - the area in which the plot and axes should be drawn.
edge - the edge along which the axis is drawn.

setGridBandPaint

public void setGridBandPaint(Paint paint)
Sets the grid band paint and sends an AxisChangeEvent to all registered listeners.
Parameters:
paint - the paint (null not permitted).

setGridBandsVisible

public void setGridBandsVisible(boolean flag)
Sets the visibility of the grid bands and notifies registered listeners that the axis has been modified.
Parameters:
flag - the new setting.

valueToString

public String valueToString(double value)
Converts a value to a string, using the list of symbols.
Parameters:
value - value to convert.
Returns:
The symbol.