LiveGraph
data visualisation and analysis framework

org.LiveGraph.settings
Class GraphSettings

java.lang.Object
  extended by org.LiveGraph.settings.ObservableSettings
      extended by org.LiveGraph.settings.GraphSettings
All Implemented Interfaces:
EventProducer

public class GraphSettings
extends ObservableSettings

Encapsulates settings concerned with the data graphs and the plot canvas.

This product includes software developed by the LiveGraph project and its contributors.
(http://www.live-graph.org)
Copyright (c) 2007-2008 G. Paperin.
All rights reserved.

File: GraphSettings.java

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:

1. Redistributions of source code must retain the above acknowledgement of the LiveGraph project and its web-site, the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the LiveGraph project and its web-site, the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software or any derived software must display the following acknowledgement:
This product includes software developed by the LiveGraph project and its contributors.
(http://www.live-graph.org)

4. All advertising materials distributed in form of HTML pages or any other technology permitting active hyper-links that mention features or use of this software or any derived software must display the acknowledgment specified in condition 3 of this agreement, and in addition, include a visible and working hyper-link to the LiveGraph homepage (http://www.live-graph.org).

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version:
"2.0.beta01"
Author:
Greg Paperin (http://www.paperin.org)

Nested Class Summary
static class GraphSettings.HGridType
          Possible types for the horizontal grid.
static class GraphSettings.VGridType
          Possible types for the vertical grid.
static class GraphSettings.XAxisType
          Possible types for the x-axis.
 
Field Summary
private  java.awt.Color hGridColour
          Color of the horisontal grid.
private  double hGridSize
          Spacing of the horisontal grid in data coordinates.
private  GraphSettings.HGridType hGridType
          Type of the horisontal grid.
private  boolean highlightDataPoints
          Whether to highlight data points as mouse is moved over the graph.
private  double maxX
          Right edge of the visible data area.
private  double maxY
          Top edge of the visible data area.
private  double minX
          Left edge of the visible data area.
private  double minY
          Bottom edge of the visible data area.
static java.lang.String preferredFileExtension
          Standard file extension.
private  java.awt.Color vGridColour
          Color of the vertical grid.
private  double vGridSize
          Spacing of the vertical grid in data coordinates.
private  GraphSettings.VGridType vGridType
          Type of the vertical grid.
private  double xAxisParamValue
          Parameter for transformation of x-values.
private  int xAxisSeriesIndex
          Against which data series to plot (index).
private  GraphSettings.XAxisType xAxisType
          Against what to plot the values.
 
Constructor Summary
GraphSettings()
          Creates a new graph settings object with the default settings.
GraphSettings(java.lang.String fileName)
          Creates a new graph settings object and loads the settings from the specified file.
 
Method Summary
private  void checkDisableHighlightingForOldJava()
          If the Java version is too old, data point highlighting is disabled.
private  double ensureGoodXAxisParameter(GraphSettings.XAxisType xAxisType, double parameter)
          Ensure that the transformation parameter has a legal value for the given x-axis type.
 java.awt.Color getHGridColour()
          Gets the colour for drawing the horizontal grid bars.
 double getHGridSize()
          Gets the interval between the horizontal grib bars.
 GraphSettings.HGridType getHGridType()
          Gets the horizontal grid type.
 boolean getHighlightDataPoints()
          Gets whether the data points in the vicinity of the mouse cursor should be highlighted.
 double getMaxX()
          Gets the maximum X value for the plot viewport.
 double getMaxY()
          Gets the maximum Y value for the plot viewport.
 double getMinX()
          Gets the minimum X value for the plot viewport.
 double getMinY()
          Gets the minimum Y value for the plot viewport.
 java.awt.Color getVGridColour()
          Gets the colour to use for drawing the vertical grid bars.
 double getVGridSize()
          Gets the interval between the vertical grid bars.
 GraphSettings.VGridType getVGridType()
          Sets the vertical grid type.
 double getXAxisParamValue()
          Gets the x-axis transformation parameter.
 int getXAxisSeriesIndex()
          Gets the index of the data series to use as the x-axis.
 GraphSettings.XAxisType getXAxisType()
          Gets the type for the x-axis.
 boolean load(java.lang.String fileName)
          Loads the settings from the specified file.
 boolean save(java.lang.String fileName)
          Saves the settings to a specified file.
 void setHGridColour(java.awt.Color c)
          Sets the colour for drawing the horizontal grid bars.
 void setHGridSize(double val)
          Sets the interval between the horizontal grib bars.
 void setHGridType(GraphSettings.HGridType v)
          Sets the horizontal grid type.
 void setHighlightDataPoints(boolean v)
          Gets whether the data points in the vicinity of the mouse cursor should be highlighted.
 void setMaxX(double v)
          Sets the maximum X value for the plot viewport.
 void setMaxY(double v)
          Sets the maximum Y value for the plot viewport.
 void setMinX(double v)
          Sets the minimum X value for the plot viewport.
 void setMinY(double v)
          Sets the minimum Y value for the plot viewport.
 void setVGridColour(java.awt.Color c)
          Sets the colour to use for drawing the vertical grid bars.
 void setVGridSize(double val)
          Sets the interval between the vertical grid bars.
 void setVGridType(GraphSettings.VGridType v)
          Gets the vertical grid type.
 void setXAxisParamValue(double val)
          Sets x-axis transformation parameter.
 void setXAxisSeriesIndex(int val)
          Sets the index of the data series to use as the x-axis.
 void setXAxisType(GraphSettings.XAxisType v)
          Sets the type for the x-axis.
 
Methods inherited from class org.LiveGraph.settings.ObservableSettings
checkObservers, checkObservers, checkObservers, checkObservers, checkObservers, eventProcessingException, eventProcessingFinished, notifyObservers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

preferredFileExtension

public static final java.lang.String preferredFileExtension
Standard file extension.

See Also:
Constant Field Values

minY

private double minY
Bottom edge of the visible data area. Default value: Double.NaN (Auto).


maxY

private double maxY
Top edge of the visible data area. Default value: Double.NaN (Auto).


minX

private double minX
Left edge of the visible data area. Default value: Double.NaN (Auto).


maxX

private double maxX
Right edge of the visible data area. Default value: Double.NaN (Auto).


vGridType

private GraphSettings.VGridType vGridType
Type of the vertical grid. Default value: VGridType.VGrid_None.


vGridSize

private double vGridSize
Spacing of the vertical grid in data coordinates. Default value: 50.


vGridColour

private java.awt.Color vGridColour
Color of the vertical grid. Default value: #C0C0C0.


hGridType

private GraphSettings.HGridType hGridType
Type of the horisontal grid. Default value: HGridType.HGrid_None.


hGridSize

private double hGridSize
Spacing of the horisontal grid in data coordinates. Default value: 50.


hGridColour

private java.awt.Color hGridColour
Color of the horisontal grid. Default value: #C0C0C0.


xAxisType

private GraphSettings.XAxisType xAxisType
Against what to plot the values. Default value: XAxisType.XAxis_DSNum.


xAxisSeriesIndex

private int xAxisSeriesIndex
Against which data series to plot (index). Default value: 0.


xAxisParamValue

private double xAxisParamValue
Parameter for transformation of x-values. Default value: 1.


highlightDataPoints

private boolean highlightDataPoints
Whether to highlight data points as mouse is moved over the graph. Default value: true.

Constructor Detail

GraphSettings

public GraphSettings()
Creates a new graph settings object with the default settings.


GraphSettings

public GraphSettings(java.lang.String fileName)
Creates a new graph settings object and loads the settings from the specified file.

Parameters:
fileName - File to load the settigs from.
Method Detail

load

public boolean load(java.lang.String fileName)
Loads the settings from the specified file.

Parameters:
fileName - File to load the settigs from.
Returns:
true if the settings were loaded, false if an exception occured.

save

public boolean save(java.lang.String fileName)
Saves the settings to a specified file.

Parameters:
fileName - The file to save the settings to.
Returns:
true if the settings were saved, false if an exception occured.

getMinY

public double getMinY()
Gets the minimum Y value for the plot viewport.

Returns:
The minimum value along the Y axis for the graph view or java.lang.Double.NaN if the current global minimum of all data series should be used instead.

setMinY

public void setMinY(double v)
Sets the minimum Y value for the plot viewport.

Parameters:
v - The minimum value along the Y axis for the graph view or java.lang.Double.NaN if the global minimum of all data series should be used at all times.

getMaxY

public double getMaxY()
Gets the maximum Y value for the plot viewport.

Returns:
The maximum value along the Y axis for the graph view or java.lang.Double.NaN if the current global maximum of all data series should be used instead.

setMaxY

public void setMaxY(double v)
Sets the maximum Y value for the plot viewport.

Parameters:
v - The maximum value along the Y axis for the graph view or java.lang.Double.NaN if the global maximum of all data series should be used at all times.

getMinX

public double getMinX()
Gets the minimum X value for the plot viewport.

Returns:
The minimum value along the X axis for the graph view or java.lang.Double.NaN if the currently smallest X value of all data series should be used instead.

setMinX

public void setMinX(double v)
Sets the minimum X value for the plot viewport.

Parameters:
v - The minimum value along the X axis for the graph view or java.lang.Double.NaN if the smallest X value of all data series should be used at all times.

getMaxX

public double getMaxX()
Gets the maximum X value for the plot viewport.

Returns:
The maximum value along the X axis for the graph view or java.lang.Double.NaN if the currently largest X value of all data series should be used instead.

setMaxX

public void setMaxX(double v)
Sets the maximum X value for the plot viewport.

Parameters:
v - The maximum value along the X axis for the graph view or java.lang.Double.NaN if the largest X value of all data series should be used at all times.

getVGridType

public GraphSettings.VGridType getVGridType()
Sets the vertical grid type.

Returns:
The vertical grid type.

setVGridType

public void setVGridType(GraphSettings.VGridType v)
Gets the vertical grid type.

Parameters:
v - The vertical grid type.

getVGridSize

public double getVGridSize()
Gets the interval between the vertical grid bars.

Returns:
The interval between the vertical grid bars.

setVGridSize

public void setVGridSize(double val)
Sets the interval between the vertical grid bars.

Parameters:
val - The interval between the vertical grid bars.

getVGridColour

public java.awt.Color getVGridColour()
Gets the colour to use for drawing the vertical grid bars.

Returns:
The colour to use for drawing the vertical grid bars.

setVGridColour

public void setVGridColour(java.awt.Color c)
Sets the colour to use for drawing the vertical grid bars.

Parameters:
c - The colour to use for drawing the vertical grid bars.

getHGridType

public GraphSettings.HGridType getHGridType()
Gets the horizontal grid type.

Returns:
The horizontal grid type.

setHGridType

public void setHGridType(GraphSettings.HGridType v)
Sets the horizontal grid type.

Parameters:
v - The horizontal grid type.

getHGridSize

public double getHGridSize()
Gets the interval between the horizontal grib bars.

Returns:
The interval between the horizontal grib bars.

setHGridSize

public void setHGridSize(double val)
Sets the interval between the horizontal grib bars.

Parameters:
val - The interval between the horizontal grib bars.

getHGridColour

public java.awt.Color getHGridColour()
Gets the colour for drawing the horizontal grid bars.

Returns:
The colour for drawing the horizontal grid bars.

setHGridColour

public void setHGridColour(java.awt.Color c)
Sets the colour for drawing the horizontal grid bars.

Parameters:
c - The colour for drawing the horizontal grid bars.

getXAxisType

public GraphSettings.XAxisType getXAxisType()
Gets the type for the x-axis.

Returns:
The type for the x-axis.

setXAxisType

public void setXAxisType(GraphSettings.XAxisType v)
Sets the type for the x-axis.

Parameters:
v - The type for the x-axis.

getXAxisSeriesIndex

public int getXAxisSeriesIndex()
Gets the index of the data series to use as the x-axis.

Returns:
The index of the data series to use as the x-axis.

setXAxisSeriesIndex

public void setXAxisSeriesIndex(int val)
Sets the index of the data series to use as the x-axis.

Parameters:
val - The index of the data series to use as the x-axis.

getXAxisParamValue

public double getXAxisParamValue()
Gets the x-axis transformation parameter.

Returns:
The x-axis transformation parameter.

setXAxisParamValue

public void setXAxisParamValue(double val)
Sets x-axis transformation parameter.

Parameters:
val - x-axis transformation parameter.

getHighlightDataPoints

public boolean getHighlightDataPoints()
Gets whether the data points in the vicinity of the mouse cursor should be highlighted. (Note, this is a hidden setting and cannot be changes via the GUI.)

Returns:
true if the data points in the vicinity of the mouse cursor should be highlighted, false otherwise.

setHighlightDataPoints

public void setHighlightDataPoints(boolean v)
Gets whether the data points in the vicinity of the mouse cursor should be highlighted. (Note, this is a hidden setting and cannot be changes via the GUI.)

Parameters:
v - true if the data points in the vicinity of the mouse cursor are to be highlighted, false otherwise.

checkDisableHighlightingForOldJava

private void checkDisableHighlightingForOldJava()
If the Java version is too old, data point highlighting is disabled.


ensureGoodXAxisParameter

private double ensureGoodXAxisParameter(GraphSettings.XAxisType xAxisType,
                                        double parameter)
Ensure that the transformation parameter has a legal value for the given x-axis type. The transformation parameter must be a real number. In addition, if the x-axis type is XAxis_DataValLogToSetBase, it must be non-negative and not 1.

Parameters:
xAxisType - The x-axis type for which to verify the parameter.
parameter - The transfom parameter to check.
Returns:
The corrected transform parameter.

LiveGraph
data visualisation and analysis framework