com.jrefinery.chart
Class VerticalCategoryPlot

java.lang.Object
  extended by com.jrefinery.chart.Plot
      extended by com.jrefinery.chart.CategoryPlot
          extended by com.jrefinery.chart.VerticalCategoryPlot
All Implemented Interfaces:
AxisConstants, CategoryPlotConstants, com.jrefinery.chart.event.AxisChangeListener, VerticalValuePlot, DatasetChangeListener
Direct Known Subclasses:
OverlaidVerticalCategoryPlot

public class VerticalCategoryPlot
extends CategoryPlot
implements VerticalValuePlot

A general class for plotting vertical category charts (bars/lines/shapes), using data from any class that implements the CategoryDataset interface.

The plot relies on a renderer to draw the individual data items, giving some flexibility to change the visual representation of the data.

See Also:
Plot, CategoryItemRenderer

Field Summary
 
Fields inherited from class com.jrefinery.chart.CategoryPlot
categoryGapsPercent, domainAxis, introGapPercent, itemGapsPercent, labelFont, labelFormatPattern, labelFormatter, labelPaint, labelsVisible, markers, parent, rangeAxis, renderer, trailGapPercent, verticalLabels
 
Fields inherited from class com.jrefinery.chart.Plot
backgroundAlpha, backgroundImage, backgroundPaint, dataset, DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, firstSeriesIndex, foregroundAlpha, insets, listeners, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, outlinePaint, outlineStroke, seriesOutlinePaint, seriesOutlineStroke, seriesPaint, seriesStroke, shapeFactory, ZERO
 
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_STROKE
 
Constructor Summary
VerticalCategoryPlot(CategoryDataset data, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryItemRenderer renderer)
          Constructs a new vertical category plot.
VerticalCategoryPlot(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 categoryGapPercent, double itemGapPercent)
          Constructs a new vertical category plot.
 
