com.jrefinery.chart
Class CombinedXYPlot

java.lang.Object
  extended by com.jrefinery.chart.Plot
      extended by com.jrefinery.chart.XYPlot
          extended by com.jrefinery.chart.CombinedXYPlot
All Implemented Interfaces:
AxisConstants, com.jrefinery.chart.event.AxisChangeListener, HorizontalValuePlot, VerticalValuePlot, DatasetChangeListener, java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
SiamCombinedXYPlot

public class CombinedXYPlot
extends XYPlot

An extension of XYPlot that can contain multiple subplots, laid out horizontally or vertically.

This class was originally written by Bill Kelemen, and has since been modified extensively by David Gilbert.

Author:
Bill Kelemen (bill@kelemen-usa.com).

Field Summary
protected  double gap
          The gap between subplots.
static int HORIZONTAL
          Constant used to indicate horizontal layout.
protected  int seriesCount
          The total number of series in all subplots.
protected  java.awt.geom.Rectangle2D[] subPlotArea
          array holding subplot areas
protected  java.util.List subplots
          Storage for the subplot references.
protected  int totalWeight
          Total weight of all charts.
protected  int type
          The layout type (HORIZONTAL or VERTICAL).
static int VERTICAL
          Constant used to indicate vertical layout.
 
Fields inherited from class com.jrefinery.chart.XYPlot
domainAxis, horizontalColors, horizontalLines, parent, rangeAxis, renderer, verticalColors, verticalLines, weight
 
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.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
CombinedXYPlot(ValueAxis axis, int type)
          Creates a new MultiXYPlot.
 
Method Summary
 void add(XYPlot subplot, int weight)
          Adds a subplot with a particular weight (greater than or equal to one).
 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).
 Dataset getDataset(int plotNo)
          Method added by Sanghamitra
 Range getHorizontalDataRange()
          Returns the range of data values to be plotted along the horizontal axis.
 java.util.List getLegendItemLabels()
          Returns an array of labels to be displayed by the legend.
 int getNoSubPlot()
           
 java.lang.String getPlotType()
          Returns a string describing the type of plot.
 XYPlot getSubPlot(int plotNo)
          Method added by Sanghamitra
 Range getVerticalDataRange()
          Returns the range for the data to be plotted against the vertical axis.
 void handleClick(int x, int y, java.awt.geom.Rectangle2D plotArea)
           
 boolean isValidSubHorizontalAxis(Axis axis)
          Checks that the horizontal axis for the subplot is valid.
 boolean isValidSubVerticalAxis(Axis axis)
          Checks that the vertical axis for the subplot is valid.
protected  void setHorizontalAxisHeight(double height)
          Sets the height for the horizontal axis of each subplot.
protected  void setVerticalAxisWidth(double width)
          Sets the width for the vertical axis of each subplot.
 void test()
           
 void zoom(double percent)
          A zoom method that does nothing.
 
Methods inherited from class com.jrefinery.chart.XYPlot
addHorizontalLine, addHorizontalLine, addVerticalLine, addVerticalLine, datasetChanged, draw, draw, drawHorizontalLine, drawHorizontalLines, drawVerticalLine, drawVerticalLines, getDomainAxis, getHorizontalAxis, getHorizontalValueAxis, getItemRenderer, getParent, getRangeAxis, getSeriesCount, getVerticalAxis, getVerticalValueAxis, getWeight, getXYDataset, handleClick, isCompatibleDomainAxis, isCompatibleRangeAxis, isSubplot, propertyChange, render, setDomainAxis, setParent, setRangeAxis, setWeight, setXYItemRenderer
 
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
 

Field Detail

HORIZONTAL

public static final int HORIZONTAL
Constant used to indicate horizontal layout.

See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
Constant used to indicate vertical layout.

See Also:
Constant Field Values

type

protected int type
The layout type (HORIZONTAL or VERTICAL).


subplots

protected java.util.List subplots
Storage for the subplot references.


seriesCount

