Module platform

Class FastScatterPlot

java.lang.Object
org.jfree.chart.plot.Plot
org.jfree.chart.plot.FastScatterPlot
All Implemented Interfaces:
Disposable, Serializable, Cloneable, EventListener, AnnotationChangeListener, AxisChangeListener, MarkerChangeListener, LegendItemSource, Pannable, ValueAxisPlot, Zoomable, PublicCloneable, DatasetChangeListener

public class FastScatterPlot extends Plot implements ValueAxisPlot, Pannable, Zoomable, Cloneable, Serializable
A fast scatter plot.
See Also:
  • Field Details

    • DEFAULT_GRIDLINE_STROKE

      public static final Stroke DEFAULT_GRIDLINE_STROKE
      The default grid line stroke.
    • DEFAULT_GRIDLINE_PAINT

      public static final Paint DEFAULT_GRIDLINE_PAINT
      The default grid line paint.
    • localizationResources

      protected static ResourceBundle localizationResources
      The resourceBundle for the localization.
  • Constructor Details

    • FastScatterPlot

      public FastScatterPlot()
      Creates a new instance of FastScatterPlot with default axes.
    • FastScatterPlot

      public FastScatterPlot(float[][] data, ValueAxis domainAxis, ValueAxis rangeAxis)
      Creates a new fast scatter plot.

      The data is an array of x, y values: data[0][i] = x, data[1][i] = y.

      Parameters:
      data - the data (null permitted).
      domainAxis - the domain (x) axis (null not permitted).
      rangeAxis - the range (y) axis (null not permitted).
  • Method Details

    • getPlotType

      public String getPlotType()
      Returns a short string describing the plot type.
      Specified by:
      getPlotType in class Plot
      Returns:
      A short string describing the plot type.
    • getData

      public float[][] getData()
      Returns the data array used by the plot.
      Returns:
      The data array (possibly null).
      See Also:
    • setData

      public void setData(float[][] data)
      Sets the data array used by the plot and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      data - the data array (null permitted).
      See Also:
    • getOrientation

      public PlotOrientation getOrientation()
      Returns the orientation of the plot.
      Specified by:
      getOrientation in interface Pannable
      Specified by:
      getOrientation in interface Zoomable
      Returns:
      The orientation (always PlotOrientation.VERTICAL).
    • getDomainAxis

      public ValueAxis getDomainAxis()
      Returns the domain axis for the plot.
      Returns:
      The domain axis (never null).
      See Also:
    • setDomainAxis

      public void setDomainAxis(ValueAxis axis)
      Sets the domain axis and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      axis - the axis (null not permitted).
      See Also:
    • getRangeAxis

      public ValueAxis getRangeAxis()
      Returns the range axis for the plot.
      Returns:
      The range axis (never null).
      See Also:
    • setRangeAxis

      public void setRangeAxis(ValueAxis axis)
      Sets the range axis and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      axis - the axis (null not permitted).
      See Also:
    • getPaint

      public Paint getPaint()
      Returns the paint used to plot data points. The default is Color.RED.
      Returns:
      The paint.
      See Also:
    • setPaint

      public void setPaint(Paint paint)
      Sets the color for the data points and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      paint - the paint (null not permitted).
      See Also:
    • isDomainGridlinesVisible

      public boolean isDomainGridlinesVisible()
      Returns true if the domain gridlines are visible, and false otherwise.
      Returns:
      true or false.
      See Also:
    • setDomainGridlinesVisible

      public void setDomainGridlinesVisible(boolean visible)
      Sets the flag that controls whether or not the domain grid-lines are visible. If the flag value is changed, a PlotChangeEvent is sent to all registered listeners.
      Parameters:
      visible - the new value of the flag.
      See Also:
    • getDomainGridlineStroke

      public Stroke getDomainGridlineStroke()
      Returns the stroke for the grid-lines (if any) plotted against the domain axis.
      Returns:
      The stroke (never null).
      See Also:
    • setDomainGridlineStroke

      public void setDomainGridlineStroke(Stroke stroke)
      Sets the stroke for the grid lines plotted against the domain axis and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      stroke - the stroke (null not permitted).
      See Also:
    • getDomainGridlinePaint

      public Paint getDomainGridlinePaint()
      Returns the paint for the grid lines (if any) plotted against the domain axis.
      Returns:
      The paint (never null).
      See Also:
    • setDomainGridlinePaint

      public void setDomainGridlinePaint(Paint paint)
      Sets the paint for the grid lines plotted against the domain axis and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      paint - the paint (null not permitted).
      See Also:
    • isRangeGridlinesVisible

      public boolean isRangeGridlinesVisible()
      Returns true if the range axis grid is visible, and false otherwise.
      Returns:
      true or false.
      See Also:
    • setRangeGridlinesVisible

      public void setRangeGridlinesVisible(boolean visible)
      Sets the flag that controls whether or not the range axis grid lines are visible. If the flag value is changed, a PlotChangeEvent is sent to all registered listeners.
      Parameters:
      visible - the new value of the flag.
      See Also:
    • getRangeGridlineStroke

      public Stroke getRangeGridlineStroke()
      Returns the stroke for the grid lines (if any) plotted against the range axis.
      Returns:
      The stroke (never null).
      See Also:
    • setRangeGridlineStroke

      public void setRangeGridlineStroke(Stroke stroke)
      Sets the stroke for the grid lines plotted against the range axis and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      stroke - the stroke (null permitted).
      See Also:
    • getRangeGridlinePaint

      public Paint getRangeGridlinePaint()
      Returns the paint for the grid lines (if any) plotted against the range axis.
      Returns:
      The paint (never null).
      See Also:
    • setRangeGridlinePaint

      public void setRangeGridlinePaint(Paint paint)
      Sets the paint for the grid lines plotted against the range axis and sends a PlotChangeEvent to all registered listeners.
      Parameters:
      paint - the paint (null not permitted).
      See Also:
    • draw

      public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info)
      Draws the fast scatter plot on a Java 2D graphics device (such as the screen or a printer).
      Specified by:
      draw in class Plot
      Parameters:
      g2 - the graphics device.
      area - the area within which the plot (including axis labels) should be drawn.
      anchor - the anchor point (null permitted).
      parentState - the state from the parent plot (ignored).
      info - collects chart drawing information (null permitted).
    • render

      public void render(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, CrosshairState crosshairState)
      Draws a representation of the data within the dataArea region. The info and crosshairState arguments may be null.
      Parameters:
      g2 - the graphics device.
      dataArea - the region in which the data is to be drawn.
      info - an optional object for collection dimension information.
      crosshairState - collects crosshair information (null permitted).
    • drawDomainGridlines

      protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks)
      Draws the gridlines for the plot, if they are visible.
      Parameters:
      g2 - the graphics device.
      dataArea - the data area.
      ticks - the ticks.
    • drawRangeGridlines

      protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks)
      Draws the gridlines for the plot, if they are visible.
      Parameters:
      g2 - the graphics device.
      dataArea - the data area.
      ticks - the ticks.
    • getDataRange

      public Range getDataRange(ValueAxis axis)
      Returns the range of data values to be plotted along the axis, or null if the specified axis isn't the domain axis or the range axis for the plot.
      Specified by:
      getDataRange in interface ValueAxisPlot
      Parameters:
      axis - the axis (null permitted).
      Returns:
      The range (possibly null).
    • zoomDomainAxes

      public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source)
      Multiplies the range on the domain axis by the specified factor.
      Specified by:
      zoomDomainAxes in interface Zoomable
      Parameters:
      factor - the zoom factor.
      info - the plot rendering info.
      source - the source point.
      See Also:
    • zoomDomainAxes

      public void zoomDomainAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor)
      Multiplies the range on the domain axis by the specified factor.
      Specified by:
      zoomDomainAxes in interface Zoomable
      Parameters:
      factor - the zoom factor.
      info - the plot rendering info.
      source - the source point (in Java2D space).
      useAnchor - use source point as zoom anchor?
      See Also:
    • zoomDomainAxes

      public void zoomDomainAxes(double lowerPercent, double upperPercent, PlotRenderingInfo info, Point2D source)
      Zooms in on the domain axes.
      Specified by:
      zoomDomainAxes in interface Zoomable
      Parameters:
      lowerPercent - the new lower bound as a percentage of the current range.
      upperPercent - the new upper bound as a percentage of the current range.
      info - the plot rendering info.
      source - the source point.
      See Also:
    • 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
      Parameters:
      factor - the zoom factor.
      info - the plot rendering info.
      source - the source point.
      See Also:
    • zoomRangeAxes

      public void zoomRangeAxes(double factor, PlotRenderingInfo info, Point2D source, boolean useAnchor)
      Multiplies the range on the range axis by the specified factor.
      Specified by:
      zoomRangeAxes in interface Zoomable
      Parameters:
      factor - the zoom factor.
      info - the plot rendering info.
      source - the source point (in Java2D space).
      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
      Parameters:
      lowerPercent - the new lower bound as a percentage of the current range.
      upperPercent - the new upper bound as a percentage of the current range.
      info - the plot rendering info.
      source - the source point.
      See Also:
    • isDomainZoomable

      public boolean isDomainZoomable()
      Returns true.
      Specified by:
      isDomainZoomable in interface Zoomable
      Returns:
      A boolean.
      See Also:
    • isRangeZoomable

      public boolean isRangeZoomable()
      Returns true.
      Specified by:
      isRangeZoomable in interface Zoomable
      Returns:
      A boolean.
      See Also:
    • isDomainPannable

      public boolean isDomainPannable()
      Returns true if panning is enabled for the domain axes, and false otherwise.
      Specified by:
      isDomainPannable in interface Pannable
      Returns:
      A boolean.
    • setDomainPannable

      public void setDomainPannable(boolean pannable)
      Sets the flag that enables or disables panning of the plot along the domain axes.
      Parameters:
      pannable - the new flag value.
    • isRangePannable

      public boolean isRangePannable()
      Returns true if panning is enabled for the range axes, and false otherwise.
      Specified by:
      isRangePannable in interface Pannable
      Returns:
      A boolean.
    • setRangePannable

      public void setRangePannable(boolean pannable)
      Sets the flag that enables or disables panning of the plot along the range axes.
      Parameters:
      pannable - the new flag value.
    • panDomainAxes

      public void panDomainAxes(double percent, PlotRenderingInfo info, Point2D source)
      Pans the domain axes by the specified percentage.
      Specified by:
      panDomainAxes in interface Pannable
      Parameters:
      percent - the distance to pan (as a percentage of the axis length).
      info - the plot info
      source - the source point where the pan action started.
    • panRangeAxes

      public void panRangeAxes(double percent, PlotRenderingInfo info, Point2D source)
      Pans the range axes by the specified percentage.
      Specified by:
      panRangeAxes in interface Pannable
      Parameters:
      percent - the distance to pan (as a percentage of the axis length).
      info - the plot info
      source - the source point where the pan action started.
    • equals

      public boolean equals(Object obj)
      Tests an arbitrary object for equality with this plot. Note that FastScatterPlot carries its data around with it (rather than referencing a dataset), and the data is included in the equality test.
      Overrides:
      equals in class Plot
      Parameters:
      obj - the object (null permitted).
      Returns:
      A boolean.
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns a clone of the plot.
      Specified by:
      clone in interface PublicCloneable
      Overrides:
      clone in class Plot
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - if some component of the plot does not support cloning.
    • dispose

      public void dispose()
      Specified by:
      dispose in interface Disposable