com.jrefinery.chart
Class HorizontalCategoryAxis

java.lang.Object
  |
  +--com.jrefinery.chart.Axis
        |
        +--com.jrefinery.chart.CategoryAxis
              |
              +--com.jrefinery.chart.HorizontalCategoryAxis
All Implemented Interfaces:
AxisConstants, HorizontalAxis

public class HorizontalCategoryAxis
extends CategoryAxis
implements HorizontalAxis

A horizontal axis that displays categories. Used for bar charts and line charts.

Note: the axis needs to rely on the plot for assistance with the placement of category labels, since the plot controls how the categories are distributed.

Author:
DG

Fields inherited from class com.jrefinery.chart.Axis
fixedDimension, label, labelFont, labelInsets, labelPaint, plot, tickLabelFont, tickLabelInsets, tickLabelPaint, tickLabelsVisible, tickMarkPaint, tickMarkStroke, tickMarksVisible, ticks, visible
 
Fields inherited from interface com.jrefinery.chart.AxisConstants
DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_PAINT, DEFAULT_TICK_STROKE
 
Constructor Summary
HorizontalCategoryAxis()
          Constructs a HorizontalCategoryAxis, using default values where necessary.
HorizontalCategoryAxis(java.lang.String label)
          Constructs a HorizontalCategoryAxis, using default values where necessary.
HorizontalCategoryAxis(java.lang.String label, java.awt.Font labelFont, java.awt.Paint labelPaint, java.awt.Insets labelInsets, boolean categoryLabelsVisible, boolean verticalCategoryLabels, java.awt.Font categoryLabelFont, java.awt.Paint categoryLabelPaint, java.awt.Insets categoryLabelInsets, boolean tickMarksVisible, java.awt.Stroke tickMarkStroke, java.awt.Paint tickMarkPaint)
          Constructs a HorizontalCategoryAxis.
 
Method Summary
 void configure()
          Configures the axis against the current plot.
 void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea, java.awt.geom.Rectangle2D plotArea)
          Draws the axis on a Java 2D graphics device (such as the screen or a printer).
protected  double getMaxTickLabelWidth(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea)
          Returns the maximum width of the ticks in the working list (that is set up by refreshTicks()).
 boolean getSkipCategoryLabelsToFit()
          Returns the flag that determines whether the category labels are to be skipped to avoid overlapping.
 boolean getVerticalCategoryLabels()
          Returns a flag indicating whether the category labels are drawn 'vertically'.
protected  boolean isCompatiblePlot(Plot plot)
          Returns true if the specified plot is compatible with the axis.
 void refreshTicks(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea)
          Creates a temporary list of ticks that can be used when drawing the axis.
 java.awt.geom.Rectangle2D reserveAxisArea(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D drawArea, double reservedWidth)
          Returns the area required to draw the axis in the specified draw area.
 double reserveHeight(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D drawArea)
          Estimates the height required for the axis, given a specific drawing area, without any information about the width of the vertical axis.
 void setSkipCategoryLabelsToFit(boolean flag)
          Sets the flag that determines whether the category labels are to be skipped to avoid overlapping.
 void setVerticalCategoryLabels(boolean flag)
          Sets the flag that determines whether the category labels are drawn 'vertically'.
 void setVerticalTickLabels(boolean flag)
          Sets the flag that determines whether the category labels are drawn 'vertically'.
 
Methods inherited from class com.jrefinery.chart.Axis
addChangeListener, getFixedDimension, getLabel, getLabelFont, getLabelInsets, getLabelPaint, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkPaint, getTickMarkStroke, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, removeChangeListener, setFixedDimension, setLabel, setLabelFont, setLabelInsets, setLabelPaint, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HorizontalCategoryAxis

public HorizontalCategoryAxis()
Constructs a HorizontalCategoryAxis, using default values where necessary.

HorizontalCategoryAxis

public HorizontalCategoryAxis(java.lang.String label)
Constructs a HorizontalCategoryAxis, using default values where necessary.
Parameters:
label - the axis label (null permitted).

HorizontalCategoryAxis

public HorizontalCategoryAxis(java.lang.String label,
                              java.awt.Font labelFont,
                              java.awt.Paint labelPaint,
                              java.awt.Insets labelInsets,
                              boolean categoryLabelsVisible,
                              boolean verticalCategoryLabels,
                              java.awt.Font categoryLabelFont,
                              java.awt.Paint categoryLabelPaint,
                              java.awt.Insets categoryLabelInsets,
                              boolean tickMarksVisible,
                              java.awt.Stroke tickMarkStroke,
                              java.awt.Paint tickMarkPaint)
