Package org.jfree.chart.axis
Class Axis
java.lang.Object
org.jfree.chart.axis.Axis
- All Implemented Interfaces:
 Serializable,Cloneable
- Direct Known Subclasses:
 CategoryAxis,ValueAxis
public abstract class Axis extends Object implements Cloneable, 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
Fields Modifier and Type Field Description static FontDEFAULT_AXIS_LABEL_FONTThe default axis label font.static InsetsDEFAULT_AXIS_LABEL_INSETSThe default axis label insets.static PaintDEFAULT_AXIS_LABEL_PAINTThe default axis label paint.static PaintDEFAULT_AXIS_LINE_PAINTThe default axis line paint.static StrokeDEFAULT_AXIS_LINE_STROKEThe default axis line stroke.static booleanDEFAULT_AXIS_VISIBLEThe default axis visibility.static FontDEFAULT_TICK_LABEL_FONTThe default tick label font.static InsetsDEFAULT_TICK_LABEL_INSETSThe default tick label insets.static PaintDEFAULT_TICK_LABEL_PAINTThe default tick label paint.static booleanDEFAULT_TICK_LABELS_VISIBLEThe default tick labels visibility.static floatDEFAULT_TICK_MARK_INSIDE_LENGTHThe default tick mark inside length.static floatDEFAULT_TICK_MARK_OUTSIDE_LENGTHThe default tick mark outside length.static PaintDEFAULT_TICK_MARK_PAINTThe default tick paint.static StrokeDEFAULT_TICK_MARK_STROKEThe default tick stroke.static booleanDEFAULT_TICK_MARKS_VISIBLEThe default tick marks visible. - 
Method Summary
Modifier and Type Method Description voidaddChangeListener(AxisChangeListener listener)Registers an object for notification of changes to the axis.Objectclone()Returns a clone of the axis.abstract voidconfigure()Configures the axis to work with the current plot.abstract AxisStatedraw(Graphics2D g2, double cursor, Rectangle2D plotArea, 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).booleanequals(Object obj)Tests this axis for equality with another object.PaintgetAxisLinePaint()Returns the paint used to draw the axis line.StrokegetAxisLineStroke()Returns the stroke used to draw the axis line.doublegetFixedDimension()Returns the fixed dimension for the axis.StringgetLabel()Returns the label for the axis.doublegetLabelAngle()Returns the angle of the axis label.FontgetLabelFont()Returns the font for the axis label.InsetsgetLabelInsets()Returns the insets for the label (that is, the amount of blank space that should be left around the label).PaintgetLabelPaint()Returns the color/shade used to draw the axis label.PlotgetPlot()Returns the plot that the axis is assigned to.FontgetTickLabelFont()Returns the font used for the tick labels (if showing).InsetsgetTickLabelInsets()Returns the insets for the tick labels.PaintgetTickLabelPaint()Returns the color/shade used for the tick labels.floatgetTickMarkInsideLength()Returns the inside length of the tick marks.floatgetTickMarkOutsideLength()Returns the outside length of the tick marks.PaintgetTickMarkPaint()Returns the paint used to draw tick marks (if they are showing).StrokegetTickMarkStroke()Returns the pen/brush used to draw tick marks (if they are showing).booleanisAxisLineVisible()A flag that controls whether or not the axis line is drawn.booleanisTickLabelsVisible()Returns a flag indicating whether or not the tick labels are visible.booleanisTickMarksVisible()Returns the flag that indicates whether or not the tick marks are showing.booleanisVisible()Returnstrueif the axis is visible, andfalseotherwise.abstract ListrefreshTicks(Graphics2D g2, AxisState state, Rectangle2D plotArea, 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).voidremoveChangeListener(AxisChangeListener listener)Deregisters an object for notification of changes to the axis.abstract AxisSpacereserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, org.jfree.ui.RectangleEdge edge, AxisSpace space, boolean isOpositeAxisVisible)Estimates the space (height or width) required to draw the axis.voidsetAxisLinePaint(Paint paint)Sets the paint used to draw the axis line and sends anAxisChangeEventto all registered listeners.voidsetAxisLineStroke(Stroke stroke)Sets the stroke used to draw the axis line and sends anAxisChangeEventto all registered listeners.voidsetAxisLineVisible(boolean visible)Sets a flag that controls whether or not the axis line is visible and sends anAxisChangeEventto all registered listeners.voidsetFixedDimension(double dimension)Sets the fixed dimension for the axis.voidsetLabel(String label)Sets the label for the axis and sends anAxisChangeEventto all registered listeners.voidsetLabelAngle(double angle)Sets the angle for the label and sends anAxisChangeEventto all registered listeners.voidsetLabelFont(Font font)Sets the font for the axis label and sends anAxisChangeEventto all registered listeners.voidsetLabelInsets(Insets insets)Sets the insets for the axis label, and sends anAxisChangeEventto all registered listeners.voidsetLabelPaint(Paint paint)Sets the paint used to draw the axis label and sends anAxisChangeEventto all registered listeners.voidsetPlot(Plot plot)Sets a reference to the plot that the axis is assigned to.voidsetTickLabelFont(Font font)Sets the font for the tick labels and sends anAxisChangeEventto all registered listeners.voidsetTickLabelInsets(Insets insets)Sets the insets for the tick labels and sends anAxisChangeEventto all registered listeners.voidsetTickLabelPaint(Paint paint)Sets the paint used to draw tick labels (if they are showing) and sends anAxisChangeEventto all registered listeners.voidsetTickLabelsVisible(boolean flag)Sets the flag that determines whether or not the tick labels are visible and sends anAxisChangeEventto all registered listeners.voidsetTickMarkInsideLength(float length)Sets the inside length of the tick marks and sends anAxisChangeEventto all registered listeners.voidsetTickMarkOutsideLength(float length)Sets the outside length of the tick marks and sends anAxisChangeEventto all registered listeners.voidsetTickMarkPaint(Paint paint)Sets the paint used to draw tick marks (if they are showing).voidsetTickMarkStroke(Stroke stroke)Sets the pen/brush used to draw tick marks (if they are showing) and sends anAxisChangeEventto all registered listeners.voidsetTickMarksVisible(boolean flag)Sets the flag that indicates whether or not the tick marks are showing and sends anAxisChangeEventto all registered listeners.voidsetVisible(boolean flag)Sets a flag that controls whether or not the axis is visible and sends anAxisChangeEventto all registered listeners. 
- 
Field Details
- 
DEFAULT_AXIS_VISIBLE
public static final boolean DEFAULT_AXIS_VISIBLEThe default axis visibility.- See Also:
 - Constant Field Values
 
 - 
