2.17.2: 2011-06-17

net.sf.basedb.util.plot
Class ScatterPlot

java.lang.Object
  extended by 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: 2009-07-29 08:43:03 +0200 (Wed, 29 Jul 2009) $

Field Summary
private  XYSeriesCollection allSeries
           
private  JFreeChart chart
           
private  XYPlot plot
           
 
Constructor Summary
ScatterPlot(String nameX, String nameY)
          Create a new ScatterPlot.
 
Method Summary
 void addData(SqlResultIterator data, Collection<PlotAnnotation> annotations)
          Add data to the plot.
 void addData(SqlResultIterator data, String... names)
          Add data to the plot.
 JFreeChart getChart()
          Get the underlying JFreeChar object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

plot

private XYPlot plot

allSeries

private XYSeriesCollection allSeries

chart

private JFreeChart chart
Constructor Detail

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 Detail

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.


2.17.2: 2011-06-17