Class ScatterPlot

java.lang.Object
net.sf.basedb.util.plot.ScatterPlot

public class ScatterPlot
extends Object
A simple plot utility for generating scatter plots without the need to delve deep into the JFreePlot package. Note! This class is experimental and it is likely that the implementation will change in the future.
Version:
2.0
Author:
Nicklas
Last modified
$Date: 2015-05-12 11:27:08 +0200 (ti, 12 maj 2015) $
  • Field Details

  • Constructor Details

    • ScatterPlot

      public ScatterPlot​(String nameX, String nameY)
      Create a new ScatterPlot.
      Parameters:
      nameX - The label on the X-axis
      nameY - The label on the Y-axis
  • Method Details

    • addData

      public void addData​(SqlResultIterator data, String... names) throws SQLException
      Add data to the plot. The SqlResultIterator should return the x value as a float in the first position, ie. data.getFloat(1) and y values in the positions 2 and up.
      Parameters:
      data - The data to plot
      names - An array of series names, x-value for series 'i' is found in data.getFloat(2+i)
      Throws:
      SQLException
    • addData

      public void addData​(SqlResultIterator data, Collection<PlotAnnotation> annotations) throws SQLException
      Add data to the plot. The SqlResultIterator must return at least 3 columns. The first column in the result is used to determine which annotation/series the spot belongs to. The second column is the x value and the third column is the y value. Additional columns are not used.

      The annotations collection contains the mappings from the actual value to the annotation. Ie. if the result contains a 1 in the first column we check which annotation returns a 1 in it's PlotAnnotation.getValues() method. One value may not be used by more than one annotation.

      Parameters:
      data - The data to plot
      annotations - Annotation information that maps each data spot to an annotation
      Throws:
      SQLException
    • getChart

      public JFreeChart getChart()
      Get the underlying JFreeChar object. Use this method to polish up everything and save the image.