DEFAULT_AXIS_LABEL_FONT
The default axis label font. - 
DEFAULT_AXIS_LABEL_PAINT
The default axis label paint. - 
DEFAULT_AXIS_LABEL_INSETS
The default axis label insets. - 
DEFAULT_AXIS_LINE_PAINT
The default axis line paint. - 
DEFAULT_AXIS_LINE_STROKE
The default axis line stroke. - 
DEFAULT_TICK_LABELS_VISIBLE
public static final boolean DEFAULT_TICK_LABELS_VISIBLEThe default tick labels visibility.- See Also:
 - Constant Field Values
 
 - 
DEFAULT_TICK_LABEL_FONT
The default tick label font. - 
DEFAULT_TICK_LABEL_PAINT
The default tick label paint. - 
DEFAULT_TICK_LABEL_INSETS
The default tick label insets. - 
DEFAULT_TICK_MARKS_VISIBLE
public static final boolean DEFAULT_TICK_MARKS_VISIBLEThe default tick marks visible.- See Also:
 - Constant Field Values
 
 - 
DEFAULT_TICK_MARK_STROKE
The default tick stroke. - 
DEFAULT_TICK_MARK_PAINT
The default tick paint. - 
DEFAULT_TICK_MARK_INSIDE_LENGTH
public static final float DEFAULT_TICK_MARK_INSIDE_LENGTHThe default tick mark inside length.- See Also:
 - Constant Field Values
 
 - 
DEFAULT_TICK_MARK_OUTSIDE_LENGTH
public static final float DEFAULT_TICK_MARK_OUTSIDE_LENGTHThe default tick mark outside length.- See Also:
 - Constant Field Values
 
 
 - 
 - 
Method Details
- 
isVisible
public boolean isVisible()Returnstrueif the axis is visible, andfalseotherwise.- Returns:
 - A boolean.
 
 - 
setVisible
public void setVisible(boolean flag)Sets a flag that controls whether or not the axis is visible and sends anAxisChangeEventto all registered listeners.- Parameters:
 flag- the flag.
 - 
