## org.jfree.chart.axis
Class Axis

    java.lang.Object
      org.jfree.chart.axis.Axis

All Implemented Interfaces:
  java.lang.Cloneable, java.io.Serializable

Direct Known Subclasses:
  CategoryAxis, ValueAxis

public abstract class Axis
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

The base class for all axes in JFreeChart. Subclasses are divided into those that display values (`ValueAxis`) and those that display categories (`CategoryAxis`).

See Also:
  Serialized Form

Field Summary
`static java.awt.Font` `DEFAULT_AXIS_LABEL_FONT` The default axis label font.
`static java.awt.Insets` `DEFAULT_AXIS_LABEL_INSETS` The default axis label insets.
`static java.awt.Paint` `DEFAULT_AXIS_LABEL_PAINT` The default axis label paint.
`static java.awt.Paint` `DEFAULT_AXIS_LINE_PAINT` The default axis line paint.
`static java.awt.Stroke` `DEFAULT_AXIS_LINE_STROKE` The default axis line stroke.
`static boolean` `DEFAULT_AXIS_VISIBLE` The default axis visibility.
`static java.awt.Font` `DEFAULT_TICK_LABEL_FONT` The default tick label font.
`static java.awt.Insets` `DEFAULT_TICK_LABEL_INSETS` The default tick label insets.
`static java.awt.Paint` `DEFAULT_TICK_LABEL_PAINT` The default tick label paint.
`static boolean` `DEFAULT_TICK_LABELS_VISIBLE` The default tick labels visibility.
`static float` `DEFAULT_TICK_MARK_INSIDE_LENGTH` The default tick mark inside length.
`static float` `DEFAULT_TICK_MARK_OUTSIDE_LENGTH` The default tick mark outside length.
`static java.awt.Paint` `DEFAULT_TICK_MARK_PAINT` The default tick paint.
`static java.awt.Stroke` `DEFAULT_TICK_MARK_STROKE` The default tick stroke.
`static boolean` `DEFAULT_TICK_MARKS_VISIBLE` The default tick marks visible.
`protected static org.jfree.util.LogContext` `LOGGER` Access to logging facilities.

Constructor Summary
`protected` `Axis(java.lang.String label)` Constructs an axis, using default values where necessary.

