|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jrefinery.chart.Plot | +--com.jrefinery.chart.CategoryPlot
A general plotting class that uses data from a CategoryDataset, and uses a plug-in renderer to draw individual data items.
Plot
,
CategoryItemRenderer
Field Summary | |
protected double |
categoryGapsPercent
The percentage of the overall drawing space allocated to providing gaps between the last item in one category and the first item in the next category. |
protected CategoryAxis |
domainAxis
The domain axis. |
protected double |
introGapPercent
The gap before the first item in the plot. |
protected double |
itemGapsPercent
The gap between items within the same category. |
protected java.awt.Font |
labelFont
The value label font. |
protected java.lang.String |
labelFormatPattern
The value label format pattern String. |
protected java.text.NumberFormat |
labelFormatter
The value label format. |
protected java.awt.Paint |
labelPaint
The value label paint. |
protected CategoryPlot |
parent
The parent plot (or null if this is not a subplot). |
protected ValueAxis |
rangeAxis
The range axis. |
protected java.util.List |
rangeMarkers
A list of markers (optional) for the range axis. |
protected CategoryItemRenderer |
renderer
The renderer for the data items. |
protected double |
trailGapPercent
The gap after the last item in the plot. |
protected boolean |
valueLabelsVisible
A flag indicating whether or not value labels are shown. |
protected boolean |
verticalLabels
A flag indicating whether or not value labels are drawn vertically. |
Fields inherited from interface com.jrefinery.chart.CategoryPlotConstants |
DEFAULT_CATEGORY_GAPS_PERCENT, DEFAULT_INTRO_GAP_PERCENT, DEFAULT_ITEM_GAPS_PERCENT, DEFAULT_LABEL_FONT, DEFAULT_TRAIL_GAP_PERCENT, MAX_CATEGORY_GAPS_PERCENT, MAX_INTRO_GAP_PERCENT, MAX_ITEM_GAPS_PERCENT, MAX_TRAIL_GAP_PERCENT |
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 | |
protected |
CategoryPlot(CategoryDataset data,
CategoryAxis domainAxis,
ValueAxis rangeAxis,
CategoryItemRenderer renderer)
Constructs a category plot, using default values where necessary. |
protected |
CategoryPlot(CategoryDataset data,
CategoryAxis domainAxis,
ValueAxis rangeAxis,
CategoryItemRenderer renderer,
java.awt.Insets insets,
java.awt.Paint backgroundPaint,
java.awt.Image backgroundImage,
float backgroundAlpha,
java.awt.Stroke outlineStroke,
java.awt.Paint outlinePaint,
float foregroundAlpha,
double introGapPercent,
double trailGapPercent,
double categoryGapsPercent,
double itemGapsPercent)
Constructs a category plot. |
Method Summary | |
void |
addRangeMarker(Marker marker)
Adds a marker for the range axis. |
void |
clearRangeMarkers()
Clears all the range markers for the plot. |
void |
datasetChanged(DatasetChangeEvent event)
Receives notification of a change to the plot's dataset. |
abstract double |
getCategoryCoordinate(int category,
java.awt.geom.Rectangle2D area)
Returns the x or y coordinate (depending on the orientation of the plot) in Java 2D User Space of the center of the specified category. |
CategoryDataset |
getCategoryDataset()
A convenience method that returns the dataset for the plot, cast as a CategoryDataset. |
double |
getCategoryGapsPercent()
Returns the percentage of the drawing space that is allocated to providing gaps between the categories. |
CategoryAxis |
getDomainAxis()
Returns the domain axis for the plot. |
double |
getIntroGapPercent()
Returns the gap before the first bar on the chart, as a percentage of the available drawing space (0.05 = 5 percent). |
double |
getItemGapsPercent()
Returns the percentage of the drawing space that is allocated to providing gaps between the items in a category. |
java.awt.Font |
getLabelFont()
Returns the value label font. |
java.text.NumberFormat |
getLabelFormatter()
Returns the value label formatter. |
java.awt.Paint |
getLabelPaint()
Returns the value label paint. |
boolean |
getLabelsVisible()
Deprecated. use getValueLabelsVisible(). |
java.util.List |
getLegendItemLabels()
Deprecated. use getLegendItems(). |
LegendItemCollection |
getLegendItems()
Returns the legend items for the plot. |
CategoryPlot |
getParent()
Returns the parent plot, or null if this is not a sub-plot. |
ValueAxis |
getRangeAxis()
Returns the range axis for the plot. |
CategoryItemRenderer |
getRenderer()
Returns a reference to the renderer for the plot. |
int |
getSeriesCount()
Returns the number of series in this plot. |
double |
getTrailGapPercent()
Returns the gap following the last bar on the chart, as a percentage of the available drawing space. |
boolean |
getValueLabelsVisible()
Returns a flag that indicates whether or not the value labels are showing. |
boolean |
getVerticalLabels()
Returns true if the value labels should be rotated to vertical, and false for standard horizontal labels. |
abstract boolean |
isCompatibleDomainAxis(CategoryAxis axis)
Checks the compatibility of a domain axis, returning true if the axis is compatible with the plot, and false otherwise. |
abstract boolean |
isCompatibleRangeAxis(ValueAxis axis)
Checks the compatibility of a range axis, returning true if the axis is compatible with the plot, and false otherwise. |
boolean |
isSubplot()
Returns true if this plot is part of a combined plot structure. |
void |
setCategoryGapsPercent(double percent)
Sets the gap between the last bar in one category and the first bar in the next category, and notifies registered listeners that the plot has been modified. |
void |
setDomainAxis(CategoryAxis axis)
Sets the domain axis for the plot (this must be compatible with the plot type or an exception is thrown). |
void |
setIntroGapPercent(double percent)
Sets the gap before the first bar on the chart, and notifies registered listeners that the plot has been modified. |
void |
setItemGapsPercent(double percent)
Sets the gap between one bar and the next within the same category, and notifies registered listeners that the plot has been modified. |
void |
setLabelFont(java.awt.Font font)
Sets the value label font. |
void |
setLabelFormatString(java.lang.String format)
Sets the format string for the value labels. |
void |
setLabelPaint(java.awt.Paint paint)
Sets the value label paint. |
void |
setLabelsVisible(boolean flag)
Deprecated. use setValueLabelsVisible(boolean). |
void |
setParent(CategoryPlot parent)
Sets the parent plot. |
void |
setRangeAxis(ValueAxis axis)
Sets the range axis for the plot. |
void |
setRenderer(CategoryItemRenderer renderer)
Sets the renderer for the plot. |
void |
setTrailGapPercent(double percent)
Sets the gap after the last bar on the chart, and notifies registered listeners that the plot has been modified. |
void |
setValueLabelsVisible(boolean flag)
Sets the flag that indicates whether or not the value labels are showing. |
void |
setVerticalLabels(boolean flag)
Sets the flag that determines the orientation of the value labels. |
void |
zoom(double percent)
Zooms (in or out) on the plot's value axis. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected CategoryPlot parent
protected CategoryAxis domainAxis
protected ValueAxis rangeAxis
protected CategoryItemRenderer renderer
protected java.util.List rangeMarkers
protected double introGapPercent
protected double trailGapPercent
protected double categoryGapsPercent
protected double itemGapsPercent
protected boolean valueLabelsVisible
protected java.awt.Font labelFont
protected java.awt.Paint labelPaint
protected java.lang.String labelFormatPattern
protected java.text.NumberFormat labelFormatter
protected boolean verticalLabels
Constructor Detail |
protected CategoryPlot(CategoryDataset data, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryItemRenderer renderer)
data
- The dataset.domainAxis
- The domain axis.rangeAxis
- The range axis.renderer
- The item renderer.protected CategoryPlot(CategoryDataset data, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryItemRenderer renderer, java.awt.Insets insets, java.awt.Paint backgroundPaint, java.awt.Image backgroundImage, float backgroundAlpha, java.awt.Stroke outlineStroke, java.awt.Paint outlinePaint, float foregroundAlpha, double introGapPercent, double trailGapPercent, double categoryGapsPercent, double itemGapsPercent)
data
- The dataset.domainAxis
- The domain axis.rangeAxis
- The range axis.renderer
- The item renderer.insets
- The insets for the plot.backgroundPaint
- An optional color for the plot's background.backgroundImage
- An optional image for the plot's background.backgroundAlpha
- Alpha-transparency for the plot's background.outlineStroke
- The stroke used to draw the plot outline.outlinePaint
- The paint used to draw the plot outline.foregroundAlpha
- The alpha transparency.introGapPercent
- The gap before the first item in the plot, as a
percentage of the available drawing space.trailGapPercent
- The gap after the last item in the plot, as a
percentage of the available drawing space.categoryGapsPercent
- The percentage of drawing space allocated
to the gap between the last item in one category
and the first item in the next category.itemGapsPercent
- The gap between items within the same category.Method Detail |
public boolean isSubplot()
isSubplot
in class Plot
true
if this plot is part of a combined plot structure.public CategoryPlot getParent()
public void setParent(CategoryPlot parent)
Only used if this plot is a sub-plot within a combination plot.
parent
- The parent plot.public int getSeriesCount()
This gets used when the plot is part of a combined chart... there may be a better mechanism in the future.
public java.util.List getLegendItemLabels()
getLegendItemLabels
in class Plot
public LegendItemCollection getLegendItems()
getLegendItems
in class Plot
public CategoryItemRenderer getRenderer()
public void setRenderer(CategoryItemRenderer renderer)
If you set the renderer to null, no data will be plotted on the chart.
renderer
- The renderer (null permitted).public double getIntroGapPercent()
public void setIntroGapPercent(double percent)
percent
- The new gap value, expressed as a percentage of the
width of the plot area (0.05 = 5 percent).public double getTrailGapPercent()
public void setTrailGapPercent(double percent)
percent
- The new gap value, expressed as a percentage of the
width of the plot area (0.05 = 5 percent).public double getCategoryGapsPercent()
public void setCategoryGapsPercent(double percent)
percent
- The new gap value, expressed as a percentage of the
width of the plot area (0.05 = 5 percent).public double getItemGapsPercent()
public void setItemGapsPercent(double percent)
percent
- The new gap value, expressed as a percentage of the width
of the plot area (0.05 = 5 percent).public CategoryDataset getCategoryDataset()
public CategoryAxis getDomainAxis()
public void setDomainAxis(CategoryAxis axis) throws AxisNotCompatibleException
axis
- The new axis.AxisNotCompatibleException
- if axis are not compatible.public ValueAxis getRangeAxis()
public void setRangeAxis(ValueAxis axis) throws AxisNotCompatibleException
An exception is thrown if the new axis and the plot are not mutually compatible.
axis
- The new axis.AxisNotCompatibleException
- if axis are not compatible.public abstract boolean isCompatibleDomainAxis(CategoryAxis axis)
axis
- The proposed axis.true
if the axis is compatible with the plot.public abstract boolean isCompatibleRangeAxis(ValueAxis axis)
axis
- The proposed axis.true
if the axis is compatible with the plot.public abstract double getCategoryCoordinate(int category, java.awt.geom.Rectangle2D area)
category
- The category (zero-based index).area
- The region within which the plot will be drawn.public void zoom(double percent)
If the value 0.0 is passed in as the zoom percent, the auto-range calculation for the axis is restored (which sets the range to include the minimum and maximum data values, thus displaying all the data).
zoom
in class Plot
percent
- The zoom amount.public boolean getLabelsVisible()
public boolean getValueLabelsVisible()
public void setLabelsVisible(boolean flag)
Registered listeners are notified of a general change to the axis.
flag
- the flag.public void setValueLabelsVisible(boolean flag)
Registered listeners are notified of a general change to the axis.
Not all renderers support this yet.
flag
- the flag.public void setLabelFont(java.awt.Font font)
Notifies registered listeners that the plot has been changed.
font
- The new value label font.public java.awt.Font getLabelFont()
public void setLabelPaint(java.awt.Paint paint)
Notifies registered listeners that the plot has been changed.
paint
- The new value label paint.public java.awt.Paint getLabelPaint()
public void setLabelFormatString(java.lang.String format)
Notifies registered listeners that the plot has been changed.
format
- The new value label format pattern. Use null
if labels are
not to be shown.public java.text.NumberFormat getLabelFormatter()
public boolean getVerticalLabels()
public void setVerticalLabels(boolean flag)
flag
- The flag.public void datasetChanged(DatasetChangeEvent event)
The chart reacts by passing on a chart change event to all registered listeners.
datasetChanged
in class Plot
event
- Information about the event (not used here).public void addRangeMarker(Marker marker)
Typically a marker will be drawn by the renderer as a line perpendicular to the range axis, however this is entirely up to the renderer.
marker
- The marker.public void clearRangeMarkers()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |