public class CategoryAxis extends Axis implements java.lang.Cloneable, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_AXIS_MARGIN
The default margin for the axis (used for both lower and upper margins).
|
static double |
DEFAULT_CATEGORY_MARGIN
The default margin between categories (a percentage of the overall axis
length).
|
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 and Description |
|---|
CategoryAxis()
Creates a new category axis with no label.
|
CategoryAxis(java.lang.String label)
Constructs a category axis, using default values where necessary.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCategoryLabelToolTip(java.lang.Comparable category,
java.lang.String tooltip)
Adds a tooltip to the specified category and sends an
AxisChangeEvent to all registered listeners. |
protected double |
calculateCategoryGapSize(int categoryCount,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
Calculates the size (width or height, depending on the location of the
axis) of a category gap.
|
protected double |
calculateCategorySize(int categoryCount,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
Calculates the size (width or height, depending on the location of the
axis) of a category.
|
protected double |
calculateTextBlockHeight(TextBlock block,
CategoryLabelPosition position,
java.awt.Graphics2D g2)
A utility method for determining the height of a text block.
|
protected double |
calculateTextBlockWidth(TextBlock block,
CategoryLabelPosition position,
java.awt.Graphics2D g2)
A utility method for determining the width of a text block.
|
void |
clearCategoryLabelToolTips()
Clears the category label tooltips and sends an
AxisChangeEvent
to all registered listeners. |
java.lang.Object |
clone()
Creates a clone of the axis.
|
void |
configure()
Configures the axis against the current plot.
|
protected TextBlock |
createLabel(java.lang.Comparable category,
float width,
RectangleEdge edge,
java.awt.Graphics2D g2)
Creates a label.
|
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).
|
protected AxisState |
drawCategoryLabels(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.
|
protected AxisState |
drawCategoryLabels(java.awt.Graphics2D g2,
java.awt.geom.Rectangle2D dataArea,
RectangleEdge edge,
AxisState state,
PlotRenderingInfo plotState)
|
void |
drawTickMarks(java.awt.Graphics2D g2,
double cursor,
java.awt.geom.Rectangle2D dataArea,
RectangleEdge edge,
AxisState state)
Draws the tick marks.
|
boolean |
equals(java.lang.Object obj)
Tests this axis for equality with an arbitrary object.
|
double |
getCategoryEnd(int category,
int categoryCount,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
Returns the end coordinate for the specified category.
|
double |
getCategoryJava2DCoordinate(CategoryAnchor anchor,
int category,
int categoryCount,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
Returns the Java 2D coordinate for a category.
|
int |
getCategoryLabelPositionOffset()
Returns the offset between the axis and the category labels (before
label positioning is taken into account).
|
CategoryLabelPositions |
getCategoryLabelPositions()
Returns the category label position specification (this contains label
positioning info for all four possible axis locations).
|
java.lang.String |
getCategoryLabelToolTip(java.lang.Comparable category)
Returns the tool tip text for the label belonging to the specified
category.
|
double |
getCategoryMargin()
Returns the category margin.
|
double |
getCategoryMiddle(java.lang.Comparable category,
java.util.List categories,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
A convenience method that returns the axis coordinate for the centre of
a category.
|
double |
getCategoryMiddle(int category,
int categoryCount,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
Returns the middle coordinate for the specified category.
|
double |
getCategorySeriesMiddle(java.lang.Comparable category,
java.lang.Comparable seriesKey,
CategoryDataset dataset,
double itemMargin,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
Returns the middle coordinate (in Java2D space) for a series within a
category.
|
double |
getCategorySeriesMiddle(int categoryIndex,
int categoryCount,
int seriesIndex,
int seriesCount,
double itemMargin,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
Returns the middle coordinate (in Java2D space) for a series within a
category.
|
double |
getCategoryStart(int category,
int categoryCount,
java.awt.geom.Rectangle2D area,
RectangleEdge edge)
Returns the starting coordinate for the specified category.
|
double |
getLowerMargin()
Returns the lower margin for the axis.
|
int |
getMaximumCategoryLabelLines()
Returns the maximum number of lines to use for each category label.
|
float |
getMaximumCategoryLabelWidthRatio()
Returns the category label width ratio.
|
java.awt.Font |
getTickLabelFont(java.lang.Comparable category)
Returns the font for the tick label for the given category.
|
java.awt.Paint |
getTickLabelPaint(java.lang.Comparable category)
Returns the paint for the tick label for the given category.
|
double |
getUpperMargin()
Returns the upper margin for the axis.
|
int |
hashCode()
Returns a hash code for this object.
|
java.util.List |
refreshTicks(java.awt.Graphics2D g2,
AxisState state,
java.awt.geom.Rectangle2D dataArea,
RectangleEdge edge)
Creates a temporary list of ticks that can be used when drawing the axis.
|
void |
removeCategoryLabelToolTip(java.lang.Comparable category)
Removes the tooltip for the specified category and sends an
AxisChangeEvent to all registered listeners. |
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.
|
void |
setCategoryLabelPositionOffset(int offset)
Sets the offset between the axis and the category labels (before label
positioning is taken into account).
|
void |
setCategoryLabelPositions(CategoryLabelPositions positions)
Sets the category label position specification for the axis and sends an
AxisChangeEvent to all registered listeners. |
void |
setCategoryMargin(double margin)
Sets the category margin and sends an
AxisChangeEvent to all
registered listeners. |
void |
setLowerMargin(double margin)
Sets the lower margin for the axis and sends an
AxisChangeEvent
to all registered listeners. |
void |
setMaximumCategoryLabelLines(int lines)
Sets the maximum number of lines to use for each category label and
sends an
AxisChangeEvent to all registered listeners. |
void |
setMaximumCategoryLabelWidthRatio(float ratio)
Sets the maximum category label width ratio and sends an
AxisChangeEvent to all registered listeners. |
void |
setTickLabelFont(java.lang.Comparable category,
java.awt.Font font)
Sets the font for the tick label for the specified category and sends
an
AxisChangeEvent to all registered listeners. |
void |
setTickLabelPaint(java.lang.Comparable category,
java.awt.Paint paint)
Sets the paint for the tick label for the specified category and sends
an
AxisChangeEvent to all registered listeners. |
void |
setUpperMargin(double margin)
Sets the upper margin for the axis and sends an
AxisChangeEvent
to all registered listeners. |
addChangeListener, createAndAddEntity, drawAxisLine, drawLabel, fireChangeEvent, getAxisLinePaint, getAxisLineStroke, getFixedDimension, getLabel, getLabelAngle, getLabelEnclosure, getLabelFont, getLabelInsets, getLabelPaint, getMinorTickMarkInsideLength, getMinorTickMarkOutsideLength, getPlot, getTickLabelFont, getTickLabelInsets, getTickLabelPaint, getTickMarkInsideLength, getTickMarkOutsideLength, getTickMarkPaint, getTickMarkStroke, hasListener, isAxisLineVisible, isMinorTickMarksVisible, isTickLabelsVisible, isTickMarksVisible, isVisible, notifyListeners, removeChangeListener, setAxisLinePaint, setAxisLineStroke, setAxisLineVisible, setFixedDimension, setLabel, setLabelAngle, setLabelFont, setLabelInsets, setLabelInsets, setLabelPaint, setMinorTickMarkInsideLength, setMinorTickMarkOutsideLength, setMinorTickMarksVisible, setPlot, setTickLabelFont, setTickLabelInsets, setTickLabelPaint, setTickLabelsVisible, setTickMarkInsideLength, setTickMarkOutsideLength, setTickMarkPaint, setTickMarkStroke, setTickMarksVisible, setVisiblepublic static final double DEFAULT_AXIS_MARGIN
public static final double DEFAULT_CATEGORY_MARGIN
public CategoryAxis()
public CategoryAxis(java.lang.String label)
label - the axis label (null permitted).public double getLowerMargin()
getUpperMargin(),
setLowerMargin(double)public void setLowerMargin(double margin)
AxisChangeEvent
to all registered listeners.margin - the margin as a percentage of the axis length (for
example, 0.05 is five percent).getLowerMargin()public double getUpperMargin()
getLowerMargin(),
setUpperMargin(double)public void setUpperMargin(double margin)
AxisChangeEvent
to all registered listeners.margin - the margin as a percentage of the axis length (for
example, 0.05 is five percent).getUpperMargin()public double getCategoryMargin()
setCategoryMargin(double)public void setCategoryMargin(double margin)
AxisChangeEvent to all
registered listeners. The overall category margin is distributed over
N-1 gaps, where N is the number of categories on the axis.margin - the margin as a percentage of the axis length (for
example, 0.05 is five percent).getCategoryMargin()public int getMaximumCategoryLabelLines()
setMaximumCategoryLabelLines(int)public void setMaximumCategoryLabelLines(int lines)
AxisChangeEvent to all registered listeners.lines - the maximum number of lines.getMaximumCategoryLabelLines()public float getMaximumCategoryLabelWidthRatio()
setMaximumCategoryLabelWidthRatio(float)public void setMaximumCategoryLabelWidthRatio(float ratio)
AxisChangeEvent to all registered listeners.ratio - the ratio.getMaximumCategoryLabelWidthRatio()public int getCategoryLabelPositionOffset()
setCategoryLabelPositionOffset(int)public void setCategoryLabelPositionOffset(int offset)
offset - the offset (in Java2D units).getCategoryLabelPositionOffset()public CategoryLabelPositions getCategoryLabelPositions()
null).setCategoryLabelPositions(CategoryLabelPositions)public void setCategoryLabelPositions(CategoryLabelPositions positions)
AxisChangeEvent to all registered listeners.positions - the positions (null not permitted).getCategoryLabelPositions()public java.awt.Font getTickLabelFont(java.lang.Comparable category)
category - the category (null not permitted).null).setTickLabelFont(Comparable, Font)public void setTickLabelFont(java.lang.Comparable category, java.awt.Font font)
AxisChangeEvent to all registered listeners.category - the category (null not permitted).font - the font (null permitted).getTickLabelFont(Comparable)public java.awt.Paint getTickLabelPaint(java.lang.Comparable category)
category - the category (null not permitted).null).Axis.setTickLabelPaint(Paint)public void setTickLabelPaint(java.lang.Comparable category, java.awt.Paint paint)
AxisChangeEvent to all registered listeners.category - the category (null not permitted).paint - the paint (null permitted).getTickLabelPaint(Comparable)public void addCategoryLabelToolTip(java.lang.Comparable category, java.lang.String tooltip)
AxisChangeEvent to all registered listeners.category - the category (null not permitted).tooltip - the tooltip text (null permitted).removeCategoryLabelToolTip(Comparable)public java.lang.String getCategoryLabelToolTip(java.lang.Comparable category)
category - the category (null not permitted).null).addCategoryLabelToolTip(Comparable, String),
removeCategoryLabelToolTip(Comparable)public void removeCategoryLabelToolTip(java.lang.Comparable category)
AxisChangeEvent to all registered listeners.category - the category (null not permitted).addCategoryLabelToolTip(Comparable, String),
clearCategoryLabelToolTips()public void clearCategoryLabelToolTips()
AxisChangeEvent
to all registered listeners.public double getCategoryJava2DCoordinate(CategoryAnchor anchor, int category, int categoryCount, java.awt.geom.Rectangle2D area, RectangleEdge edge)
anchor - the anchor point.category - the category index.categoryCount - the category count.area - the data area.edge - the location of the axis.public double getCategoryStart(int category, int categoryCount, java.awt.geom.Rectangle2D area, RectangleEdge edge)
category - the category.categoryCount - the number of categories.area - the data area.edge - the axis location.getCategoryMiddle(int, int, Rectangle2D, RectangleEdge),
getCategoryEnd(int, int, Rectangle2D, RectangleEdge)public double getCategoryMiddle(int category, int categoryCount, java.awt.geom.Rectangle2D area, RectangleEdge edge)
category - the category.categoryCount - the number of categories.area - the data area.edge - the axis location.getCategoryStart(int, int, Rectangle2D, RectangleEdge),
getCategoryEnd(int, int, Rectangle2D, RectangleEdge)public double getCategoryEnd(int category, int categoryCount, java.awt.geom.Rectangle2D area, RectangleEdge edge)
category - the category.categoryCount - the number of categories.area - the data area.edge - the axis location.getCategoryStart(int, int, Rectangle2D, RectangleEdge),
getCategoryMiddle(int, int, Rectangle2D, RectangleEdge)public double getCategoryMiddle(java.lang.Comparable category, java.util.List categories, java.awt.geom.Rectangle2D area, RectangleEdge edge)
category - the category key (null not permitted).categories - the categories (null not permitted).area - the data area (null not permitted).edge - the edge along which the axis lies (null not
permitted).getCategorySeriesMiddle(Comparable, Comparable, CategoryDataset,
double, Rectangle2D, RectangleEdge)public double getCategorySeriesMiddle(java.lang.Comparable category, java.lang.Comparable seriesKey, CategoryDataset dataset, double itemMargin, java.awt.geom.Rectangle2D area, RectangleEdge edge)
category - the category (null not permitted).seriesKey - the series key (null not permitted).dataset - the dataset (null not permitted).itemMargin - the item margin (0.0 <= itemMargin < 1.0);area - the area (null not permitted).edge - the edge (null not permitted).public double getCategorySeriesMiddle(int categoryIndex, int categoryCount, int seriesIndex, int seriesCount, double itemMargin, java.awt.geom.Rectangle2D area, RectangleEdge edge)
categoryIndex - the category index.categoryCount - the category count.seriesIndex - the series index.seriesCount - the series count.itemMargin - the item margin (0.0 <= itemMargin < 1.0);area - the area (null not permitted).edge - the edge (null not permitted).protected double calculateCategorySize(int categoryCount, java.awt.geom.Rectangle2D area, RectangleEdge edge)
categoryCount - the number of categories.area - the area within which the categories will be drawn.edge - the axis location.protected double calculateCategoryGapSize(int categoryCount, java.awt.geom.Rectangle2D area, RectangleEdge edge)
categoryCount - the number of categories.area - the area within which the categories will be drawn.edge - the axis location.public AxisSpace reserveSpace(java.awt.Graphics2D g2, Plot plot, java.awt.geom.Rectangle2D plotArea, RectangleEdge edge, AxisSpace space)
reserveSpace in class Axisg2 - 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.public void configure()
public AxisState draw(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState)
draw in class Axisg2 - 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).null).protected AxisState drawCategoryLabels(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState)
drawCategoryLabels(Graphics2D, Rectangle2D,
Rectangle2D, RectangleEdge, AxisState, PlotRenderingInfo).g2 - the graphics device (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).null).protected AxisState drawCategoryLabels(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge, AxisState state, PlotRenderingInfo plotState)
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).null).public java.util.List refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge)
refreshTicks in class Axisg2 - the graphics device (used to get font measurements).state - the axis state.dataArea - the area inside the axes.edge - the location of the axis.public void drawTickMarks(java.awt.Graphics2D g2, double cursor, java.awt.geom.Rectangle2D dataArea, RectangleEdge edge, AxisState state)
protected TextBlock createLabel(java.lang.Comparable category, float width, RectangleEdge edge, java.awt.Graphics2D g2)
category - the category.width - the available width.edge - the edge on which the axis appears.g2 - the graphics device.protected double calculateTextBlockWidth(TextBlock block, CategoryLabelPosition position, java.awt.Graphics2D g2)
block - the text block.position - the position.g2 - the graphics device.protected double calculateTextBlockHeight(TextBlock block, CategoryLabelPosition position, java.awt.Graphics2D g2)
block - the text block.position - the label position.g2 - the graphics device.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
public boolean equals(java.lang.Object obj)
public int hashCode()
hashCode in class java.lang.ObjectCopyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.