LiveGraph
data visualisation and analysis framework

org.LiveGraph.settings
Class DataSeriesSettings

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

public class DataSeriesSettings
extends ObservableSettings

Ecapsulates the settings concerned with plotting each of the data series.

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: DataSeriesSettings.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
private static class DataSeriesSettings.SeriesParameters
          This struct-class is used to group the settings for one data series in a single data structure.
static class DataSeriesSettings.TransformMode
          The transformation mode to the series values.
 
Field Summary
private  java.util.List<java.awt.Color> defaultColours
          Holds the default colours.
static java.lang.String preferredFileExtension
          The default file extension.
private  java.util.List<DataSeriesSettings.SeriesParameters> settings
          Holds the current settigs.
 
Constructor Summary
DataSeriesSettings()
          Creates a new data series settings object and initialises it with default values.
DataSeriesSettings(java.lang.String fileName)
          Creates a new data series settings object and loads the settigs from the specified file.
 
Method Summary
private  void createDefaultColours()
          Creates a set of "nice" default colours for the plot.
private  double ensureGoodTransformParam(DataSeriesSettings.TransformMode transformMode, double parameter)
          Ensure that the transformation parameter has a legal value for the given transformation mode.
private  void ensureLength(int maxSeriesIndex)
          Ensures that this settings container contains at least the settings for the data series with the specified index and all indices before that.
 java.awt.Color getColour(int seriesIndex)
          Gets the colour for the plot of the data series with the specified index.
private  java.awt.Color getDefaultColour(int s)
           
private  boolean getDefaultShow(int s)
           
private  DataSeriesSettings.TransformMode getDefaultTransformMode(int s)
           
private  double getDefaultTransformParam(int s)
           
 boolean getShow(int seriesIndex)
          Setts whether the data series with the specified index should be included in tthe plot.
 DataSeriesSettings.TransformMode getTransformMode(int seriesIndex)
          Gets the transformation mode for the plotted values of the data series with the specified index.
 double getTransformParam(int seriesIndex)
          Gets the parameter for the transformation of the plotted values of the data series with the specified index; this parameter is currently required only for the mode Transform_ScaleBySetVal.
 boolean load(java.lang.String fileName)
          Loads the settings from a specified file.
 boolean save(java.lang.String fileName)
          Saves the settings to a specified file.
 void setColour(int seriesIndex, java.awt.Color colour)
          Sets the colour for the plot of the data series with the specified index.
 void setShow(int seriesIndex, boolean show)
          Sets whether the data series with the specified index should be included in the plot.
 void setShowAll(int from, int to, boolean show)
          Sets whether the data series between the specified indices should be included in the plot.
 void setShowToggleAll(int from, int to)
          Toggles whether the data series between the specified indices should be included in the plot.
 void setTransformMode(int seriesIndex, DataSeriesSettings.TransformMode transformMode)
          Sets the transformation mode for the plotted values of the data series with the specified index.
 void setTransformParam(int seriesIndex, double parameter)
          Sets the parameter for the transformation of the plotted values of the data series with the specified index; this parameter is currently required only for the mode Transform_ScaleBySetVal;
 
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
The default file extension.

See Also:
Constant Field Values

settings

private java.util.List<DataSeriesSettings.SeriesParameters> settings
Holds the current settigs.


defaultColours

private java.util.List<java.awt.Color> defaultColours
Holds the default colours.

Constructor Detail

DataSeriesSettings

public DataSeriesSettings()
Creates a new data series settings object and initialises it with default values.


DataSeriesSettings

public DataSeriesSettings(java.lang.String fileName)
Creates a new data series settings object and loads the settigs from the specified file.

Parameters:
fileName - The file name to use.
Method Detail

createDefaultColours

private void createDefaultColours()
Creates a set of "nice" default colours for the plot.


getDefaultShow

private boolean getDefaultShow(int s)

getDefaultColour

private java.awt.Color getDefaultColour(int s)

getDefaultTransformMode

private DataSeriesSettings.TransformMode getDefaultTransformMode(int s)

getDefaultTransformParam

private double getDefaultTransformParam(int s)

ensureLength

private void ensureLength(int maxSeriesIndex)
Ensures that this settings container contains at least the settings for the data series with the specified index and all indices before that. If this settings object does not yet contain any settings for any of the series with these indices, new settings data structures will be created and initialised with default values.