getLabel
Returns the label for the axis.- Returns:
 - The label for the axis (
nullpossible). 
 - 
setLabel
Sets the label for the axis and sends anAxisChangeEventto all registered listeners.- Parameters:
 label- the new label (nullpermitted).
 - 
getLabelFont
Returns the font for the axis label.- Returns:
 - The font.
 
 - 
setLabelFont
Sets the font for the axis label and sends anAxisChangeEventto all registered listeners.- Parameters:
 font- the font (nullnot permitted).
 - 
getLabelPaint
Returns the color/shade used to draw the axis label.- Returns:
 - The paint (never 
null). 
 - 
setLabelPaint
Sets the paint used to draw the axis label and sends anAxisChangeEventto all registered listeners.- Parameters:
 paint- the paint (nullnot permitted).
 - 
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
Sets the insets for the axis label, and sends anAxisChangeEventto all registered listeners.- Parameters:
 insets- the insets (nullnot 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 anAxisChangeEventto 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 anAxisChangeEventto all registered listeners.- Parameters:
 visible- the flag.
 - 
getAxisLinePaint
Returns the paint used to draw the axis line.- Returns:
 - The paint (never 
null). 
 - 
setAxisLinePaint
Sets the paint used to draw the axis line and sends anAxisChangeEventto all registered listeners.- Parameters:
 paint- the paint (nullnot permitted).
 - 
getAxisLineStroke
Returns the stroke used to draw the axis line.- Returns:
 - The stroke (never 
null). 
 - 
setAxisLineStroke
Sets the stroke used to draw the axis line and sends anAxisChangeEventto all registered listeners.- Parameters:
 stroke- the stroke (nullnot 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 anAxisChangeEventto all registered listeners.- Parameters:
 flag- the flag.
 - 
getTickLabelFont
Returns the font used for the tick labels (if showing).- Returns:
 - The font (never 
null). 
 - 
setTickLabelFont
Sets the font for the tick labels and sends anAxisChangeEventto all registered listeners.- Parameters:
 font- the font (nullnot allowed).
 - 
getTickLabelPaint
Returns the color/shade used for the tick labels.- Returns:
 - The paint used for the tick labels.
 
 - 
setTickLabelPaint
Sets the paint used to draw tick labels (if they are showing) and sends anAxisChangeEventto all registered listeners.- Parameters:
 paint- the paint (nullnot permitted).
 - 
getTickLabelInsets
Returns the insets for the tick labels.- Returns:
 - The insets (never 
null). 
 - 
setTickLabelInsets
Sets the insets for the tick labels and sends anAxisChangeEventto all registered listeners.- Parameters:
 insets- the insets (nullnot 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 anAxisChangeEventto 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 anAxisChangeEventto 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 anAxisChangeEventto all registered listeners.- Parameters:
 length- the new length.
 - 
getTickMarkStroke
Returns the pen/brush used to draw tick marks (if they are showing).- Returns:
 - The pen/brush used to draw tick marks.
 
 - 
setTickMarkStroke
Sets the pen/brush used to draw tick marks (if they are showing) and sends anAxisChangeEventto all registered listeners.- Parameters:
 stroke- the new pen/brush (nullnot permitted).
 - 
getTickMarkPaint
Returns the paint used to draw tick marks (if they are showing).- Returns:
 - The paint.
 
 - 
setTickMarkPaint
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
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
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(Graphics2D g2, Plot plot, Rectangle2D plotArea, org.jfree.ui.RectangleEdge edge, AxisSpace space, boolean isOpositeAxisVisible)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(Graphics2D g2, double cursor, Rectangle2D plotArea, 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 (nullnot 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 (nullnot permitted).plotState- collects information about the plot (nullpermitted).- Returns:
 - the axis state (never 
null). 
 - 
refreshTicks
public abstract List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D plotArea, 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
Registers an object for notification of changes to the axis.- Parameters:
 listener- the object that is being registered.
 - 
removeChangeListener
Deregisters an object for notification of changes to the axis.- Parameters:
 listener- the object to deregister.
 - 
clone
Returns a clone of the axis.- Returns:
 - A clone.
 - Throws:
 CloneNotSupportedException- if some component of the axis does not support cloning.
 - 
equals
Tests this axis for equality with another object. 
 -