org.jfree.chart.axis
Class SymbolicAxis

java.lang.Object
  extended byorg.jfree.chart.axis.Axis
      extended byorg.jfree.chart.axis.ValueAxis
          extended byorg.jfree.chart.axis.NumberAxis
              extended byorg.jfree.chart.axis.SymbolicAxis
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class SymbolicAxis
extends NumberAxis
implements java.io.Serializable

A standard linear value axis, for SYMBOLIC values.

Author:
Anthony Boulestreau
See Also:
Serialized Form

Field Summary
static java.awt.Paint DEFAULT_SYMBOLIC_GRID_LINE_PAINT
          The default symbolic grid line 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_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_LABELS_VISIBLE, DEFAULT_TICK_MARK_INSIDE_LENGTH, DEFAULT_TICK_MARK_OUTSIDE_LENGTH, DEFAULT_TICK_MARK_PAINT, DEFAULT_TICK_MARK_STROKE, DEFAULT_TICK_MARKS_VISIBLE, LOGGER
 
Constructor Summary
SymbolicAxis(java.lang.String label, java.lang.String[] sv)
          Constructs a symbolic axis, using default attribute values where necessary.
 
Method Summary
protected  void autoAdjustRange()
          Rescales the axis to ensure that all data is visible.
 AxisState draw(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState)
          Draws the axis on a Java 2D graphics device (such as the screen or a printer).
 void drawSymbolicGridLines(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge, java.util.List ticks)
          Draws the symbolic grid lines.
 void drawSymbolicGridLinesHorizontal(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, boolean firstGridLineIsDark, java.util.List ticks)
          Draws the symbolic grid lines.
 void drawSymbolicGridLinesVertical(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D plotArea, boolean firstGridLineIsDark, java.util.List ticks)
          Draws the symbolic grid lines.
 java.awt.geom.Rectangle2D.Double getSymbolicGridLine(int position)
          Get the symbolic grid line corresponding to the specified position.
 java.awt.Paint getSymbolicGridPaint()
          Returns the symbolic grid line color.
 java.lang.String[] getSymbolicValue()
          Returns the list of the symbolic values to display.
 boolean isGridLinesVisible()
          Returns true if the symbolic grid lines are showing, and false otherwise.
 java.util.List refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D plotArea, java.awt.geom.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).
 java.util.List refreshTicksHorizontal(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.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).
 java.util.List refreshTicksVertical(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.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(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D plotArea)
          This operation is not supported by the symbolic values.
 void setSymbolicGridLinesVisible(boolean flag)
          Sets the visibility of the symbolic grid lines and notifies registered listeners that the axis has been modified.
 java.lang.String valueToString(double value)
          Converts a value to a string, using the list of symbolic values.
 
Methods inherited from class org.jfree.chart.axis.NumberAxis
autoRangeIncludesZero, autoRangeStickyZero, calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, clone, configure, createIntegerTickUnits, createIntegerTickUnits, createStandardTickUnits, createStandardTickUnits, equals, estimateMaximumTickLabelHeight, estimateMaximumTickLabelWidth, getMarkerBand, getNumberFormatOverride, getRangeType, getTickUnit, java2DToValue, refreshHorizontalTicks, refreshVerticalTicks, selectAutoTickUnit, selectHorizontalAutoTickUnit, selectVerticalAutoTickUnit, setAutoRangeIncludesZero, setAutoRangeStickyZero, setMarkerBand, setNumberFormatOverride, setRangeType, setTickUnit, setTickUnit, valueToJava2D
 
Methods inherited from class org.jfree.chart.axis.ValueAxis
calculateAnchorPoint, centerRange, drawAxisLine, drawTickMarksAndLabels, findMaximumTickLabelHeight, findMaximumTickLabelWidth, getAutoRangeMinimumSize, getAutoTickIndex, getDownArrow, getFixedAutoRange, getLeftArrow, getLowerBound, getLowerMargin, getRange, getRightArrow, getStandardTickUnits, getUpArrow, getUpperBound, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, isNegativeArrowVisible, isPositiveArrowVisible, isVerticalTickLabels, lengthToJava2D, reserveSpace, resizeRange, resizeRange, setAutoRange, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setDownArrow, setFixedAutoRange, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setNegativeArrowVisible, setPositiveArrowVisible, setRange, setRange, setRange, setRangeAboutValue, setRangeWithMargins, setRangeWithMargins, setRangeWithMargins, setRightArrow, setStandardTickUnits, setUpArrow, setUpperBound, setUpperMargin, setVerticalTickLabels, zoomRange
 
Methods inherited from class org.jfree.chart.axis.Axis
addChangeListener, drawLabel, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelEnclosure, getLabelFont, getLabelInsets, getLabelPaint, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, isAxisLineVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, removeChangeListener, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SYMBOLIC_GRID_LINE_PAINT

public static final java.awt.Paint DEFAULT_SYMBOLIC_GRID_LINE_PAINT
The default symbolic grid line paint.

Constructor Detail

SymbolicAxis

public SymbolicAxis(java.lang.String label,
                    java.lang.String[] sv)
Constructs a symbolic axis, using default attribute values where necessary.

Parameters:
label - the axis label (null permitted).
sv - the list of symbolic values to display instead of the numeric value.
Method Detail

getSymbolicValue

public java.lang.String[] getSymbolicValue()
Returns the list of the symbolic values to display.

Returns:
list of symbolic values.

getSymbolicGridPaint

public java.awt.Paint getSymbolicGridPaint()
Returns the symbolic grid line color.

Returns:
the grid line color.

isGridLinesVisible

public boolean isGridLinesVisible()
Returns true if the symbolic grid lines are showing, and false otherwise.

Returns:
true if the symbolic grid lines are showing, and false otherwise.

setSymbolicGridLinesVisible

public void setSymbolicGridLinesVisible(boolean flag)
Sets the visibility of the symbolic grid lines and notifies registered listeners that the axis has been modified.

Parameters:
flag - the new setting.

selectAutoTickUnit

protected void selectAutoTickUnit(java.awt.Graphics2D g2,
                                  java.awt.geom.Rectangle2D drawArea,
                                  java.awt.geom.Rectangle2D plotArea)
This operation is not supported by the symbolic values.

Parameters:
g2 - the graphics device.
drawArea - the area in which the plot and axes should be drawn.
plotArea - the area in which the plot should be drawn.

draw

public AxisState draw(java.awt.Graphics2D g2,
                      double cursor,
                      java.awt.geom.Rectangle2D plotArea,
                      java.awt.geom.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 class 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).

drawSymbolicGridLines

public void drawSymbolicGridLines(java.awt.Graphics2D g2,
                                  java.awt.geom.Rectangle2D plotArea,
                                  java.awt.geom.Rectangle2D dataArea,
                                  RectangleEdge edge,
                                  java.util.List ticks)
Draws the symbolic grid lines.

The colors are consecutively the color specified by symbolicGridPaint (DEFAULT_SYMBOLIC_GRID_LINE_PAINT by default) and white.

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.

drawSymbolicGridLinesHorizontal

public void drawSymbolicGridLinesHorizontal(java.awt.Graphics2D g2,
                                            java.awt.geom.Rectangle2D plotArea,
                                            java.awt.geom.Rectangle2D dataArea,
                                            boolean firstGridLineIsDark,
                                            java.util.List ticks)
Draws the symbolic grid lines.

The colors are consecutively the color specified by symbolicGridPaint (DEFAULT_SYMBOLIC_GRID_LINE_PAINT by default) and white. or if firstGridLineIsDark is true white and the color specified by symbolicGridPaint.

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).
firstGridLineIsDark - True: the first symbolic grid line take the color of symbolicGridPaint. False: the first symbolic grid line is white.
ticks - the ticks.

