UI.Run.JSci
Class GEVAGraphModel

java.lang.Object
  extended by UI.Run.JSci.GEVAGraphModel
All Implemented Interfaces:
JSci.awt.Graph2DModel

public class GEVAGraphModel
extends java.lang.Object
implements JSci.awt.Graph2DModel

Override the JSci Graph2DModel to do some custom graph data extraction

Author:
eliott bartley

Constructor Summary
GEVAGraphModel()
           
 
Method Summary
 void addData(double[] data)
          Add a single instance of statistics data to each of the series
 void addGraphDataListener(JSci.awt.GraphDataListener listener)
           
 int addSeries()
          Add a new series to the graph
 float calcYExtremaMax()
          Calculate the maximum Y value on the graph.
 float calcYExtremaMin()
          Calculate the minimum Y value on the graph.
 void firstSeries()
          Set the active series to the first series.
 java.awt.Color getColour()
          Get the colour to render the active series in the GUI
 java.awt.Color getErrorColour()
          Get the colour to render the error series of the active series
 java.awt.Color getSeriesColour(int seriesIndex)
          Get the colour used when rendering the specified seriesIndex in the GUI
 int getSeriesErrorSeries(int seriesIndex)
          Get the seriesIndex that the specified seriesIndex is using as its error bars.
 int getSeriesLength(int seriesIndex)
          Get the total number of data indexes for the specified series.
 float getSeriesOffset(int seriesIndex)
          Get the vertical offset amount for the specified series. i.e. if the series has values in the range 50..100, and an offset of 10 is set for it, it will show its values in the range 60..110
 float getSeriesScale(int seriesIndex)
          Get the vertical scaling factor for the specified series. i.e. if the series has values in the range 50..100, and a scale of 0.5 is set for it, it will show its values in the range 25..50
 GEVAGraphStatistics getSeriesStatistics(int seriesIndex)
          Get statistical information about the specified series
 float getSeriesValue(int seriesIndex)
          Get the last data value recorded for this series
 float getSeriesValueAt(int seriesIndex, int dataIndex)
          Get the data value of a particular series at a particular point
 float getXCoord(int dataIndex)
          All data is recorded on integer steps, so this will always return the same value as what's passed in
 float getXExtremaMax()
          Get the maximum X value on the graph.
 float getXExtremaMin()
          The min will always be 0.
 float getYCoord(int dataIndex)
          Get the value that was recorded for the active series (see firstSeries/nextSeries) at the generation specified by dataIndex
 float getZCoord(int dataIndex)
          Get the error bar value that was recorded for the active series (see firstSeries/nextSeries) at the generation specified by dataIndex
 boolean hasErrorSeries()
          Get whether the active series has another series as its error series
 boolean isErrorSeries()
          Get whether the active series is an error series for another series
 boolean isErrorVisible()
          Get whether the error series of the active series is visible
 boolean isSelected()
          Get whether the active series is selected
 boolean isSeriesErrorSeries(int seriesIndex)
          Return whether the specified seriesIndex is the error bars of another seriesIndex
 boolean isSeriesSelected(int seriesIndex)
          Get whether the specified seriesIndex is highlighted in the GUI
 boolean isSeriesVisible(int seriesIndex)
          Get whether the specified seriesIndex is visible in the GUI
 boolean isVisible()
          Get whether the active series is visible
 boolean lastSeries()
          Get whether there are any more active series.
 boolean nextSeries()
          Set the active series to the next series.
 void removeGraphDataListener(JSci.awt.GraphDataListener listener)
           
 int seriesLength()
          Get the length of the active series (see firstSeries/nextSeries)
 void setSeriesColour(int seriesIndex, java.awt.Color colour)
          Set the colour used when rendering the specified seriesIndex in the GUI
 void setSeriesErrorSeries(int seriesIndex, int errorIndex)
          Set a seriesIndex to use another seriesIndex as its error bars.
 void setSeriesOffset(int seriesIndex, float offset)
          Set the vertical offset amount for the specified series. i.e. if the series has values in the range 50..100, and an offset of 10 is set for it, it will show its values ini the range 60..110
 void setSeriesOnTop(int seriesIndex)
          Set the specified series as being the most important.
 void setSeriesScale(int seriesIndex, float scale)
          Set the vertical scaling factor for the specified series. i.e. if the series has values in the range 50..100, and a scale of 0.5 is set for it, it will show its values in the range 25..50
 void setSeriesSelected(int seriesIndex, boolean selected)
          Set whether the specified seriesIndex should be highlighted in the GUI
 void setSeriesVisible(int seriesIndex, boolean visible)
          Set whether the specified seriesIndex should be visible in the GUI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GEVAGraphModel