Method Summary
`void` `addChangeListener(AxisChangeListener listener)` Registers an object for notification of changes to the axis.
`java.lang.Object` `clone()` Returns a clone of the axis.
`abstract void` `configure()` Configures the axis to work with the current plot.
`abstract AxisState` `draw(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge, PlotRenderingInfo plotState)` Draws the axis on a Java 2D graphics device (such as the screen or a printer).
`protected void` `drawAxisLine(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)` Draws an axis line at the current cursor position and edge.
`protected AxisState` `drawLabel(java.lang.String label, java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge, AxisState state)` Draws the axis label.
`boolean` `equals(java.lang.Object obj)` Tests this axis for equality with another object.
`java.awt.Paint` `getAxisLinePaint()` Returns the paint used to draw the axis line.
`java.awt.Stroke` `getAxisLineStroke()` Returns the stroke used to draw the axis line.
`double` `getFixedDimension()` Returns the fixed dimension for the axis.
`java.lang.String` `getLabel()` Returns the label for the axis.
`double` `getLabelAngle()` Returns the angle of the axis label.
`protected java.awt.geom.Rectangle2D` `getLabelEnclosure(java.awt.Graphics2D g2, org.jfree.ui.RectangleEdge edge)` Returns a rectangle that encloses the axis label.
`java.awt.Font` `getLabelFont()` Returns the font for the axis label.
`java.awt.Insets` `getLabelInsets()` Returns the insets for the label (that is, the amount of blank space that should be left around the label).
`java.awt.Paint` `getLabelPaint()` Returns the color/shade used to draw the axis label.
`Plot` `getPlot()` Returns the plot that the axis is assigned to.
`java.awt.Font` `getTickLabelFont()` Returns the font used for the tick labels (if showing).
`java.awt.Insets` `getTickLabelInsets()` Returns the insets for the tick labels.
`java.awt.Paint` `getTickLabelPaint()` Returns the color/shade used for the tick labels.
`float` `getTickMarkInsideLength()` Returns the inside length of the tick marks.
`float` `getTickMarkOutsideLength()` Returns the outside length of the tick marks.
`java.awt.Paint` `getTickMarkPaint()` Returns the paint used to draw tick marks (if they are showing).
`java.awt.Stroke` `getTickMarkStroke()` Returns the pen/brush used to draw tick marks (if they are showing).
`boolean` `isAxisLineVisible()` A flag that controls whether or not the axis line is drawn.
`boolean` `isTickLabelsVisible()` Returns a flag indicating whether or not the tick labels are visible.
`boolean` `isTickMarksVisible()` Returns the flag that indicates whether or not the tick marks are showing.
`boolean` `isVisible()` Returns `true` if the axis is visible, and `false` otherwise.
`protected void` `notifyListeners(AxisChangeEvent event)` Notifies all registered listeners that the axis has changed.
`abstract java.util.List` `refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge)` Calculates the positions of the ticks for the axis, storing the results in the tick list (ready for drawing).
`void` `removeChangeListener(AxisChangeListener listener)` Deregisters an object for notification of changes to the axis.
`abstract AxisSpace` `reserveSpace(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D plotArea, org.jfree.ui.RectangleEdge edge, AxisSpace space)` Estimates the space (height or width) required to draw the axis.
`void` `setAxisLinePaint(java.awt.Paint paint)` Sets the paint used to draw the axis line and sends an `AxisChangeEvent` to all registered listeners.
`void` `setAxisLineStroke(java.awt.Stroke stroke)` Sets the stroke used to draw the axis line and sends an `AxisChangeEvent` to all registered listeners.
`void` `setAxisLineVisible(boolean visible)` Sets a flag that controls whether or not the axis line is visible and sends an `AxisChangeEvent` to all registered listeners.
`void` `setFixedDimension(double dimension)` Sets the fixed dimension for the axis.
`void` `setLabel(java.lang.String label)` Sets the label for the axis and sends an `AxisChangeEvent` to all registered listeners.
`void` `setLabelAngle(double angle)` Sets the angle for the label and sends an `AxisChangeEvent` to all registered listeners.
`void` `setLabelFont(java.awt.Font font)` Sets the font for the axis label and sends an `AxisChangeEvent` to all registered listeners.
`void` `setLabelInsets(java.awt.Insets insets)` Sets the insets for the axis label, and sends an `AxisChangeEvent` to all registered listeners.
`void` `setLabelPaint(java.awt.Paint paint)` Sets the paint used to draw the axis label and sends an `AxisChangeEvent` to all registered listeners.
`void` `setPlot(Plot plot)` Sets a reference to the plot that the axis is assigned to.
`void` `setTickLabelFont(java.awt.Font font)` Sets the font for the tick labels and sends an `AxisChangeEvent` to all registered listeners.
`void` `setTickLabelInsets(java.awt.Insets insets)` Sets the insets for the tick labels and sends an `AxisChangeEvent` to all registered listeners.
`void` `setTickLabelPaint(java.awt.Paint paint)` Sets the paint used to draw tick labels (if they are showing) and sends an `AxisChangeEvent` to all registered listeners.
`void` `setTickLabelsVisible(boolean flag)` Sets the flag that determines whether or not the tick labels are visible and sends an `AxisChangeEvent` to all registered listeners.
`void` `setTickMarkInsideLength(float length)` Sets the inside length of the tick marks and sends an `AxisChangeEvent` to all registered listeners.
`void` `setTickMarkOutsideLength(float length)` Sets the outside length of the tick marks and sends an `AxisChangeEvent` to all registered listeners.
`void` `setTickMarkPaint(java.awt.Paint paint)` Sets the paint used to draw tick marks (if they are showing).
`void` `setTickMarkStroke(java.awt.Stroke stroke)` Sets the pen/brush used to draw tick marks (if they are showing) and sends an `AxisChangeEvent` to all registered listeners.
`void` `setTickMarksVisible(boolean flag)` Sets the flag that indicates whether or not the tick marks are showing and sends an `AxisChangeEvent` to all registered listeners.
`void` `setVisible(boolean flag)` Sets a flag that controls whether or not the axis is visible and sends an `AxisChangeEvent` to all registered listeners.

