Class LiteralAxis

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.jfree.util.PublicCloneable

    public class LiteralAxis
    extends org.jfree.chart.axis.NumberAxis
    A standard linear value axis that replaces integer values with symbols.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.awt.Paint DEFAULT_GRID_BAND_ALTERNATE_PAINT
      The default paint for alternate grid bands.
      static java.awt.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_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
    • Constructor Summary

      Constructors 
      Constructor Description
      LiteralAxis​(java.lang.String label, DataManager<?> manager, int[] literalIndices)
      Constructs a symbol axis, using default attribute values where necessary.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void autoAdjustRange()
      Rescales the axis to ensure that all data is visible.
      org.jfree.chart.axis.AxisState draw​(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge, org.jfree.chart.plot.PlotRenderingInfo plotState)
      Draws the axis on a Java 2D graphics device (such as the screen or a printer).
      protected void drawGridBands​(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge, java.util.List ticks)
      Draws the grid bands.
      protected void drawGridBandsHorizontal​(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, boolean firstGridBandIsDark, java.util.List ticks)
      Draws the grid bands for the axis when it is at the top or bottom of the plot.
      protected void drawGridBandsVertical​(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, boolean firstGridBandIsDark, java.util.List ticks)
      Draws the grid bands for an axis that is aligned to the left or right of the data area (that is, a vertical axis).
      java.awt.Paint getGridBandAlternatePaint()
      Returns the paint used for alternate grid bands.
      java.awt.Paint getGridBandPaint()
      Returns the paint used to color the grid bands.
      boolean isGridBandsVisible()
      Returns true if the grid bands are showing, and false otherwise.
      java.util.List refreshTicks​(java.awt.Graphics2D g2, org.jfree.chart.axis.AxisState state, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
      Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
      protected java.util.List refreshTicksHorizontal​(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
      Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for drawing).
      protected java.util.List refreshTicksVertical​(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.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 dataArea, org.jfree.ui.RectangleEdge edge)
      This operation is not supported by this axis.
      protected void selectHorizontalAutoTickUnit​(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
      Selects an appropriate tick value for the axis.
      protected void selectVerticalAutoTickUnit​(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)
      Selects an appropriate tick value for the axis.
      void setGridBandAlternatePaint​(java.awt.Paint paint)
      Sets the paint used for alternate grid bands and sends a AxisChangeEvent to all registered listeners.
      void setGridBandPaint​(java.awt.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.
      void setLiteralIndices​(int[] literalIndices)  
      java.lang.String valueToString​(double value)
      Converts a value to a string, using the list of symbols.
      • Methods inherited from class org.jfree.chart.axis.NumberAxis

        calculateHighestVisibleTickValue, calculateLowestVisibleTickValue, calculateVisibleTickCount, clone, configure, createIntegerTickUnits, createIntegerTickUnits, createStandardTickUnits, createStandardTickUnits, equals, estimateMaximumTickLabelHeight, estimateMaximumTickLabelWidth, getAutoRangeIncludesZero, getAutoRangeStickyZero, getMarkerBand, getNumberFormatOverride, getRangeType, getTickUnit, hashCode, java2DToValue, 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, getDefaultAutoRange, getDownArrow, getFixedAutoRange, getLeftArrow, getLowerBound, getLowerMargin, getMinorTickCount, getRange, getRightArrow, getStandardTickUnits, getUpArrow, getUpperBound, getUpperMargin, isAutoRange, isAutoTickUnitSelection, isInverted, isNegativeArrowVisible, isPositiveArrowVisible, isVerticalTickLabels, lengthToJava2D, pan, reserveSpace, resizeRange, resizeRange, resizeRange2, setAutoRange, setAutoRange, setAutoRangeMinimumSize, setAutoRangeMinimumSize, setAutoTickIndex, setAutoTickUnitSelection, setAutoTickUnitSelection, setDefaultAutoRange, setDownArrow, setFixedAutoRange, setInverted, setLeftArrow, setLowerBound, setLowerMargin, setMinorTickCount, 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, createAndAddEntity, createAttributedLabel, drawAttributedLabel, drawLabel, fireChangeEvent, getAttributedLabel, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelEnclosure, getLabelFont, getLabelInsets, getLabelLocation, getLabelPaint, getMinorTickMarkInsideLength, getMinorTickMarkOutsideLength, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, hasListener, isAxisLineVisible, isMinorTickMarksVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, labelAnchorH, labelAnchorV, labelLocationX, labelLocationY, notifyListeners, removeChangeListener, setAttributedLabel, setAttributedLabel, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelInsets, setLabelLocation, setLabelPaint, setMinorTickMarkInsideLength, setMinorTickMarkOutsideLength, setMinorTickMarksVisible, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_GRID_BAND_PAINT

        public static final java.awt.Paint DEFAULT_GRID_BAND_PAINT
        The default grid band paint.
      • DEFAULT_GRID_BAND_ALTERNATE_PAINT

        public static final java.awt.Paint DEFAULT_GRID_BAND_ALTERNATE_PAINT
        The default paint for alternate grid bands.
        Since:
        1.0.7
    • Constructor Detail

      • LiteralAxis

        public LiteralAxis​(java.lang.String label,
                           DataManager<?> manager,
                           int[] literalIndices)
        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 Detail

      • 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.
        See Also:
        setGridBandsVisible(boolean)
      • 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.
        See Also:
        isGridBandsVisible()
      • setGridBandPaint

        public void setGridBandPaint​(java.awt.Paint paint)
        Sets the grid band paint and sends an AxisChangeEvent to all registered listeners.
        Parameters:
        paint - the paint (null not permitted).
        See Also:
        getGridBandPaint()
      • setGridBandAlternatePaint

        public void setGridBandAlternatePaint​(java.awt.Paint paint)
        Sets the paint used for alternate grid bands and sends a AxisChangeEvent to all registered listeners.
        Parameters:
        paint - the paint (null not permitted).
        Since:
        1.0.7
        See Also:
        getGridBandAlternatePaint(), setGridBandPaint(Paint)
      • selectAutoTickUnit

        protected void selectAutoTickUnit​(java.awt.Graphics2D g2,
                                          java.awt.geom.Rectangle2D dataArea,
                                          org.jfree.ui.RectangleEdge edge)
        This operation is not supported by this axis.
        Overrides:
        selectAutoTickUnit in class org.jfree.chart.axis.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.
      • selectHorizontalAutoTickUnit

        protected void selectHorizontalAutoTickUnit​(java.awt.Graphics2D g2,
                                                    java.awt.geom.Rectangle2D dataArea,
                                                    org.jfree.ui.RectangleEdge edge)
        Selects an appropriate tick value for the axis. The strategy is to display as many ticks as possible (selected from an array of 'standard' tick units) without the labels overlapping.
        Overrides:
        selectHorizontalAutoTickUnit in class org.jfree.chart.axis.NumberAxis
        Parameters:
        g2 - the graphics device.
        dataArea - the area defined by the axes.
        edge - the axis location.
      • selectVerticalAutoTickUnit

        protected void selectVerticalAutoTickUnit​(java.awt.Graphics2D g2,
                                                  java.awt.geom.Rectangle2D dataArea,
                                                  org.jfree.ui.RectangleEdge edge)
        Selects an appropriate tick value for the axis. The strategy is to display as many ticks as possible (selected from an array of 'standard' tick units) without the labels overlapping.
        Overrides:
        selectVerticalAutoTickUnit in class org.jfree.chart.axis.NumberAxis
        Parameters:
        g2 - the graphics device.
        dataArea - the area in which the plot should be drawn.
        edge - the axis location.
      • draw

        public org.jfree.chart.axis.AxisState draw​(java.awt.Graphics2D g2,
                                                   double cursor,
                                                   java.awt.geom.Rectangle2D plotArea,
                                                   java.awt.geom.Rectangle2D dataArea,
                                                   org.jfree.ui.RectangleEdge edge,
                                                   org.jfree.chart.plot.PlotRenderingInfo plotState)
        Draws the axis on a Java 2D graphics device (such as the screen or a printer).
        Overrides:
        draw in class org.jfree.chart.axis.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​(java.awt.Graphics2D g2,
                                     java.awt.geom.Rectangle2D plotArea,
                                     java.awt.geom.Rectangle2D dataArea,
                                     org.jfree.ui.RectangleEdge edge,
                                     java.util.List ticks)
        Draws the grid bands. Alternate bands are colored using gridBandPaint (DEFAULT_GRID_BAND_PAINT by default).
        Parameters:
        g2 - the graphics target (null not permitted).
        plotArea - the area within which the plot is drawn (null not permitted).
        dataArea - the data area to which the axes are aligned (null not permitted).
        edge - the edge to which the axis is aligned (null not permitted).
        ticks - the ticks (null not permitted).
      • drawGridBandsHorizontal

        protected void drawGridBandsHorizontal​(java.awt.Graphics2D g2,
                                               java.awt.geom.Rectangle2D plotArea,
                                               java.awt.geom.Rectangle2D dataArea,
                                               boolean firstGridBandIsDark,
                                               java.util.List ticks)
        Draws the grid bands for the axis when it is at the top or bottom of the plot.
        Parameters:
        g2 - the graphics target (null not permitted).
        plotArea - the area within which the plot is drawn (not used here).
        dataArea - the area for the data (to which the axes are aligned, null not permitted).
        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 (null not permitted).
      • drawGridBandsVertical

        protected void drawGridBandsVertical​(java.awt.Graphics2D g2,
                                             java.awt.geom.Rectangle2D plotArea,
                                             java.awt.geom.Rectangle2D dataArea,
                                             boolean firstGridBandIsDark,
                                             java.util.List ticks)
        Draws the grid bands for an axis that is aligned to the left or right of the data area (that is, a vertical axis).
        Parameters:
        g2 - the graphics target (null not permitted).
        plotArea - the area within which the plot is drawn (not used here).
        dataArea - the area for the data (to which the axes are aligned, null not permitted).
        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 (null not permitted).
      • autoAdjustRange

        protected void autoAdjustRange()
        Rescales the axis to ensure that all data is visible.
        Overrides:
        autoAdjustRange in class org.jfree.chart.axis.NumberAxis
      • refreshTicks

        public java.util.List refreshTicks​(java.awt.Graphics2D g2,
                                           org.jfree.chart.axis.AxisState state,
                                           java.awt.geom.Rectangle2D dataArea,
                                           org.jfree.ui.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 org.jfree.chart.axis.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 java.util.List refreshTicksHorizontal​(java.awt.Graphics2D g2,
                                                        java.awt.geom.Rectangle2D dataArea,
                                                        org.jfree.ui.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 class org.jfree.chart.axis.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 java.util.List refreshTicksVertical​(java.awt.Graphics2D g2,
                                                      java.awt.geom.Rectangle2D dataArea,
                                                      org.jfree.ui.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 class org.jfree.chart.axis.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.
      • valueToString

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

        public void setLiteralIndices​(int[] literalIndices)