public GEVAGraphModel()
Method Detail

addSeries

public int addSeries()
Add a new series to the graph

Returns:
Series index. Used in *Series* methods, e.g. getSeriesColour(..)

addData

public void addData(double[] data)
Add a single instance of statistics data to each of the series

Parameters:
data - Array of data, one for each series

getXExtremaMin

public float getXExtremaMin()
The min will always be 0. Should I have even bothered adding this method? Well I did!

Returns:
0, always 0. In fact, from now on, I'm never going to say zero again, I'll just say "get-x-extrama-min-open-bracket-close-bracket"!

getXExtremaMax

public float getXExtremaMax()
Get the maximum X value on the graph. This will be equal to the last generation parsed

Returns:
The maximum X value on the graph

calcYExtremaMin

public float calcYExtremaMin()
Calculate the minimum Y value on the graph. This is calculated by finding the minimum Y value across all visible statistics (invisible are ignored). Setting the graphs minimum Y value to this will pack the display to the visible data

Returns:
The minimum Y value on the graph

calcYExtremaMax

public float calcYExtremaMax()
Calculate the maximum Y value on the graph. This is calculated by finding the maximum Y value across all visible statistics (invisible are ignored). Setting the graphs maximum Y value to this will pack the display to the visible data

Returns:
The maximum Y value on the graph

getSeriesLength

public int getSeriesLength(int seriesIndex)
Get the total number of data indexes for the specified series. getSeriesValueAt(seriesIndex, dataIndex)'s dataIndex will run through [0..getSeriesLength(seriesIndex) - 1]

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
Returns:
The total number of data indexes

getSeriesStatistics

public GEVAGraphStatistics getSeriesStatistics(int seriesIndex)
Get statistical information about the specified series

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
Returns:
statistical information about the specified series

setSeriesScale

public void setSeriesScale(int seriesIndex,
                           float scale)
Set the vertical scaling factor for the specified series. i.e. if the series has values in the range 50..100, and a scale of 0.5 is set for it, it will show its values in the range 25..50

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
scale - The scaling factor. Must be > 0 or the graph will throw. It is best to be kept above 0.0001 or so as very low values can confuse the extrema calculations causing the graph to throw too

getSeriesScale

public float getSeriesScale(int seriesIndex)
Get the vertical scaling factor for the specified series. i.e. if the series has values in the range 50..100, and a scale of 0.5 is set for it, it will show its values in the range 25..50

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
Returns:
the scaling factor

setSeriesOffset

public void setSeriesOffset(int seriesIndex,
                            float offset)
Set the vertical offset amount for the specified series. i.e. if the series has values in the range 50..100, and an offset of 10 is set for it, it will show its values ini the range 60..110

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
offset - The offset amount. Can be positive or negative to offset up or down the graph respectively

getSeriesOffset

public float getSeriesOffset(int seriesIndex)
Get the vertical offset amount for the specified series. i.e. if the series has values in the range 50..100, and an offset of 10 is set for it, it will show its values in the range 60..110

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
Returns:
the offset

setSeriesColour

public void setSeriesColour(int seriesIndex,
                            java.awt.Color colour)
Set the colour used when rendering the specified seriesIndex in the GUI

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
colour - The colour to render as

getSeriesColour

public java.awt.Color getSeriesColour(int seriesIndex)
Get the colour used when rendering the specified seriesIndex in the GUI

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
Returns:
the colour used when rendering the specified seriesIndex in the GUI

setSeriesVisible

public void setSeriesVisible(int seriesIndex,
                             boolean visible)
Set whether the specified seriesIndex should be visible in the GUI

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
visible - whether it should be visible

isSeriesVisible

public boolean isSeriesVisible(int seriesIndex)
Get whether the specified seriesIndex is visible in the GUI

Parameters:
seriesIndex - The series index (returned from addSeries) to test
Returns:
whether the specified seriesIndex is visible in the GUI

setSeriesSelected

public void setSeriesSelected(int seriesIndex,
                              boolean selected)
Set whether the specified seriesIndex should be highlighted in the GUI

Parameters:
seriesIndex - The series index (returned from addSeries) to modify
selected - whether it should be highlighted

isSeriesSelected

public boolean isSeriesSelected(int seriesIndex)
Get whether the specified seriesIndex is highlighted in the GUI

Parameters:
seriesIndex - The series index (returned from addSeries) to test
Returns:
whether the specified seriesIndex is highlighted in the GUI

setSeriesErrorSeries

public void setSeriesErrorSeries(int seriesIndex,
                                 int errorIndex)
Set a seriesIndex to use another seriesIndex as its error bars. A seriesIndex cannot be its own error bars