Method Summary
 void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D plotArea, ChartRenderingInfo info)
          Draws the plot on a Java 2D graphics device (such as the screen or a printer).
 double getCategoryCoordinate(int category, java.awt.geom.Rectangle2D area)
          Returns the x-coordinate (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.
 java.lang.Number getMaximumVerticalDataValue()
          Returns the maximum value in the range (since the range values are plotted against the vertical axis by this plot).
 java.lang.Number getMinimumVerticalDataValue()
          Returns the minimum value in the range (since this is plotted against the vertical axis by VerticalBarPlot).
 java.lang.String getPlotType()
          Returns a short string describing the type of plot.
 Range getVerticalDataRange()
          Returns the range of data values that will be plotted against the range axis.
 ValueAxis getVerticalValueAxis()
          Returns the vertical value axis.
 void handleClick(int x, int y, ChartRenderingInfo info)
          Handles a 'click' on the plot by updating the anchor values.
 boolean isCompatibleDomainAxis(CategoryAxis axis)
          Checks the compatibility of a domain axis, returning true if the axis is compatible with the plot, and false otherwise.
 boolean isCompatibleHorizontalAxis(Axis axis)
          Checks the compatibility of a horizontal axis, returning true if the axis is compatible with the plot, and false otherwise.
 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 isCompatibleVerticalAxis(Axis axis)
          Checks the compatibility of a vertical axis, returning true if the axis is compatible with the plot, and false otherwise.
 void render(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D dataArea, ChartRenderingInfo info, java.awt.Shape backgroundPlotArea)
          Draws a representation of the data within the dataArea region, using the current renderer.
 
Methods inherited from class com.jrefinery.chart.CategoryPlot
addRangeMarker, datasetChanged, getCategoryGapsPercent, getDomainAxis, getIntroGapPercent, getItemGapsPercent, getLabelFont, getLabelFormatter, getLabelPaint, getLabelsVisible, getLegendItemLabels, getParent, getRangeAxis, getRenderer, getSeriesCount, getTrailGapPercent, getVerticalLabels, isSubplot, setCategoryGapsPercent, setDomainAxis, setIntroGapPercent, setItemGapsPercent, setLabelFont, setLabelFormatString, setLabelPaint, setLabelsVisible, setParent, setRangeAxis, setRenderer, setTrailGapPercent, setVerticalLabels, zoom
 
Methods inherited from class com.jrefinery.chart.Plot
addChangeListener, axisChanged, drawOutlineAndBackground, getBackgroundAlpha, getBackgroundPaint, getDataset, getFirstSeriesIndex, getForegroundAlpha, getInsets, getOutlinePaint, getOutlineStroke, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesStroke, getShape, getShape, getShapeFactory, notifyListeners, removeChangeListener, setBackgroundAlpha, setBackgroundImage, setBackgroundPaint, setDataset, setFirstSeriesIndex, setForegroundAlpha, setInsets, setOutlinePaint, setOutlineStroke, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, setSeriesPaint, setSeriesPaint, setSeriesStroke, setSeriesStroke, setShapeFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VerticalCategoryPlot

public VerticalCategoryPlot(CategoryDataset data,
                            CategoryAxis domainAxis,
                            ValueAxis rangeAxis,
                            CategoryItemRenderer renderer)
Constructs a new vertical category plot.

Parameters:
data - The dataset.
domainAxis - The domain axis.
rangeAxis - The range axis.
renderer - The renderer for the data.

VerticalCategoryPlot

public VerticalCategoryPlot(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 categoryGapPercent,
                            double itemGapPercent)
Constructs a new vertical category plot.

Parameters:
domainAxis - The horizontal axis.
rangelAxis - The vertical axis.
insets - The amount of space to leave blank around the edges of 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 an outline around the plot.
outlinePaint - The color used to draw an outline around the plot.
foregroundAlpha - The alpha-transparency for the plot.
introGapPercent - The gap before the first bar in the plot, as a percentage of the available drawing space.
trailGapPercent - The gap after the last bar in the plot, as a percentage of the available drawing space.
categoryGapPercent - The percentage of drawing space allocated to the gap between the last bar in one category and the first bar in the next category.
itemGapPercent - The gap between bars within the same category.
Method Detail

getCategoryDataset

public CategoryDataset getCategoryDataset()
A convenience method that returns the dataset for the plot, cast as a CategoryDataset.

Overrides:
getCategoryDataset in class CategoryPlot
Returns:
The category dataset.

getVerticalValueAxis

public ValueAxis getVerticalValueAxis()
Returns the vertical value axis.

This method supports the VerticalValuePlot interface.

Specified by:
getVerticalValueAxis in interface VerticalValuePlot
Returns:
The vertical axis.

getCategoryCoordinate

public double getCategoryCoordinate(int category,
                                    java.awt.geom.Rectangle2D area)
Returns the x-coordinate (in Java 2D User Space) of the center of the specified category.

Specified by:
getCategoryCoordinate in class CategoryPlot
Parameters:
category - The index of the category of interest (first category index = 0).
area - The region within which the plot will be drawn.

isCompatibleHorizontalAxis

public boolean isCompatibleHorizontalAxis(Axis axis)
Checks the compatibility of a horizontal axis, returning true if the axis is compatible with the plot, and false otherwise.

Parameters:
axis - The horizontal axis.

isCompatibleVerticalAxis

public boolean isCompatibleVerticalAxis(Axis axis)
Checks the compatibility of a vertical axis, returning true if the axis is compatible with the plot, and false otherwise.

Parameters:
axis - The vertical axis.

isCompatibleDomainAxis

public boolean isCompatibleDomainAxis(CategoryAxis axis)
Checks the compatibility of a domain axis, returning true if the axis is compatible with the plot, and false otherwise.

Specified by:
isCompatibleDomainAxis in class CategoryPlot
Parameters:
axis - The proposed axis.
Returns:
True if the axis is compatible with the plot, and false otherwise.

isCompatibleRangeAxis

public boolean isCompatibleRangeAxis(ValueAxis axis)
Checks the compatibility of a range axis, returning true if the axis is compatible with the plot, and false otherwise.

Specified by:
isCompatibleRangeAxis in class CategoryPlot
Parameters:
axis - The proposed axis.
Returns:
True if the axis is compatible with the plot, and false otherwise.

draw

public void draw(java.awt.Graphics2D g2,
                 java.awt.geom.Rectangle2D plotArea,
                 ChartRenderingInfo info)
Draws the plot on a Java 2D graphics device (such as the screen or a printer).

At your option, you may supply an instance of ChartRenderingInfo. If you do, it will be populated with information about the drawing, including various plot dimensions and tooltip info.

Specified by:
draw in class Plot
Parameters:
g2 - The graphics device.
plotArea - The area within which the plot should be drawn.
info - Collects info as the chart is drawn.

render

public void render(java.awt.Graphics2D g2,
                   java.awt.geom.Rectangle2D dataArea,
                   ChartRenderingInfo info,
                   java.awt.Shape backgroundPlotArea)
Draws a representation of the data within the dataArea region, using the current renderer.

Parameters:
g2 - The graphics device.
dataArea - The region in which the data is to be drawn.
info - An optional object for collection dimension information.
backgroundPlotArea - The chart's background area.

getPlotType

public java.lang.String getPlotType()
Returns a short string describing the type of plot.

Specified by:
getPlotType in class Plot
Returns:
A description.

getVerticalDataRange

public Range getVerticalDataRange()
Returns the range of data values that will be plotted against the range axis.

If the dataset is null, this method returns null.

Specified by:
getVerticalDataRange in interface VerticalValuePlot
Returns:
The data range.

getMinimumVerticalDataValue

public java.lang.Number getMinimumVerticalDataValue()
Returns the minimum value in the range (since this is plotted against the vertical axis by VerticalBarPlot).

This method will return null if the dataset is null.

Returns:
The minimum value.

getMaximumVerticalDataValue

public java.lang.Number getMaximumVerticalDataValue()
Returns the maximum value in the range (since the range values are plotted against the vertical axis by this plot).

This method will return null if the dataset is null.

Returns:
The maximum value.

handleClick

public void handleClick(int x,
                        int y,
                        ChartRenderingInfo info)
Handles a 'click' on the plot by updating the anchor values.

Overrides:
handleClick in class Plot
Parameters:
x - The x coordinate.
y - The y coordinate.
info - The dimensions of the plot.


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.