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:
Serializable
,Cloneable
A specialised category axis that can display sub-categories.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
For serialization.private List
Storage for the sub-categories (these need to be set manually).private Font
The font for the sub-category labels.private Paint
The 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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSubCategory
(Comparable subCategory) Adds a sub-category to the axis and sends anAxisChangeEvent
to all registered listeners.draw
(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) Draws the axis on a Java 2D graphics device (such as the screen or a printer).protected AxisState
drawSubCategoryLabels
(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState) Draws the category labels and returns the updated axis state.boolean
Tests the axis for equality with an arbitrary object.private double
getMaxDim
(Graphics2D g2, RectangleEdge edge) Returns the maximum of the relevant dimension (height or width) of the subcategory labels.Returns the font used to display the sub-category labels.Returns the paint used to display the sub-category labels.int
hashCode()
Returns a hashcode for this instance.private void
readObject
(ObjectInputStream stream) Provides serialization support.reserveSpace
(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) Estimates the space required for the axis, given a specific drawing area.void
setSubLabelFont
(Font font) Sets the font used to display the sub-category labels and sends anAxisChangeEvent
to all registered listeners.void
setSubLabelPaint
(Paint paint) Sets the paint used to display the sub-category labels and sends anAxisChangeEvent
to all registered listeners.private void
writeObject
(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 Details
-
serialVersionUID
private static final long serialVersionUIDFor serialization.- See Also:
-
subCategories
Storage for the sub-categories (these need to be set manually). -
subLabelFont
The font for the sub-category labels. -
subLabelPaint
The paint for the sub-category labels.
-
-
Constructor Details
-
SubCategoryAxis
Creates a new axis.- Parameters:
label
- the axis label.
-
-
Method Details
-
addSubCategory
Adds a sub-category to the axis and sends anAxisChangeEvent
to all registered listeners.- Parameters:
subCategory
- the sub-category (null
not permitted).
-
getSubLabelFont
Returns the font used to display the sub-category labels.- Returns:
- The font (never
null
). - See Also:
-
setSubLabelFont
Sets the font used to display the sub-category labels and sends anAxisChangeEvent
to all registered listeners.- Parameters:
font
- the font (null
not permitted).- See Also:
-
getSubLabelPaint
Returns the paint used to display the sub-category labels.- Returns:
- The paint (never
null
). - See Also:
-
setSubLabelPaint
Sets the paint used to display the sub-category labels and sends anAxisChangeEvent
to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).- See Also:
-
reserveSpace
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) Estimates the space required for the axis, given a specific drawing area.- Overrides:
reserveSpace
in 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
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(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) Draws the axis on a Java 2D graphics device (such as the screen or a printer).- Overrides:
draw
in classCategoryAxis
- Parameters:
g2
- the graphics device (null
not permitted).cursor
- the cursor location.plotArea
- the area within which the axis should be drawn (null
not permitted).dataArea
- the area within which the plot is being drawn (null
not permitted).edge
- the location of the axis (null
not permitted).plotState
- collects information about the plot (null
permitted).- Returns:
- The axis state (never
null
).
-
drawSubCategoryLabels
protected AxisState drawSubCategoryLabels(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState) Draws the category labels and returns the updated axis state.- Parameters:
g2
- the graphics device (null
not permitted).plotArea
- the plot area (null
not permitted).dataArea
- the area inside the axes (null
not permitted).edge
- the axis location (null
not permitted).state
- the axis state (null
not permitted).plotState
- collects information about the plot (null
permitted).- Returns:
- The updated axis state (never
null
).
-
equals
Tests the axis for equality with an arbitrary object.- Overrides:
equals
in classCategoryAxis
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()Returns a hashcode for this instance.- Overrides:
hashCode
in classCategoryAxis
- Returns:
- A hashcode for this instance.
-
writeObject
Provides serialization support.- Parameters:
stream
- the output stream.- Throws:
IOException
- if there is an I/O error.
-
readObject
Provides serialization support.- Parameters:
stream
- the input stream.- Throws:
IOException
- if there is an I/O error.ClassNotFoundException
- if there is a classpath problem.
-