Class CombinedDomainXYPlot

All Implemented Interfaces:
Serializable, Cloneable, EventListener, AnnotationChangeListener, AxisChangeListener, MarkerChangeListener, PlotChangeListener, RendererChangeListener, LegendItemSource, Pannable, ValueAxisPlot, Zoomable, PublicCloneable, DatasetChangeListener

public class CombinedDomainXYPlot extends XYPlot implements PlotChangeListener
An extension of XYPlot that contains multiple subplots that share a common domain axis.
See Also:
  • Constructor Details

    • CombinedDomainXYPlot

      Default constructor.
    • CombinedDomainXYPlot

      public CombinedDomainXYPlot(ValueAxis domainAxis)
      Creates a new combined plot that shares a domain axis among multiple subplots.
      Parameters:
      domainAxis - the shared axis.
  • Method Details

    • getPlotType

      public String getPlotType()
      Returns a string describing the type of plot.
      Overrides:
      getPlotType in class XYPlot
      Returns:
      The type of plot.
    • getGap

      public double getGap()
      Returns the gap between subplots, measured in Java2D units.
      Returns:
      The gap (in Java2D units).
      See Also:
    • setGap

      public void setGap(double gap)
      Sets the amount of space between subplots and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      gap - the gap between subplots (in Java2D units).
      See Also:
    • isRangePannable

      public boolean isRangePannable()
      Returns true if the range is pannable for at least one subplot, and false otherwise.
      Specified by:
      isRangePannable in interface Pannable
      Overrides:
      isRangePannable in class XYPlot
      Returns:
      A boolean.
    • setRangePannable

      public void setRangePannable(boolean pannable)
      Sets the flag, on each of the subplots, that controls whether or not the range is pannable.
      Overrides:
      setRangePannable in class XYPlot
      Parameters:
      pannable - the new flag value.
    • setOrientation

      public void setOrientation(PlotOrientation orientation)
      Sets the orientation for the plot (also changes the orientation for all the subplots to match).
      Overrides:
      setOrientation in class XYPlot
      Parameters:
      orientation - the orientation (null not allowed).
      See Also:
    • setShadowGenerator

      public void setShadowGenerator(ShadowGenerator generator)
      Sets the shadow generator for the plot (and all subplots) and sends a PlotChangeEvent to all registered listeners.
      Overrides:
      setShadowGenerator in class XYPlot
      Parameters:
      generator - the new generator (null permitted).
    • getDataRange

      public Range getDataRange(ValueAxis axis)
      Returns a range representing the extent of the data values in this plot (obtained from the subplots) that will be rendered against the specified axis. NOTE: This method is intended for internal JFreeChart use, and is public only so that code in the axis classes can call it. Since only the domain axis is shared between subplots, the JFreeChart code will only call this method for the domain values (although this is not checked/enforced).
      Specified by:
      getDataRange in interface ValueAxisPlot
      Overrides:
      getDataRange in class XYPlot
      Parameters:
      axis - the axis.
      Returns:
      The range (possibly null).
    • add

      public void add(XYPlot subplot)
      Adds a subplot (with a default 'weight' of 1) and sends a PlotChangeEvent to all registered listeners.

      The domain axis for the subplot will be set to null. You must ensure that the subplot has a non-null range axis.

      Parameters:
      subplot - the subplot (null not permitted).
    • add

      public void add(XYPlot subplot, int weight)
      Adds a subplot with the specified weight and sends a PlotChangeEvent to all registered listeners. The weight determines how much space is allocated to the subplot relative to all the other subplots.

      The domain axis for the subplot will be set to null. You must ensure that the subplot has a non-null range axis.

      Parameters:
      subplot - the subplot (null not permitted).
      weight - the weight (must be >= 1).
    • remove

      public void remove(XYPlot subplot)
      Removes a subplot from the combined chart and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      subplot - the subplot (null not permitted).
    • getSubplots

      public List<XYPlot> getSubplots()
      Returns the list of subplots. The returned list may be empty, but is never null.
      Returns:
      An unmodifiable list of subplots.
    • calculateAxisSpace

      Calculates the axis space required.
      Overrides:
      calculateAxisSpace in class XYPlot
      Parameters:
      g2 - the graphics device.
      plotArea - the plot area.
      Returns:
      The space.
    • draw

      public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info)
      Draws the plot within the specified area on a graphics device.
      Overrides:
      draw in class XYPlot
      Parameters:
      g2 - the graphics device.
      area - the plot area (in Java2D space).
      anchor - an anchor point in Java2D space (null permitted).
      parentState - the state from the parent plot, if there is one (null permitted).
      info - collects chart drawing information (null permitted).
    • getLegendItems

      Returns a collection of legend items for the plot.
      Specified by:
      getLegendItems in interface LegendItemSource
      Overrides:
      getLegendItems in class XYPlot
      Returns:
      The legend items.
    • zoomRangeAxes

      public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source)
      Multiplies the range on the range axis/axes by the specified factor.
      Specified by:
      zoomRangeAxes in interface Zoomable
      Overrides:
      zoomRangeAxes in class XYPlot
      Parameters:
      factor - the zoom factor.
      info - the plot rendering info (null not permitted).
      source - the source point (null not permitted).
      See Also:
    • zoomRangeAxes

      public void zoomRangeAxes(double factor, PlotRenderingInfo state, Point2D source, boolean useAnchor)
      Multiplies the range on the range axis/axes by the specified factor.
      Specified by:
      zoomRangeAxes in interface Zoomable
      Overrides:
      zoomRangeAxes in class XYPlot
      Parameters:
      factor - the zoom factor.
      state - the plot state.
      source - the source point (in Java2D coordinates).
      useAnchor - use source point as zoom anchor?
      See Also:
    • zoomRangeAxes

      public void zoomRangeAxes(double lowerPercent, double upperPercent, PlotRenderingInfo info, Point2D source)
      Zooms in on the range axes.
      Specified by:
      zoomRangeAxes in interface Zoomable
      Overrides:
      zoomRangeAxes in class XYPlot
      Parameters:
      lowerPercent - the lower bound.
      upperPercent - the upper bound.
      info - the plot rendering info (null not permitted).
      source - the source point (null not permitted).
      See Also:
    • panRangeAxes

      public void panRangeAxes(double panRange, PlotRenderingInfo info, Point2D source)
      Pans all range axes by the specified percentage.
      Specified by:
      panRangeAxes in interface Pannable
      Overrides:
      panRangeAxes in class XYPlot
      Parameters:
      panRange - the distance to pan (as a percentage of the axis length).
      info - the plot info (null not permitted).
      source - the source point where the pan action started.
    • findSubplot

      public XYPlot findSubplot(PlotRenderingInfo info, Point2D source)
      Returns the subplot (if any) that contains the (x, y) point (specified in Java2D space).
      Parameters:
      info - the chart rendering info (null not permitted).
      source - the source point (null not permitted).
      Returns:
      A subplot (possibly null).
    • 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.
      See Also:
    • setFixedRangeAxisSpace

      public void setFixedRangeAxisSpace(AxisSpace space)
      Sets the fixed range axis space and sends a PlotChangeEvent to all registered listeners.
      Overrides:
      setFixedRangeAxisSpace in class XYPlot
      Parameters:
      space - the space (null permitted).
      See Also:
    • setFixedRangeAxisSpaceForSubplots

      Sets the size (width or height, depending on the orientation of the plot) for the domain axis of each subplot.
      Parameters:
      space - the space.
    • handleClick

      public void handleClick(int x, int y, PlotRenderingInfo info)
      Handles a 'click' on the plot by updating the anchor values.
      Overrides:
      handleClick in class XYPlot
      Parameters:
      x - x-coordinate, where the click occurred.
      y - y-coordinate, where the click occurred.
      info - object containing information about the plot dimensions.
    • datasetChanged

      public void datasetChanged(DatasetChangeEvent event)
      Receives notification of a change to the plot's dataset.

      The axis ranges are updated if necessary.

      Specified by:
      datasetChanged in interface DatasetChangeListener
      Overrides:
      datasetChanged in class XYPlot
      Parameters:
      event - information about the event (not used here).
    • plotChanged

      public void plotChanged(PlotChangeEvent event)
      Receives a PlotChangeEvent and responds by notifying all listeners.
      Specified by:
      plotChanged in interface PlotChangeListener
      Parameters:
      event - the event.
    • equals

      public boolean equals(Object obj)
      Tests this plot for equality with another object.
      Overrides:
      equals in class XYPlot
      Parameters:
      obj - the other object.
      Returns:
      true or false.
    • clone

      Returns a clone of the annotation.
      Specified by:
      clone in interface PublicCloneable
      Overrides:
      clone in class XYPlot
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - this class will not throw this exception, but subclasses (if any) might.