getSymbolicGridLine

public java.awt.geom.Rectangle2D.Double getSymbolicGridLine(int position)
Get the symbolic grid line corresponding to the specified position.

Parameters:
position - position of the grid line, startinf from 0.
Returns:
the symbolic grid line corresponding to the specified position.

autoAdjustRange

protected void autoAdjustRange()
Rescales the axis to ensure that all data is visible.

Overrides:
autoAdjustRange in class NumberAxis

refreshTicks

public java.util.List refreshTicks(java.awt.Graphics2D g2,
                                   AxisState state,
                                   java.awt.geom.Rectangle2D plotArea,
                                   java.awt.geom.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 class NumberAxis
Parameters:
g2 - the graphics device.
state - the axis state.
plotArea - the area in which the plot (inlcuding axes) should be drawn.
dataArea - the area in which the data should be drawn.
edge - the location of the axis.
Returns:
A list of ticks.

refreshTicksHorizontal

public java.util.List refreshTicksHorizontal(java.awt.Graphics2D g2,
                                             double cursor,
                                             java.awt.geom.Rectangle2D plotArea,
                                             java.awt.geom.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).

Parameters:
g2 - the graphics device.
cursor - the cursor position for drawing the axis.
plotArea - the area in which the plot (inlcuding axes) should be drawn.
dataArea - the area in which the data should be drawn.
edge - the location of the axis.
Returns:
The ticks.

refreshTicksVertical

public java.util.List refreshTicksVertical(java.awt.Graphics2D g2,
                                           double cursor,
                                           java.awt.geom.Rectangle2D plotArea,
                                           java.awt.geom.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).

Parameters:
g2 - the graphics device.
cursor - the cursor position for drawing the axis.
plotArea - the area in which the plot and the axes should be drawn.
dataArea - the area in which the plot should be drawn.
edge - the location of the axis.
Returns:
The ticks.

valueToString

public java.lang.String valueToString(double value)
Converts a value to a string, using the list of symbolic values.

Parameters:
value - value to convert.
Returns:
the symbolic value.

drawSymbolicGridLinesVertical

public void drawSymbolicGridLinesVertical(java.awt.Graphics2D g2,
                                          java.awt.geom.Rectangle2D drawArea,
                                          java.awt.geom.Rectangle2D plotArea,
                                          boolean firstGridLineIsDark,
                                          java.util.List ticks)
Draws the symbolic grid lines.

The colors are consecutively the color specified by symbolicGridPaint (DEFAULT_SYMBOLIC_GRID_LINE_PAINT by default) and white. or if firstGridLineIsDark is true white and the color specified by symbolicGridPaint.

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).
firstGridLineIsDark - True: the first symbolic grid line take the color of symbolicGridPaint. False: the first symbolic grid line is white.
ticks - a list of ticks.