com.jrefinery.chart
Class CombinedXYPlot

java.lang.Object
  |
  +--com.jrefinery.chart.Plot
        |
        +--com.jrefinery.chart.XYPlot
              |
              +--com.jrefinery.chart.CombinedXYPlot
All Implemented Interfaces:
AxisChangeListener, AxisConstants, DatasetChangeListener, java.util.EventListener, HorizontalValuePlot, java.beans.PropertyChangeListener, VerticalValuePlot

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
static int HORIZONTAL
          Constant used to indicate horizontal layout.
static int VERTICAL
          Constant used to indicate vertical layout.
 
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, foregroundAlpha, insets, listenerList, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, noDataMessage, noDataMessageFont, 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_PAINT, DEFAULT_TICK_STROKE
 
Constructor Summary
CombinedXYPlot(ValueAxis axis, int type)
          Creates a new MultiXYPlot.
 
Method Summary
 void add(XYPlot subplot)
          Adds a subplot, with a default 'weight' of 1.
 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).
 double getGap()
          Returns the space between subplots.
 Range getHorizontalDataRange()
          Returns the range for the horizontal axis.
 java.util.List getLegendItemLabels()
          Deprecated. use getLegendItems.
 LegendItemCollection getLegendItems()
          Returns a collection of legend items for the plot.
 java.lang.String getPlotType()
          Returns a string describing the type of plot.
 Range getVerticalDataRange()
          Returns the range for the vertical axis.
 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.
 void setGap(double gap)
          Sets the amount of space between subplots.
protected  void setHorizontalAxisHeight(double height)
          Sets the height for the horizontal axis of each subplot.
 void setRenderer(XYItemRenderer renderer)
          Sets the item renderer FOR ALL SUBPLOTS.
 void setSeriesPaint(java.awt.Paint[] paint)
          Sets the paint used to color any shapes representing series FOR ALL SUBPLOTS.
protected  void setVerticalAxisWidth(double width)
          Sets the width for the vertical axis of each subplot.
 void setXYItemRenderer(XYItemRenderer renderer)
          Deprecated. use setRenderer(...) method.
 void zoom(double percent)
          A zoom method that (currently) does nothing.
 
Methods inherited from class com.jrefinery.chart.XYPlot
addAnnotation, addDomainMarker, addHorizontalLine, addHorizontalLine, addRangeMarker, addVerticalLine, addVerticalLine, clearAnnotations, clearDomainMarkers, clearRangeMarkers, datasetChanged, drawHorizontalLine, drawVerticalLine, getDomainAxis, getHorizontalAxis, getHorizontalValueAxis, getItemRenderer, getParent, getRangeAxis, getRenderer, getSeriesCount, getVerticalAxis, getVerticalValueAxis, getWeight, getXYDataset, handleClick, isCompatibleDomainAxis, isCompatibleRangeAxis, isSubplot, propertyChange, render, setDomainAxis, setParent, setRangeAxis, setWeight
 
Methods inherited from class com.jrefinery.chart.Plot
addChangeListener, axisChanged, drawNoDataMessage, drawOutlineAndBackground, getBackgroundAlpha, getBackgroundPaint, getDataset, getDatasetGroup, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getOutlinePaint, getOutlineStroke, getSeriesOutlinePaint, getSeriesOutlineStroke, getSeriesPaint, getSeriesStroke, getShape, getShape, getShapeFactory, notifyListeners, removeChangeListener, setBackgroundAlpha, setBackgroundImage, setBackgroundPaint, setDataset, setDatasetGroup, setForegroundAlpha, setInsets, setNoDataMessage, setNoDataMessageFont, setOutlinePaint, setOutlineStroke, setSeriesOutlinePaint, setSeriesOutlineStroke, setSeriesOutlineStroke, 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.

VERTICAL

public static final int VERTICAL
Constant used to indicate vertical layout.
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

setGap

public void setGap(double gap)
Sets the amount of space between subplots.
Parameters:
gap - the gap between subplots

getGap

public double getGap()
Returns the space between subplots.
Returns:
the gap

add

public void add(XYPlot subplot)
Adds a subplot, with a default 'weight' of 1.

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

Parameters:
subplot - the subplot.

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 - if axis are not compatible.
java.lang.IllegalArgumentException - if weight < 1

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.
Returns:
true if the horizontal axis for the subplot is valid.

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.
Returns:
true if the vertical axis for the subplot is valid.

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 - collects information about the drawing (null permitted).

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.

getLegendItems

public LegendItemCollection getLegendItems()
Returns a collection of legend items for the plot.
Overrides:
getLegendItems in class XYPlot
Returns:
the legend items.

getPlotType

public java.lang.String getPlotType()
Returns a string describing the type of plot.
Overrides:
getPlotType in class XYPlot
Returns:
the type of plot.

zoom

public void zoom(double percent)
A zoom method that (currently) does nothing.
Overrides:
zoom in class XYPlot
Parameters:
percent - the zoom percentage.

setSeriesPaint

public void setSeriesPaint(java.awt.Paint[] paint)
Sets the paint used to color any shapes representing series FOR ALL SUBPLOTS. Registered listeners are notified that the plot has been modified.

Note: usually you will want to set the colors independently for each subplot, which is NOT what this method does.

Overrides:
setSeriesPaint in class Plot
Parameters:
paint - an array of Paint objects used to color series.

setRenderer

public void setRenderer(XYItemRenderer renderer)
Sets the item renderer FOR ALL SUBPLOTS. Registered listeners are notified that the plot has been modified.

Note: usually you will want to set the renderer independently for each subplot, which is NOT what this method does.

Overrides:
setRenderer in class XYPlot
Parameters:
renderer - the new renderer.

getHorizontalDataRange

public Range getHorizontalDataRange()
Returns the range for the horizontal axis. This is the combined range of all the subplots.
Overrides:
getHorizontalDataRange in class XYPlot
Returns:
the range.

getVerticalDataRange

public Range getVerticalDataRange()
Returns the range for the vertical axis. This is the combined range of all the subplots.
Overrides:
getVerticalDataRange in class XYPlot
Returns:
the range.

setXYItemRenderer

public void setXYItemRenderer(XYItemRenderer renderer)
Deprecated. use setRenderer(...) method.

Sets the XYItemRenderer for the plot.
Overrides:
setXYItemRenderer in class XYPlot
Parameters:
renderer - the renderer.

getLegendItemLabels

public java.util.List getLegendItemLabels()
Deprecated. use getLegendItems.

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).