Package org.jfree.chart.axis
Class SubCategoryAxis
- java.lang.Object
-
- org.jfree.chart.axis.Axis
-
- org.jfree.chart.axis.CategoryAxis
-
- org.jfree.chart.axis.SubCategoryAxis
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class SubCategoryAxis extends CategoryAxis implements java.lang.Cloneable, java.io.Serializable
A specialised category axis that can display sub-categories.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static longserialVersionUIDFor serialization.private java.util.ListsubCategoriesStorage for the sub-categories (these need to be set manually).private java.awt.FontsubLabelFontThe font for the sub-category labels.private java.awt.PaintsubLabelPaintThe paint for the sub-category labels.-
Fields inherited from class org.jfree.chart.axis.CategoryAxis
DEFAULT_AXIS_MARGIN, DEFAULT_CATEGORY_MARGIN
-
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 SubCategoryAxis(java.lang.String label)Creates a new axis.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSubCategory(java.lang.Comparable subCategory)Adds a sub-category to the axis and sends anAxisChangeEventto all registered listeners.AxisStatedraw(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).protected AxisStatedrawSubCategoryLabels(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState)Draws the category labels and returns the updated axis state.booleanequals(java.lang.Object obj)Tests the axis for equality with an arbitrary object.private doublegetMaxDim(java.awt.Graphics2D g2, RectangleEdge edge)Returns the maximum of the relevant dimension (height or width) of the subcategory labels.java.awt.FontgetSubLabelFont()Returns the font used to display the sub-category labels.java.awt.PaintgetSubLabelPaint()Returns the paint used to display the sub-category labels.inthashCode()Returns a hashcode for this instance.private voidreadObject(java.io.ObjectInputStream stream)Provides serialization support.AxisSpacereserveSpace(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D plotArea, RectangleEdge edge, AxisSpace space)Estimates the space required for the axis, given a specific drawing area.voidsetSubLabelFont(java.awt.Font font)Sets the font used to display the sub-category labels and sends anAxisChangeEventto all registered listeners.voidsetSubLabelPaint(java.awt.Paint paint)Sets the paint used to display the sub-category labels and sends anAxisChangeEventto all registered listeners.private voidwriteObject(java.io.ObjectOutputStream stream)Provides serialization support.-
Methods inherited from class org.jfree.chart.axis.CategoryAxis
addCategoryLabelToolTip, addCategoryLabelURL, calculateCategoryGapSize, calculateCategorySize, calculateTextBlockHeight, calculateTextBlockWidth, clearCategoryLabelToolTips, clearCategoryLabelURLs, clone, configure, createLabel, drawCategoryLabels, drawTickMarks, getCategoryEnd, getCategoryJava2DCoordinate, getCategoryLabelPositionOffset, getCategoryLabelPositions, getCategoryLabelToolTip, getCategoryLabelURL, getCategoryMargin, getCategoryMiddle, getCategoryMiddle, getCategorySeriesMiddle, getCategorySeriesMiddle, getCategoryStart, getLowerMargin, getMaximumCategoryLabelLines, getMaximumCategoryLabelWidthRatio, getTickLabelFont, getTickLabelPaint, getUpperMargin, refreshTicks, removeCategoryLabelToolTip, removeCategoryLabelURL, setCategoryLabelPositionOffset, setCategoryLabelPositions, setCategoryMargin, setLowerMargin, setMaximumCategoryLabelLines, setMaximumCategoryLabelWidthRatio, setTickLabelFont, setTickLabelPaint, setUpperMargin
-
Methods inherited from class org.jfree.chart.axis.Axis
addChangeListener, createAndAddEntity, createAttributedLabel, drawAttributedLabel, drawAxisLine, 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
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
subCategories
private java.util.List subCategories
Storage for the sub-categories (these need to be set manually).
-
subLabelFont
private java.awt.Font subLabelFont
The font for the sub-category labels.
-
subLabelPaint
private transient java.awt.Paint subLabelPaint
The paint for the sub-category labels.
-
-
Method Detail
-
addSubCategory
public void addSubCategory(java.lang.Comparable subCategory)
Adds a sub-category to the axis and sends anAxisChangeEventto all registered listeners.- Parameters:
subCategory- the sub-category (nullnot permitted).
-
getSubLabelFont
public java.awt.Font getSubLabelFont()
Returns the font used to display the sub-category labels.- Returns:
- The font (never
null). - See Also:
setSubLabelFont(Font)
-
setSubLabelFont
public void setSubLabelFont(java.awt.Font font)
Sets the font used to display the sub-category labels and sends anAxisChangeEventto all registered listeners.- Parameters:
font- the font (nullnot permitted).- See Also:
getSubLabelFont()
-
getSubLabelPaint
public java.awt.Paint getSubLabelPaint()
Returns the paint used to display the sub-category labels.- Returns:
- The paint (never
null). - See Also:
setSubLabelPaint(Paint)
-
setSubLabelPaint
public void setSubLabelPaint(java.awt.Paint paint)
Sets the paint used to display the sub-category labels and sends anAxisChangeEventto all registered listeners.- Parameters:
paint- the paint (nullnot permitted).- See Also:
getSubLabelPaint()
-
reserveSpace
public AxisSpace reserveSpace(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D plotArea, RectangleEdge edge, AxisSpace space)
Estimates the space required for the axis, given a specific drawing area.- Overrides:
reserveSpacein classCategoryAxis- Parameters:
g2- the graphics device (used to obtain font information).plot- the plot that the axis belongs to.plotArea- the area within which the axis should be drawn.edge- the axis location (top or bottom).space- the space already reserved.- Returns:
- The space required to draw the axis.
-
getMaxDim
private double getMaxDim(java.awt.Graphics2D g2, RectangleEdge edge)Returns the maximum of the relevant dimension (height or width) of the subcategory labels.- Parameters:
g2- the graphics device.edge- the edge.- Returns:
- The maximum dimension.
-
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:
drawin classCategoryAxis- Parameters:
g2- the graphics device (nullnot permitted).cursor- the cursor location.plotArea- the area within which the axis should be drawn (nullnot permitted).dataArea- the area within which the plot is being drawn (nullnot permitted).edge- the location of the axis (nullnot permitted).plotState- collects information about the plot (nullpermitted).- Returns:
- The axis state (never
null).
-
drawSubCategoryLabels
protected AxisState drawSubCategoryLabels(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState)
Draws the category labels and returns the updated axis state.- Parameters:
g2- the graphics device (nullnot permitted).plotArea- the plot area (nullnot permitted).dataArea- the area inside the axes (nullnot permitted).edge- the axis location (nullnot permitted).state- the axis state (nullnot permitted).plotState- collects information about the plot (nullpermitted).- Returns:
- The updated axis state (never
null).
-
equals
public boolean equals(java.lang.Object obj)
Tests the axis for equality with an arbitrary object.- Overrides:
equalsin classCategoryAxis- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hashcode for this instance.- Overrides:
hashCodein classCategoryAxis- Returns:
- A hashcode for this instance.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOExceptionProvides serialization support.- Parameters:
stream- the output stream.- Throws:
java.io.IOException- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundExceptionProvides serialization support.- Parameters:
stream- the input stream.- Throws:
java.io.IOException- if there is an I/O error.java.lang.ClassNotFoundException- if there is a classpath problem.
-
-