Constructs a HorizontalCategoryAxis.
Parameters:
label - the axis label (null permitted).
labelFont - the font for displaying the axis label.
labelPaint - the paint used to draw the axis label.
labelInsets - determines the amount of blank space around the label.
categoryLabelsVisible - a flag indicating whether or not category labels are visible.
verticalCategoryLabels - a flag indicating whether or not the category labels are drawn vertically.
categoryLabelFont - the font used to display category labels.
categoryLabelPaint - the paint used to draw category labels.
categoryLabelInsets - determines the blank space around each category label.
tickMarksVisible - a flag indicating whether or not tick marks are visible.
tickMarkStroke - the stroke used to draw tick marks (if visible).
tickMarkPaint - the paint used to draw tick marks (if visible).
Method Detail

getVerticalCategoryLabels

public boolean getVerticalCategoryLabels()
Returns a flag indicating whether the category labels are drawn 'vertically'.
Returns:
the flag.

setVerticalCategoryLabels

public void setVerticalCategoryLabels(boolean flag)
Sets the flag that determines whether the category labels are drawn 'vertically'.
Parameters:
flag - the new value of the flag.

setVerticalTickLabels

public void setVerticalTickLabels(boolean flag)
Sets the flag that determines whether the category labels are drawn 'vertically'.

You should use the setVerticalCategoryLabels method - this method just passed over to it anyway.

Parameters:
flag - the new value of the flag.

getSkipCategoryLabelsToFit

public boolean getSkipCategoryLabelsToFit()
Returns the flag that determines whether the category labels are to be skipped to avoid overlapping.
Returns:
The flag.

setSkipCategoryLabelsToFit

public void setSkipCategoryLabelsToFit(boolean flag)
Sets the flag that determines whether the category labels are to be skipped to avoid overlapping.
Parameters:
flag - the new value of the flag.

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D drawArea,
                 java.awt.geom.Rectangle2D plotArea)
Draws the axis on a Java 2D graphics device (such as the screen or a printer).
Overrides:
draw in class Axis
Parameters:
g2 - the graphics device.
drawArea - the area within which the axis should be drawn.
plotArea - the area within which the plot is being drawn.

refreshTicks

public void refreshTicks(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D plotArea,
                         java.awt.geom.Rectangle2D dataArea)
Creates a temporary list of ticks that can be used when drawing the axis.
Overrides:
refreshTicks in class Axis
Parameters:
g2 - the graphics device (used to get font measurements).
plotArea - the area where the plot and axes will be drawn.
dataArea - the area inside the axes.

reserveHeight

public double reserveHeight(java.awt.Graphics2D g2,
                            Plot plot,
                            java.awt.geom.Rectangle2D drawArea)
Estimates the height required for the axis, given a specific drawing area, without any information about the width of the vertical axis.

Supports the HorizontalAxis interface.

Specified by:
reserveHeight in interface HorizontalAxis
Parameters:
g2 - the graphics device (used to obtain font information).
plot - the plot that the axis belongs to.
drawArea - the area within which the axis should be drawn.
Returns:
the estimated height required for the axis.

reserveAxisArea

public java.awt.geom.Rectangle2D reserveAxisArea(java.awt.Graphics2D g2,
                                                 Plot plot,
                                                 java.awt.geom.Rectangle2D drawArea,
                                                 double reservedWidth)
Returns the area required to draw the axis in the specified draw area.
Specified by:
reserveAxisArea in interface HorizontalAxis
Parameters:
g2 - the graphics device.
plot - the plot that the axis belongs to.
drawArea - the area within which the plot should be drawn.
reservedWidth - the width reserved by the vertical axis.
Returns:
the area required to draw the axis in the specified draw area.

getMaxTickLabelWidth

protected double getMaxTickLabelWidth(java.awt.Graphics2D g2,
                                      java.awt.geom.Rectangle2D plotArea)
Returns the maximum width of the ticks in the working list (that is set up by refreshTicks()).
Overrides:
getMaxTickLabelWidth in class Axis
Parameters:
g2 - the graphics device.
plotArea - the area within which the plot is to be drawn.
Returns:
the maximum width of the ticks in the working list.

isCompatiblePlot

protected boolean isCompatiblePlot(Plot plot)
Returns true if the specified plot is compatible with the axis.
Overrides:
isCompatiblePlot in class Axis
Parameters:
plot - The plot.
Returns:
true if the specified plot is compatible with the axis.

configure

public void configure()
Configures the axis against the current plot. Nothing required in this class.
Overrides:
configure in class Axis