Methods inherited from class java.lang.Object
`finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_AXIS_VISIBLE

    public static final boolean DEFAULT_AXIS_VISIBLE

  The default axis visibility.

  See Also:
    Constant Field Values

### DEFAULT_AXIS_LABEL_FONT

    public static final java.awt.Font DEFAULT_AXIS_LABEL_FONT

  The default axis label font.

### DEFAULT_AXIS_LABEL_PAINT

    public static final java.awt.Paint DEFAULT_AXIS_LABEL_PAINT

  The default axis label paint.

### DEFAULT_AXIS_LABEL_INSETS

    public static final java.awt.Insets DEFAULT_AXIS_LABEL_INSETS

  The default axis label insets.

### DEFAULT_AXIS_LINE_PAINT

    public static final java.awt.Paint DEFAULT_AXIS_LINE_PAINT

  The default axis line paint.

### DEFAULT_AXIS_LINE_STROKE

    public static final java.awt.Stroke DEFAULT_AXIS_LINE_STROKE

  The default axis line stroke.

### DEFAULT_TICK_LABELS_VISIBLE

    public static final boolean DEFAULT_TICK_LABELS_VISIBLE

  The default tick labels visibility.

  See Also:
    Constant Field Values

### DEFAULT_TICK_LABEL_FONT

    public static final java.awt.Font DEFAULT_TICK_LABEL_FONT

  The default tick label font.

### DEFAULT_TICK_LABEL_PAINT

    public static final java.awt.Paint DEFAULT_TICK_LABEL_PAINT

  The default tick label paint.

### DEFAULT_TICK_LABEL_INSETS

    public static final java.awt.Insets DEFAULT_TICK_LABEL_INSETS

  The default tick label insets.

### DEFAULT_TICK_MARKS_VISIBLE

    public static final boolean DEFAULT_TICK_MARKS_VISIBLE

  The default tick marks visible.

  See Also:
    Constant Field Values

### DEFAULT_TICK_MARK_STROKE

    public static final java.awt.Stroke DEFAULT_TICK_MARK_STROKE

  The default tick stroke.

### DEFAULT_TICK_MARK_PAINT

    public static final java.awt.Paint DEFAULT_TICK_MARK_PAINT

  The default tick paint.

### DEFAULT_TICK_MARK_INSIDE_LENGTH

    public static final float DEFAULT_TICK_MARK_INSIDE_LENGTH

  The default tick mark inside length.

  See Also:
    Constant Field Values

### DEFAULT_TICK_MARK_OUTSIDE_LENGTH

    public static final float DEFAULT_TICK_MARK_OUTSIDE_LENGTH

  The default tick mark outside length.

  See Also:
    Constant Field Values

### LOGGER

    protected static final org.jfree.util.LogContext LOGGER

  Access to logging facilities.

Constructor Detail

### Axis

    protected Axis(java.lang.String label)

  Constructs an axis, using default values where necessary.

Parameters:
  `label` - the axis label (`null` permitted).

Method Detail

### isVisible

    public boolean isVisible()

  Returns `true` if the axis is visible, and `false` otherwise.

  Returns:
    A boolean.

### setVisible

    public void setVisible(boolean flag)

  Sets a flag that controls whether or not the axis is visible and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `flag` - the flag.

### getLabel

    public java.lang.String getLabel()

  Returns the label for the axis.

  Returns:
    The label for the axis (`null` possible).

### setLabel

    public void setLabel(java.lang.String label)

  Sets the label for the axis and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `label` - the new label (`null` permitted).

### getLabelFont

    public java.awt.Font getLabelFont()

  Returns the font for the axis label.

  Returns:
    The font.

### setLabelFont

    public void setLabelFont(java.awt.Font font)

  Sets the font for the axis label and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `font` - the font (`null` not permitted).

### getLabelPaint

    public java.awt.Paint getLabelPaint()

  Returns the color/shade used to draw the axis label.

  Returns:
    The paint (never `null`).

### setLabelPaint

    public void setLabelPaint(java.awt.Paint paint)

  Sets the paint used to draw the axis label and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `paint` - the paint (`null` not permitted).

### getLabelInsets

    public java.awt.Insets getLabelInsets()

  Returns the insets for the label (that is, the amount of blank space that should be left around the label).

  Returns:
    The label insets (never `null`).

### setLabelInsets

    public void setLabelInsets(java.awt.Insets insets)

  Sets the insets for the axis label, and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `insets` - the insets (`null` not permitted).

### getLabelAngle

    public double getLabelAngle()

  Returns the angle of the axis label.

  Returns:
    The angle (in radians).

### setLabelAngle

    public void setLabelAngle(double angle)

  Sets the angle for the label and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `angle` - the angle (in radians).

### isAxisLineVisible

    public boolean isAxisLineVisible()

  A flag that controls whether or not the axis line is drawn.

  Returns:
    A boolean.

### setAxisLineVisible

    public void setAxisLineVisible(boolean visible)

  Sets a flag that controls whether or not the axis line is visible and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `visible` - the flag.

### getAxisLinePaint

    public java.awt.Paint getAxisLinePaint()

  Returns the paint used to draw the axis line.

  Returns:
    The paint (never `null`).

### setAxisLinePaint

    public void setAxisLinePaint(java.awt.Paint paint)

  Sets the paint used to draw the axis line and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `paint` - the paint (`null` not permitted).

### getAxisLineStroke

    public java.awt.Stroke getAxisLineStroke()

  Returns the stroke used to draw the axis line.

  Returns:
    The stroke (never `null`).

### setAxisLineStroke

    public void setAxisLineStroke(java.awt.Stroke stroke)

  Sets the stroke used to draw the axis line and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `stroke` - the stroke (`null` not permitted).

### isTickLabelsVisible

    public boolean isTickLabelsVisible()

  Returns a flag indicating whether or not the tick labels are visible.

  Returns:
    The flag.

### setTickLabelsVisible

    public void setTickLabelsVisible(boolean flag)

  Sets the flag that determines whether or not the tick labels are visible and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `flag` - the flag.

### getTickLabelFont

    public java.awt.Font getTickLabelFont()

  Returns the font used for the tick labels (if showing).

  Returns:
    The font (never `null`).

### setTickLabelFont

    public void setTickLabelFont(java.awt.Font font)

  Sets the font for the tick labels and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `font` - the font (`null` not allowed).

### getTickLabelPaint

    public java.awt.Paint getTickLabelPaint()

  Returns the color/shade used for the tick labels.

  Returns:
    The paint used for the tick labels.

### setTickLabelPaint

    public void setTickLabelPaint(java.awt.Paint paint)

  Sets the paint used to draw tick labels (if they are showing) and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `paint` - the paint (`null` not permitted).

### getTickLabelInsets

    public java.awt.Insets getTickLabelInsets()

  Returns the insets for the tick labels.

  Returns:
    The insets (never `null`).

### setTickLabelInsets

    public void setTickLabelInsets(java.awt.Insets insets)

  Sets the insets for the tick labels and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `insets` - the insets (`null` not permitted).

### isTickMarksVisible

    public boolean isTickMarksVisible()

  Returns the flag that indicates whether or not the tick marks are showing.

  Returns:
    the flag that indicates whether or not the tick marks are showing.

### setTickMarksVisible

    public void setTickMarksVisible(boolean flag)

  Sets the flag that indicates whether or not the tick marks are showing and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `flag` - the flag.

### getTickMarkInsideLength

    public float getTickMarkInsideLength()

  Returns the inside length of the tick marks.

  Returns:
    The length.

### setTickMarkInsideLength

    public void setTickMarkInsideLength(float length)

  Sets the inside length of the tick marks and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `length` - the new length.

### getTickMarkOutsideLength

    public float getTickMarkOutsideLength()

  Returns the outside length of the tick marks.

  Returns:
    The length.

### setTickMarkOutsideLength

    public void setTickMarkOutsideLength(float length)

  Sets the outside length of the tick marks and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `length` - the new length.

### getTickMarkStroke

    public java.awt.Stroke getTickMarkStroke()

  Returns the pen/brush used to draw tick marks (if they are showing).

  Returns:
    The pen/brush used to draw tick marks.

### setTickMarkStroke

    public void setTickMarkStroke(java.awt.Stroke stroke)

  Sets the pen/brush used to draw tick marks (if they are showing) and sends an `AxisChangeEvent` to all registered listeners.

  Parameters:
    `stroke` - the new pen/brush (`null` not permitted).

### getTickMarkPaint

    public java.awt.Paint getTickMarkPaint()

  Returns the paint used to draw tick marks (if they are showing).

  Returns:
    The paint.

### setTickMarkPaint

    public void setTickMarkPaint(java.awt.Paint paint)

  Sets the paint used to draw tick marks (if they are showing).

  Registered listeners are notified of a general change to the axis.

  Parameters:
    `paint` - the new paint (null not permitted).

### getPlot

    public Plot getPlot()

  Returns the plot that the axis is assigned to.

  This method will return null if the axis is not currently assigned to a plot.

  Returns:
    The plot that the axis is assigned to.

### setPlot

    public void setPlot(Plot plot)

  Sets a reference to the plot that the axis is assigned to.

  This method is used internally, you shouldn't need to call it yourself.

  Parameters:
    `plot` - the plot.

### getFixedDimension

    public double getFixedDimension()

  Returns the fixed dimension for the axis.

  Returns:
    The fixed dimension.

### setFixedDimension

    public void setFixedDimension(double dimension)

  Sets the fixed dimension for the axis.

  This is used when combining more than one plot on a chart. In this case, there may be several axes that need to have the same height or width so that they are aligned. This method is used to fix a dimension for the axis (the context determines whether the dimension is horizontal or vertical).

  Parameters:
    `dimension` - the fixed dimension.

### configure

    public abstract void configure()

  Configures the axis to work with the current plot. Override this method to perform any special processing (such as auto-rescaling).

### reserveSpace

    public abstract AxisSpace reserveSpace(java.awt.Graphics2D g2,
                                           Plot plot,
                                           java.awt.geom.Rectangle2D plotArea,
                                           org.jfree.ui.RectangleEdge edge,
                                           AxisSpace space)

  Estimates the space (height or width) required to draw the axis.

  Parameters:
    `g2` - the graphics device.
    `plot` - the plot that the axis belongs to.
    `plotArea` - the area within which the plot (including axes) should be drawn.
    `edge` - the axis location.
    `space` - space already reserved.
  Returns:
    The space required to draw the axis (including pre-reserved space).

### draw

    public abstract AxisState draw(java.awt.Graphics2D g2,
                                   double cursor,
                                   java.awt.geom.Rectangle2D plotArea,
                                   java.awt.geom.Rectangle2D dataArea,
                                   org.jfree.ui.RectangleEdge edge,
                                   PlotRenderingInfo plotState)

  Draws the axis on a Java 2D graphics device (such as the screen or a printer).

  Parameters:
    `g2` - the graphics device (`null` not permitted).
    `cursor` - the cursor location (determines where to draw the axis).
    `plotArea` - the area within which the axes and plot should be drawn.
    `dataArea` - the area within which the data should be drawn.
    `edge` - the axis location (`null` not permitted).
    `plotState` - collects information about the plot (`null` permitted).
  Returns:
    the axis state (never `null`).

### refreshTicks

    public abstract java.util.List refreshTicks(java.awt.Graphics2D g2,
                                                AxisState state,
                                                java.awt.geom.Rectangle2D plotArea,
                                                java.awt.geom.Rectangle2D dataArea,
                                                org.jfree.ui.RectangleEdge edge)

  Calculates the positions of the ticks for the axis, storing the results in the tick list (ready for drawing).

  Parameters:
    `g2` - the graphics device.
    `state` - the axis state.
    `plotArea` - the area within which the axes and plot should be drawn.
    `dataArea` - the area inside the axes.
    `edge` - the edge on which the axis is located.
  Returns:
    The list of ticks.

### addChangeListener

    public void addChangeListener(AxisChangeListener listener)

  Registers an object for notification of changes to the axis.

  Parameters:
    `listener` - the object that is being registered.

### removeChangeListener

    public void removeChangeListener(AxisChangeListener listener)

  Deregisters an object for notification of changes to the axis.

  Parameters:
    `listener` - the object to deregister.

### notifyListeners

    protected void notifyListeners(AxisChangeEvent event)

  Notifies all registered listeners that the axis has changed. The AxisChangeEvent provides information about the change.

  Parameters:
    `event` - information about the change to the axis.

### getLabelEnclosure

    protected java.awt.geom.Rectangle2D getLabelEnclosure(java.awt.Graphics2D g2,
                                                          org.jfree.ui.RectangleEdge edge)

  Returns a rectangle that encloses the axis label. This is typically used for layout purposes (it gives the maximum dimensions of the label).

  Parameters:
    `g2` - the graphics device.
    `edge` - the edge of the plot area along which the axis is measuring.
  Returns:
    The enclosing rectangle.

### drawLabel

    protected AxisState drawLabel(java.lang.String label,
                                  java.awt.Graphics2D g2,
                                  java.awt.geom.Rectangle2D plotArea,
                                  java.awt.geom.Rectangle2D dataArea,
                                  org.jfree.ui.RectangleEdge edge,
                                  AxisState state)

  Draws the axis label.

  Parameters:
    `label` - the label text.
    `g2` - the graphics device.
    `plotArea` - the plot area.
    `dataArea` - the area inside the axes.
    `edge` - the location of the axis.
    `state` - the axis state (`null` not permitted).
  Returns:
    Information about the axis.

### drawAxisLine

    protected void drawAxisLine(java.awt.Graphics2D g2,
                                double cursor,
                                java.awt.geom.Rectangle2D dataArea,
                                org.jfree.ui.RectangleEdge edge)

  Draws an axis line at the current cursor position and edge.

  Parameters:
    `g2` - the graphics device.
    `cursor` - the cursor position.
    `dataArea` - the data area.
    `edge` - the edge.

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Returns a clone of the axis.

  Returns:
    A clone.
  Throws:
    `java.lang.CloneNotSupportedException` - if some component of the axis does not support cloning.

### equals

    public boolean equals(java.lang.Object obj)

  Tests this axis for equality with another object.

  Parameters:
    `obj` - the object.
  Returns:
    `true` or `false`.