de.unidu.is.gnuplot
Class DataSource

java.lang.Object
  extended byde.unidu.is.gnuplot.Source
      extended byde.unidu.is.gnuplot.FileSource
          extended byde.unidu.is.gnuplot.DataSource
Direct Known Subclasses:
ArrayDataSource

public abstract class DataSource
extends FileSource

An abstract class describing a single plot curve which is defined by data points (instead of a function).

For using this class, the name of the data output file has to be specified. For constructing the data file inside of getCommand(), the program iterates through (x,y) data pairs with next() together with getX() and getY():

   while(next()) {
       double x = getX(); // current x
       double y = getY(); // current y
       doSomething(x,y);
   }
 
Thus, one instance can only be used once for iterating.

This class has to be subclassed for specific application areas.

Since:
2002-04-10
Version:
$Revision: 1.4 $, $Date: 2005/02/21 17:29:18 $
Author:
Henrik Nottelmann

Field Summary
 
Fields inherited from class de.unidu.is.gnuplot.FileSource
filename, nosmooth
 
Fields inherited from class de.unidu.is.gnuplot.Source
max, min, title
 
Constructor Summary
DataSource(java.lang.String title, java.lang.String filename)
          Creates a new instance.
 
Method Summary
 java.lang.String getCommand()
          Creates the datafile and returns a gnuplot expression defining the data file for the gnuplot plot command (with smooth unique is set).
abstract  double getX()
          Returns the x value of the current (x,y) data pair.
abstract  double getY()
          Returns the y value of the current (x,y) data pair.
abstract  boolean next()
          Switches to the next possible (x,y) data pair if possible.
 void write()
          Writes the data in the file.
 void write(java.io.Writer writer)
          Writes the data in the witer.
 
Methods inherited from class de.unidu.is.gnuplot.FileSource
getFilename, isSmooth, setFilename, setSmooth
 
Methods inherited from class de.unidu.is.gnuplot.Source
getMax, getMin, getTitle, setMax, setMin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSource

public DataSource(java.lang.String title,
                  java.lang.String filename)
Creates a new instance.

Parameters:
filename - name of the corresponding file with data points
Method Detail

write

public void write(java.io.Writer writer)
Writes the data in the witer.

Parameters:
writer - writer to which the file is written to

write

public void write()
Writes the data in the file.


getCommand

public java.lang.String getCommand()
Creates the datafile and returns a gnuplot expression defining the data file for the gnuplot plot command (with smooth unique is set).

Overrides:
getCommand in class FileSource
Returns:
gnuplot expression defining the function or data file

next

public abstract boolean next()
Switches to the next possible (x,y) data pair if possible.

This method has to be overridden in subclasses.

Returns:
true iff another data pair is available

getX

public abstract double getX()
Returns the x value of the current (x,y) data pair.

This method has to be overridden in subclasses.

Returns:
x value

getY

public abstract double getY()
Returns the y value of the current (x,y) data pair.

This method has to be overridden in subclasses.

Returns:
y value