com.jrefinery.chart
Class HorizontalCategoryPlot

java.lang.Object
  extended by com.jrefinery.chart.Plot
      extended by com.jrefinery.chart.CategoryPlot
          extended by com.jrefinery.chart.HorizontalCategoryPlot
All Implemented Interfaces:
AxisConstants, CategoryPlotConstants, com.jrefinery.chart.event.AxisChangeListener, HorizontalValuePlot, DatasetChangeListener

public class HorizontalCategoryPlot
extends CategoryPlot
implements HorizontalValuePlot

A class that plots data from a CategoryDataset, with the values plotted along the horizontal axis and the categories plotted along the vertical axis. A plug-in class that implements the CategoryItemRenderer class is used to draw individual data items.

See Also:
CategoryPlot, 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
HorizontalCategoryPlot(CategoryDataset data, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryItemRenderer renderer)
          Constructs a horizontal category plot.
HorizontalCategoryPlot(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 alpha, double introGapPercent, double trailGapPercent, double categoryGapPercent, double itemGapPercent)
          Constructs a horizontal 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.
 Range getHorizontalDataRange()
          Returns the data range for the horizontal axis.
 ValueAxis getHorizontalValueAxis()
          Returns the horizontal axis.
 java.lang.String getPlotType()
          Returns a short string describing the type of plot.
 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

HorizontalCategoryPlot

public HorizontalCategoryPlot(CategoryDataset data,
                              CategoryAxis domainAxis,
                              ValueAxis rangeAxis,
                              CategoryItemRenderer renderer)
Constructs a horizontal category plot.

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

HorizontalCategoryPlot

public HorizontalCategoryPlot(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 alpha,
                              double introGapPercent,
                              double trailGapPercent,
                              double categoryGapPercent,
                              double itemGapPercent)
Constructs a horizontal category plot.

Parameters:
domainAxis - The domain axis.
rangeAxis - The range 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.
alpha - The alpha-transparency for the plot.
introGapPercent - The gap before the first bar in the plot.
trailGapPercent - The gap after the last bar in the plot.
categoryGapPercent - 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.
renderer - The renderer for the plot.
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.

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 proposed 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 - A structure for passing back information about the chart drawing (ignored if null).

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.
tooltips - A collection of tooltips.
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 short string describing the plot type.

getHorizontalDataRange

public Range getHorizontalDataRange()
Returns the data range for the horizontal axis.

Specified by:
getHorizontalDataRange in interface HorizontalValuePlot
Returns:
The range.

getHorizontalValueAxis

public ValueAxis getHorizontalValueAxis()
Returns the horizontal axis.

This method supports the HorizontalValuePlot interface.

Specified by:
getHorizontalValueAxis in interface HorizontalValuePlot
Returns:
The horizontal axis.

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.


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.