Parameters:
seriesIndex - The series index (returned from addSeries) to add error bars to
errorIndex - The series index (returned from addSeries) that will become the error bars

getSeriesErrorSeries

public int getSeriesErrorSeries(int seriesIndex)
Get the seriesIndex that the specified seriesIndex is using as its error bars. If no seriesIndex is the error bars of the specified one, -1 is returned

Parameters:
seriesIndex - The series index (returned from addSeries) get the error bars of
Returns:
The index of the series that is the error bars of seriesIndex

isSeriesErrorSeries

public boolean isSeriesErrorSeries(int seriesIndex)
Return whether the specified seriesIndex is the error bars of another seriesIndex

Parameters:
seriesIndex - The series index (returned from addSeries) to test
Returns:
true if the specified seriesIndex is the error bars of another one, else false

getSeriesValueAt

public float getSeriesValueAt(int seriesIndex,
                              int dataIndex)
Get the data value of a particular series at a particular point

Parameters:
seriesIndex - The series index (returned from addSeries) to get from
dataIndex - The X co-ordinate of the data index (generation)
Returns:
The value of the series at the specified generation

getSeriesValue

public float getSeriesValue(int seriesIndex)
Get the last data value recorded for this series

Parameters:
seriesIndex - The series index (returned from addSeries) to get from
Returns:
the last data value recorded

setSeriesOnTop

public void setSeriesOnTop(int seriesIndex)
Set the specified series as being the most important. It is rendered last and is therefor rendered on top of all others. Set to -1 to make no series the top series

Parameters:
seriesIndex - The series index (returned from addSeries) to test

getXCoord

public float getXCoord(int dataIndex)
All data is recorded on integer steps, so this will always return the same value as what's passed in

Specified by:
getXCoord in interface JSci.awt.Graph2DModel
Parameters:
dataIndex - The X co-ordinate of the data index (generation)
Returns:
Each generation is output on the X co-ordinate it was recorded at, so this will be equal to the dataIndex

getYCoord

public float getYCoord(int dataIndex)
Get the value that was recorded for the active series (see firstSeries/nextSeries) at the generation specified by dataIndex

Specified by:
getYCoord in interface JSci.awt.Graph2DModel
Parameters:
dataIndex - The generation to use
Returns:
The value of the active series at the specified generation

getZCoord

public float getZCoord(int dataIndex)
Get the error bar value that was recorded for the active series (see firstSeries/nextSeries) at the generation specified by dataIndex

Parameters:
dataIndex - The generation to use
Returns:
The value of the error series at the specified generation. If no error series is set for the active series, this returns 0. Use hasErrorSeries()

getColour

public java.awt.Color getColour()
Get the colour to render the active series in the GUI

Returns:
The colour to render the active series in the GUI

getErrorColour

public java.awt.Color getErrorColour()
Get the colour to render the error series of the active series

Returns:
the colour to render the error series of the active series or null if there is no error series for the active series

isVisible

public boolean isVisible()
Get whether the active series is visible

Returns:
Whether the active series is visible

isErrorVisible

public boolean isErrorVisible()
Get whether the error series of the active series is visible

Returns:
whether the error series of the active series is visible or false if there is no error series for the active series

isSelected

public boolean isSelected()
Get whether the active series is selected

Returns:
Whether the active series is selected

hasErrorSeries

public boolean hasErrorSeries()
Get whether the active series has another series as its error series

Returns:
whether the active series has another series as its error series

isErrorSeries

public boolean isErrorSeries()
Get whether the active series is an error series for another series

Returns:
Whether the active series is an error series for another series

seriesLength

public int seriesLength()
Get the length of the active series (see firstSeries/nextSeries)

Specified by:
seriesLength in interface JSci.awt.Graph2DModel

firstSeries

public void firstSeries()
Set the active series to the first series. If setSeriesOnTop is set to 0, this will set the series to the first series following the 'on-top' series

Specified by:
firstSeries in interface JSci.awt.Graph2DModel

nextSeries

public boolean nextSeries()
Set the active series to the next series. This will be in order of the series array except if setSeriesOnTop is set to a value other that -1, where the order will change so that the 'on-top' series will be moved to be the last series

Specified by:
nextSeries in interface JSci.awt.Graph2DModel

lastSeries

public boolean lastSeries()
Get whether there are any more active series. If this returns true, all methods that rely on the active series will throw an exception

Returns:
true if the last series has been reached, else false

addGraphDataListener

public void addGraphDataListener(JSci.awt.GraphDataListener listener)
Specified by:
addGraphDataListener in interface JSci.awt.Graph2DModel

removeGraphDataListener

public void removeGraphDataListener(JSci.awt.GraphDataListener listener)
Specified by:
removeGraphDataListener in interface JSci.awt.Graph2DModel