halo.userinterface.gui.graphhandler
Class XYGraphConstructor

java.lang.Object
  extended by halo.userinterface.gui.graphhandler.XYGraphConstructor

public class XYGraphConstructor
extends java.lang.Object

Class for the generation and displaying of an XY graph with JFreeChart Provides methods for generating a plot from a file, but also for direct adding of number pairs or a whole list of number pairs

Author:
Stefanie Kaufmann

Constructor Summary
XYGraphConstructor(java.lang.String title, java.lang.String xlabel, java.lang.String ylabel)
          Constructs an empty graph constructor with a given title and axis labels
 
Method Summary
 void addData(double x, java.util.ArrayList<java.lang.Double> y)
          Adds a number of numerical (x,y) pairs to the graph (scatterplot) , but only if the number is the same as the number of existing series; this method should be used after 'addEmptySeries' to ensure no messing up of data that does not belong together
 void addData(double x, double y)
          Adds one single numerical pair to the graph, but only if there is only one series of data; this method should be used after 'addEmptySeries' to ensure no messing up of data that does not belong together
 void addEmptySeries(java.util.ArrayList<java.lang.String> titles)
          Creates a number of empty series and adds them to those yet existing
 void addEmptySeries(java.lang.String title)
          Creates one empty series and adds them to the existing ones
 void addSeries(java.util.ArrayList<Tuple<java.lang.Double,java.lang.Double>> list, java.lang.String title)
          Adds a list of numerical pairs to the graph
 void generateGraph()
          Generates a graph from the loaded data and displays it
 java.util.ArrayList<org.jfree.data.xy.XYSeries> getSeries()
          Returns the list of series
 void readInData(java.io.File dataSource)
          Reads in data from a given file and prepares it for plotting Structure of the input file has to be tabular, with first column giving the x-axis value, other columns giving corresponding y-axis values
 void saveGraph(java.io.File output)
          Saves the graph as a JPEG picture
 void savePlotFile(java.io.File output)
          Generates a plotting file with tab separations
 void setPoints(boolean[] points)
          Sets the point definitions
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XYGraphConstructor

public XYGraphConstructor(java.lang.String title,
                          java.lang.String xlabel,
                          java.lang.String ylabel)
Constructs an empty graph constructor with a given title and axis labels

Parameters:
title - Title of the graph
xlabel - Title of the x-axis
ylabel - Title of the y-axis
Method Detail

readInData

public void readInData(java.io.File dataSource)
Reads in data from a given file and prepares it for plotting Structure of the input file has to be tabular, with first column giving the x-axis value, other columns giving corresponding y-axis values

Parameters:
dataSource - A file containing data to be plotted

addSeries

public void addSeries(java.util.ArrayList<Tuple<java.lang.Double,java.lang.Double>> list,
                      java.lang.String title)
Adds a list of numerical pairs to the graph

Parameters:
list - A list of numerical pairs/tuples
title - The title of the list

addData

public void addData(double x,
                    double y)
Adds one single numerical pair to the graph, but only if there is only one series of data; this method should be used after 'addEmptySeries' to ensure no messing up of data that does not belong together

Parameters:
x - The x-axis value
y - The y-axis value

addData

public void addData(double x,
                    java.util.ArrayList<java.lang.Double> y)
Adds a number of numerical (x,y) pairs to the graph (scatterplot) , but only if the number is the same as the number of existing series; this method should be used after 'addEmptySeries' to ensure no messing up of data that does not belong together

Parameters:
x - A single x-value
y - A set of corresponding y-values

addEmptySeries

public void addEmptySeries(java.util.ArrayList<java.lang.String> titles)
Creates a number of empty series and adds them to those yet existing

Parameters:
titles - A number of titles for the empty series

addEmptySeries

public void addEmptySeries(java.lang.String title)
Creates one empty series and adds them to the existing ones

Parameters:
title - The title of this series

generateGraph

public void generateGraph()
Generates a graph from the loaded data and displays it


saveGraph

public void saveGraph(java.io.File output)
Saves the graph as a JPEG picture

Parameters:
output - The output file where it will be saved

savePlotFile

public void savePlotFile(java.io.File output)
Generates a plotting file with tab separations


setPoints

public void setPoints(boolean[] points)
Sets the point definitions

Parameters:
points - An array defining which series will be printed as points (TRUE) and which as lines (FALSE)

getSeries

public java.util.ArrayList<org.jfree.data.xy.XYSeries> getSeries()
Returns the list of series

Returns:
The list of series