fern.tools.gnuplot
Class Axes

java.lang.Object
  extended by fern.tools.gnuplot.Axes
All Implemented Interfaces:
Iterable<String>
Direct Known Subclasses:
ArrayMatrixAxes, CollectionAxes

public abstract class Axes
extends Object
implements Iterable<String>

Contains the data columns for GnuPlot. GnuPlot has a list of Axes objects and assumes that each of these Axes object has one x column (the first one), optionally one y column and n value columns.

The main access point to the data is the Iterable interface which yields the tab separated values of each columns row by row.

It is possible to add other Axes object to an Axes object. So If you call the Iterable.iterator(), all of the columns of each attached Axes object will be yielded. Hence attached Axes objects must have the same number of rows (if they don't, an IllegalArgumentException will be thrown).

This class also manages labels and styles for each column. If you specify either of them, then either the length must be equal to the number of columns or 1 shorter (then the Axes objects knows that its first column is an x column).

The content of labels is directly passed to the plot command as title "label", the content of styles also is attached to the corresponding place in the plot command (e.g. styles[i]="with linespoints").

Author:
Florian Erhard

Field Summary
static int Additional
           
static int ThreeD
           
static int TwoD
           
 
Constructor Summary
Axes()
           
 
Method Summary
 void addAxes(Axes axes)
          Attaches an Axes object to this one.
 void applyDefaultStyle(String defaultStyle)
          Sets the style of each column to the default style except for columns that already have a style.
 int getDimensionType()
          Gets if this Axes object contains 2 or 3 dimensional data.
 String getLabel(int col)
          Gets the label for a column.
 Number getNumber(int row, int col)
          Gets the entry of this axes at the specified position.
abstract  int getNumColumns()
          Gets the number of columns.
abstract  int getNumRows()
          Gets the number of rows.
 String getStyle(int col)
          Gets the style for a column.
 Number getX(int row)
           
 void setLabel(int col, String label)
          Sets the label for a column.
 void setStyle(int col, String style)
          Sets the style for a column.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Iterable
iterator
 

Field Detail

TwoD

public static final int TwoD
See Also:
Constant Field Values

ThreeD

public static final int ThreeD
See Also:
Constant Field Values

Additional

public static final int Additional
See Also:
Constant Field Values
Constructor Detail

Axes

public Axes()
Method Detail

getDimensionType

public int getDimensionType()
Gets if this Axes object contains 2 or 3 dimensional data. If it is an additional axes object of another, it does not have a dimension. The dimension is infered by inspecting the number of labels and styles given.

Returns:
See Also:
TwoD, ThreeD, Additional

addAxes

public void addAxes(Axes axes)
Attaches an Axes object to this one. It cannot have an Axes object with an x axis (which means that the labels/styles array is 1 shorter then the number of columns).

Additionally the numbers of rows must be equal.

Parameters:
axes - the Axes object to attach

getNumColumns

public abstract int getNumColumns()
Gets the number of columns. The number of the attached Axes object is also included.

Returns:
number of columns.

getNumRows

public abstract int getNumRows()
Gets the number of rows.

Returns:
number of rows.

getX

public Number getX(int row)

getNumber

public Number getNumber(int row,
                        int col)
Gets the entry of this axes at the specified position.

Parameters:
row - the row of the entry
col - the col of the entry
Returns:
the entry

setLabel

public void setLabel(int col,
                     String label)
Sets the label for a column. If this Axes object has a x axis, the label of the 0th column cannot be set (because it is the x axis).

Parameters:
col - zero based index of the column
label - label for the column

getLabel

public String getLabel(int col)
Gets the label for a column. If this Axes object has a x axis, the label of the 0th column cannot be retrieved (because it is the x axis).

Parameters:
col - zero based index of the column
Returns:
label for the column

setStyle

public void setStyle(int col,
                     String style)
Sets the style for a column. If this Axes object has a x axis, the style of the 0th column cannot be set (because it is the x axis).

Parameters:
col - zero based index of the column
style - style for the column

getStyle

public String getStyle(int col)
Gets the style for a column. If this Axes object has a x axis, the style of the 0th column cannot be retrieved (because it is the x axis).

Parameters:
col - zero based index of the column style style for the column

applyDefaultStyle

public void applyDefaultStyle(String defaultStyle)
Sets the style of each column to the default style except for columns that already have a style.

Parameters:
defaultStyle - the default style to set