org.jfree.chart.plot
Class CombinedXYPlot

java.lang.Object
  |
  +--org.jfree.chart.plot.Plot
        |
        +--org.jfree.chart.plot.XYPlot
              |
              +--org.jfree.chart.plot.CombinedXYPlot
All Implemented Interfaces:
AxisChangeListener, AxisConstants, DatasetChangeListener, java.util.EventListener, HorizontalValuePlot, java.beans.PropertyChangeListener, java.io.Serializable, VerticalValuePlot

public class CombinedXYPlot
extends XYPlot
implements java.io.Serializable

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).
See Also:
Serialized Form

Field Summary
static int HORIZONTAL
          Constant used to indicate horizontal layout.
static int VERTICAL
          Constant used to indicate vertical layout.
 
Fields inherited from class org.jfree.chart.plot.XYPlot
DEFAULT_CROSSHAIR_PAINT, DEFAULT_CROSSHAIR_STROKE, DEFAULT_CROSSHAIR_VISIBLE, DEFAULT_GRIDLINE_PAINT, DEFAULT_GRIDLINE_STROKE
 
Fields inherited from class org.jfree.chart.plot.Plot
DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, ZERO
 
Fields inherited from interface org.jfree.chart.axis.AxisConstants
BOTTOM, DEFAULT_AXIS_LABEL_FONT, DEFAULT_AXIS_LABEL_INSETS, DEFAULT_AXIS_LABEL_PAINT, DEFAULT_AXIS_VISIBLE, DEFAULT_TICK_LABEL_FONT, DEFAULT_TICK_LABEL_INSETS, DEFAULT_TICK_LABEL_PAINT, DEFAULT_TICK_LABELS_VISIBLE, DEFAULT_TICK_MARK_INSIDE_LENGTH, DEFAULT_TICK_MARK_OUTSIDE_LENGTH, DEFAULT_TICK_MARK_PAINT, DEFAULT_TICK_MARK_STROKE, DEFAULT_TICK_MARKS_VISIBLE, LEFT, RIGHT, TOP
 
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).
 boolean equals(java.lang.Object obj)
          Tests this plot for equality with another object.
 double getGap()
          Returns the space between subplots.
 Range getHorizontalDataRange(ValueAxis axis)
          Returns the range for the horizontal axis.
 LegendItemCollection getLegendItems()
          Returns a collection of legend items for the plot.
 java.lang.String getPlotType()
          Returns a string describing the type of plot.
 java.util.List getSubPlots()
          Returns the list of subplots.
 Range getVerticalDataRange(ValueAxis axis)
          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.
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 org.jfree.chart.plot.XYPlot
addAnnotation, addDomainMarker, addRangeMarker, addSecondaryRangeMarker, clearAnnotations, clearDomainMarkers, clearRangeMarkers, clearSecondaryRangeMarkers, datasetChanged, drawHorizontalLine, drawVerticalLine, getDomainAxis, getDomainAxisLocation, getDomainCrosshairPaint, getDomainCrosshairStroke, getDomainCrosshairValue, getDomainGridlinePaint, getDomainGridlineStroke, getHorizontalAxis, getHorizontalValueAxis, getRangeAxis, getRangeAxisLocation, getRangeCrosshairPaint, getRangeCrosshairStroke, getRangeCrosshairValue, getRangeGridlinePaint, getRangeGridlineStroke, getRenderer, getSecondaryRangeAxis, getSecondaryRenderer, getSecondaryXYDataset, getSeriesCount, getVerticalAxis, getVerticalValueAxis, getWeight, getXYDataset, handleClick, isCompatibleDomainAxis, isCompatibleRangeAxis, isDomainCrosshairLockedOnData, isDomainCrosshairVisible, isDomainGridlinesVisible, isRangeCrosshairLockedOnData, isRangeCrosshairVisible, isRangeGridlinesVisible, propertyChange, render, render2, setDomainAxis, setDomainAxisLocation, setDomainAxisLocation, setDomainCrosshairLockedOnData, setDomainCrosshairPaint, setDomainCrosshairStroke, setDomainCrosshairValue, setDomainCrosshairValue, setDomainCrosshairVisible, setDomainGridlinePaint, setDomainGridlineStroke, setDomainGridlinesVisible, setRangeAxis, setRangeAxisLocation, setRangeAxisLocation, setRangeCrosshairLockedOnData, setRangeCrosshairPaint, setRangeCrosshairStroke, setRangeCrosshairValue, setRangeCrosshairValue, setRangeCrosshairVisible, setRangeGridlinePaint, setRangeGridlineStroke, setRangeGridlinesVisible, setSecondaryRangeAxis, setSecondaryRenderer, setWeight
 
Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, axisChanged, drawBackground, drawNoDataMessage, drawOutline, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundPaint, getDataAreaRatio, getDataset, getDatasetGroup, getForegroundAlpha, getInsets, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOppositeAxisLocation, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, getSecondaryDataset, isSubplot, notifyListeners, removeChangeListener, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundPaint, setDataAreaRatio, setDataset, setDatasetGroup, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setOutlinePaint, setOutlineStroke, setParent, setSecondaryDataset
 
Methods inherited from class java.lang.Object
clone, 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
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

getSubPlots

public java.util.List getSubPlots()
Returns the list of subplots.

Returns:
the list of subplots.

getGap

public double getGap()
Returns the space between subplots.

Returns:
the gap

setGap

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

Parameters:
gap - the gap between subplots

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.

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(ValueAxis axis)
Returns the range for the horizontal axis. This is the combined range of all the subplots.

Specified by:
getHorizontalDataRange in interface HorizontalValuePlot
Overrides:
getHorizontalDataRange in class XYPlot
Parameters:
axis - the axis.
Returns:
the range.

getVerticalDataRange

public Range getVerticalDataRange(ValueAxis axis)
Returns the range for the vertical axis. This is the combined range of all the subplots.

Specified by:
getVerticalDataRange in interface VerticalValuePlot
Overrides:
getVerticalDataRange in class XYPlot
Parameters:
axis - the axis.
Returns:
the range.

setXYItemRenderer

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

Sets the XYItemRenderer for the plot.

Parameters:
renderer - the renderer.

equals

public boolean equals(java.lang.Object obj)
Tests this plot for equality with another object.

Overrides:
equals in class XYPlot
Parameters:
obj - the other object.
Returns:
true or false.