protected int seriesCount
The total number of series in all subplots.


totalWeight

protected int totalWeight
Total weight of all charts.


gap

protected double gap
The gap between subplots.


subPlotArea

protected java.awt.geom.Rectangle2D[] subPlotArea
array holding subplot areas

Constructor Detail

CombinedXYPlot

public CombinedXYPlot(ValueAxis axis,
                      int type)
Creates a new MultiXYPlot.

If the layout type is HORIZONTAL, you need to supply a vertical axis to be shared by the subplots. If the layout type is VERTICAL, you need to supply a horizontal axis to be shared by the subplots.

Parameters:
axis - The shared axis.
type - The layout type (HORIZONTAL or VERTICAL).
Method Detail

add

public void add(XYPlot subplot,
                int weight)
         throws AxisNotCompatibleException,
                java.lang.IllegalArgumentException
Adds a subplot with a particular weight (greater than or equal to one). The weight determines how much space is allocated to the subplot relative to all the other subplots.

The subplot should have a null horizontal axis (for VERTICAL layout) or a null vertical axis (for HORIZONTAL layout).

Parameters:
subplot - The subplot.
weight - The weight.
Throws:
AxisNotCompatibleException
java.lang.IllegalArgumentException

getSubPlot

public XYPlot getSubPlot(int plotNo)
Method added by Sanghamitra


getDataset

public Dataset getDataset(int plotNo)
Method added by Sanghamitra


getNoSubPlot

public int getNoSubPlot()

isValidSubHorizontalAxis

public boolean isValidSubHorizontalAxis(Axis axis)
Checks that the horizontal axis for the subplot is valid.

Note that for a VERTICAL layout, the horizontal axis must be null (since each subplot shares the horizontal axis maintained by this class).

Parameters:
axis - The horizontal axis.

isValidSubVerticalAxis

public boolean isValidSubVerticalAxis(Axis axis)
Checks that the vertical axis for the subplot is valid.

Note that for a HORIZONTAL layout, the vertical axis must be null (since each subplot shares the vertical axis maintained by this class).

Parameters:
axis - The vertical axis.

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). Will perform all the placement calculations for each sub-plots and then tell these to draw themselves.

Overrides:
draw in class XYPlot
Parameters:
g2 - The graphics device.
plotArea - The area within which the plot (including axis labels) should be drawn.
info - Information about the drawing.

handleClick

public void handleClick(int x,
                        int y,
                        java.awt.geom.Rectangle2D plotArea)
Overrides:
handleClick in class XYPlot

setHorizontalAxisHeight

protected void setHorizontalAxisHeight(double height)
Sets the height for the horizontal axis of each subplot.

Parameters:
height - The height.

setVerticalAxisWidth

protected void setVerticalAxisWidth(double width)
Sets the width for the vertical axis of each subplot.

Parameters:
width - The width.

zoom

public void zoom(double percent)
A zoom method that does nothing. TO BE DONE.

Overrides:
zoom in class XYPlot
Parameters:
percent - The zoom percentage.

getLegendItemLabels

public java.util.List getLegendItemLabels()
Returns an array of labels to be displayed by the legend.

Overrides:
getLegendItemLabels in class XYPlot
Returns:
An array of legend item labels (or null).

getPlotType

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

Overrides:
getPlotType in class XYPlot
Returns:
The type of plot.

getHorizontalDataRange

public Range getHorizontalDataRange()
Description copied from interface: HorizontalValuePlot
Returns the range of data values to be plotted along the horizontal axis.

Specified by:
getHorizontalDataRange in interface HorizontalValuePlot
Overrides:
getHorizontalDataRange in class XYPlot
Returns:
The range.

getVerticalDataRange

public Range getVerticalDataRange()
Description copied from interface: VerticalValuePlot
Returns the range for the data to be plotted against the vertical axis.

Specified by:
getVerticalDataRange in interface VerticalValuePlot
Overrides:
getVerticalDataRange in class XYPlot
Returns:
The range.

test

public void test()


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.