Parameters:
maxSeriesIndex - It will be ensured that this container contains settings for at least all data series up to this index.

load

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

Parameters:
fileName - The file to load the settings 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.

setShow

public void setShow(int seriesIndex,
                    boolean show)
Sets whether the data series with the specified index should be included in the plot.

Parameters:
seriesIndex - A data series index (corresponds to the column index in the data file).
show - true if the data series with the specified index is to be included in the plot, false otherwise.

setShowAll

public void setShowAll(int from,
                       int to,
                       boolean show)
Sets whether the data series between the specified indices should be included in the plot.

Parameters:
from - Starting data series index (inclusive).
to - Finishing data series index (inclusive).
show - true if the data series with the specified index is to be included in tthe plot, false otherwise.

setShowToggleAll

public void setShowToggleAll(int from,
                             int to)
Toggles whether the data series between the specified indices should be included in the plot.

Parameters:
from - Starting data series index (inclusive).
to - Finishing data series index (inclusive).

setColour

public void setColour(int seriesIndex,
                      java.awt.Color colour)
Sets the colour for the plot of the data series with the specified index.

Parameters:
seriesIndex - A data series index (corresponds to the column index in the data file).
colour - The colour for the plot of the data series with the specified index.

setTransformMode

public void setTransformMode(int seriesIndex,
                             DataSeriesSettings.TransformMode transformMode)
Sets the transformation mode for the plotted values of the data series with the specified index.

Parameters:
seriesIndex - A data series index (corresponds to the column index in the data file).
transformMode - The transformation mode for the plotted values of the data series with the specified index.

setTransformParam

public void setTransformParam(int seriesIndex,
                              double parameter)
Sets the parameter for the transformation of the plotted values of the data series with the specified index; this parameter is currently required only for the mode Transform_ScaleBySetVal;

Parameters:
seriesIndex - A data series index (corresponds to the column index in the data file).
parameter - The parameter for the transformation of the plotted values of the data series with the specified index.

getShow

public boolean getShow(int seriesIndex)
Setts whether the data series with the specified index should be included in tthe plot. If no setting value has been defined for the specified series, a defalut value will be returned as specified by getDefaultShow(int).

Parameters:
seriesIndex - A data series index (corresponds to the column index in the data file).
Returns:
true if the data series with the specified index is to be included in tthe plot, false otherwise.
See Also:
getDefaultShow(int)

getColour

public java.awt.Color getColour(int seriesIndex)
Gets the colour for the plot of the data series with the specified index. If no setting value has been defined for the specified series, a defalut value will be returned as specified by getDefaultColour(int).

Parameters:
seriesIndex - A data series index (corresponds to the column index in the data file).
Returns:
The colour for the plot of the data series with the specified index.
See Also:
getDefaultColour(int)

getTransformMode

public DataSeriesSettings.TransformMode getTransformMode(int seriesIndex)
Gets the transformation mode for the plotted values of the data series with the specified index. If no setting value has been defined for the specified series, a defalut value will be returned as specified by getDefaultTransformMode(int).

Parameters:
seriesIndex - A data series index (corresponds to the column index in the data file).
Returns:
The transformation mode for the plotted values of the data series with the specified index.
See Also:
getDefaultTransformMode(int)

getTransformParam

public double getTransformParam(int seriesIndex)
Gets the parameter for the transformation of the plotted values of the data series with the specified index; this parameter is currently required only for the mode Transform_ScaleBySetVal. If no setting value has been defined for the specified series, a defalut value will be returned as specified by getDefaultTransformParam(int).

Parameters:
seriesIndex - A data series index (corresponds to the column index in the data file).
Returns:
The parameter for the transformation of the plotted values of the data series with the specified index.
See Also:
getDefaultTransformParam(int)

ensureGoodTransformParam

private double ensureGoodTransformParam(DataSeriesSettings.TransformMode transformMode,
                                        double parameter)
Ensure that the transformation parameter has a legal value for the given transformation mode. The transformation parameter must be a real number and if the transformation mode is Transform_Logarithm, it must be non-negative and not 1.

Parameters:
transformMode - The transform mode for which to verify the parameter.
parameter - The transfom parameter to check.
Returns:
The corrected transform parameter.

LiveGraph
data visualisation and analysis framework