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:
SettingsObserver

public class DataSeriesSettings
extends ObservableSettings
implements SettingsObserver

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 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:
"1.1.1"
Author:
Greg Paperin (http://www.paperin.org)

Nested Class Summary
 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  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 serInd)
           
private  double getDefaultScaleFactor(int serInd)
           
private  boolean getDefaultShow(int serInd)
           
private  DataSeriesSettings.TransformMode getDefaultTransformMode(int serInd)
           
 double getScaleFactor(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_SetVal.
 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.
 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 setScaleFactor(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_SetVal;
private  void setSeriesMarkedAsXAxis(int seriesIndex)
          Getts called when this settings container was registered as an observer to a graph settings container and some data series was set as being used as the x-axis in the observed graph settings container.
 void setShow(int seriesIndex, boolean show)
          Sets whether the data series with the specified index should be included in tthe 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 settingHasChanged(ObservableSettings settings, java.lang.Object info)
          Data seties settings objects may listen to other settings objects in order to react to changed in other settings; currently data series settings react when a data series is set to be used as the x-axis.
 void setTransformMode(int seriesIndex, DataSeriesSettings.TransformMode transformMode)
          Sets the transformation mode for the plotted values of the data series with the specified index.
 
Methods inherited from class org.LiveGraph.settings.ObservableSettings
addObserver, countObservers, hasObserver, notifyObservers, notifyObservers, removeObserver
 
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 serInd)

getDefaultColour

private java.awt.Color getDefaultColour(int serInd)

getDefaultTransformMode

private DataSeriesSettings.TransformMode getDefaultTransformMode(int serInd)

getDefaultScaleFactor

private double getDefaultScaleFactor(int serInd)

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 tthe 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.

setScaleFactor

public void setScaleFactor(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_SetVal;

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)

getScaleFactor

public double getScaleFactor(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_SetVal. If no setting value has been defined for the specified series, a defalut value will be returned as specified by getDefaultScaleFactor(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:
getDefaultScaleFactor(int)

settingHasChanged

public void settingHasChanged(ObservableSettings settings,
                              java.lang.Object info)
Data seties settings objects may listen to other settings objects in order to react to changed in other settings; currently data series settings react when a data series is set to be used as the x-axis. This method calls setSeriesMarkedAsXAxis(int) to process this event.

The corresponding series is then set to invisible, because practice suggests that users rarely want to plot the series against which all other series are plotted. If users want to have the series plotted anyway, they can switch it back on at any time.

Specified by:
settingHasChanged in interface SettingsObserver
Parameters:
settings - The settings object that was changed.
info - Is used to further specify the change. Usually this is a String containing the name of the changed setting.
See Also:
setSeriesMarkedAsXAxis(int)

setSeriesMarkedAsXAxis

private void setSeriesMarkedAsXAxis(int seriesIndex)
Getts called when this settings container was registered as an observer to a graph settings container and some data series was set as being used as the x-axis in the observed graph settings container.

The specified data series is set to invisible, because practice suggests that users rarely want to plot the series against which all other series are plotted. If users want to have the series plotted anyway, they can switch it back on at any time.

Parameters:
seriesIndex - The index of the data series to be set to invisible (corresponds to the column index in the data file).
See Also:
settingHasChanged(ObservableSettings, Object)

LiveGraph
data visualisation and analysis framework