main
Class UserPreferences

java.lang.Object
  extended by main.UserPreferences
All Implemented Interfaces:
java.io.Serializable

public class UserPreferences
extends java.lang.Object
implements java.io.Serializable

This class stores all user preference settings. When the user makes changes to settings such as default background color of charts or delimiting characters for data imports these settings are stored in an instance of this class.

Each time a change is made the information is automatically saved by serializing the class instance to a file in the application directory.

User specific settings are supported by naming the settings file after the user name, followed by the extension .pref.

If this file is missing upon startup, a new file with the default settings is created. The default settings used for this purpose are also defined in this class.

See Also:
Serialized Form

Field Summary
private  java.awt.Color activeDesignDefaultColor
          The active design default color.
private  boolean autoFitAxis
          Axes are autofitted
private  java.awt.Color axisColor
          The axis color.
private  double axisDefaultMax
          The axis default maximum value.
private  double axisDefaultMin
          The axis default minimum value.
private  int axisHeight
          The axis height in pixels.
private  boolean axisInverted
          Flips the axes upside down.
private  java.awt.Color axisLabelFontColor
          The axis font color used for the axis title labels.
private  int axisLabelFontSize
          The axis label font size.
private  int axisTicCount
          The number of tics used on the axis count.
private  java.awt.Color axisTicLabelFontColor
          The font color used for the axis tic labels.
private  java.lang.String axisTicLabelFormat
          The axis tic label format.
private  int axisTicLength
          The axis tic length in pixels.
private  int axisWidth
          The width in pixels that is used by one axis.
private  java.awt.Color backgroundDefaultColor
          The default background color for charts.
private  java.lang.String delimiter
          The delimiter used to distinguish columns when importing data.
private  int designIDFontSize
          The design id font size.
private  int designLabelFontSize
          The design label font size.
private  int dirToImportFrom
          The directory to import from.
private  java.awt.Color filterColor
          The filter color.
private  int filterHeight
          The height of the triangles that represent the filter in pixels.
private  boolean filterInverted
          Inverts filters.
private  int filterWidth
          The width of one half triangle that represents a filter in pixels.
private  java.lang.String homeDir
          The user's home directory.
static int IMPORT_FROM_HOMEDIR
          Open file import browse dialog in the user's home directory by default.
static int IMPORT_FROM_LASTDIR
          Open file import browse dialog in the last opened directory by default.
static int IMPORT_FROM_USERDIR
          Open file import browse dialog in a userspecified directory by default.
private  java.awt.Color inActiveDesignDefaultColor
          The inactive (filtered) design default color.
private  java.lang.String lastFile
          The last file that was selected.
private  boolean lastFileInitialised
          Flag to remember when lastFile is initialised.
private  java.lang.String otherDelimiter
          Character that is used as delimiter when importing data.
(package private) static boolean printLog
          Flag to enable debug message printing for this class.
(package private) static long serialVersionUID
          The version tracking unique identifier for Serialization.
private  boolean showDesignIDs
          Flag to enable plotting design id numbers to the left of the left-most axis.
private  boolean showFilteredDesigns
          Switch that enables displaying filtered designs.
private  int ticLabelFontSize
          The tic label font size.
private  boolean treatConsecutiveAsOne
          Flag to enable treating consecutive delimiters as one.
private  java.lang.String userDir
          User-specified setting where the file browsing dialog should start by default.
 
Constructor Summary
UserPreferences()
          Instantiates a new user preferences.
 
Method Summary
 java.awt.Color getActiveDesignDefaultColor()
          Gets the active design default color.
 java.awt.Color getAxisColor()
          Gets the axis color.
 double getAxisDefaultMax()
          Gets the axis default maximum value.
 double getAxisDefaultMin()
          Gets the axis default minimum value.
 int getAxisHeight()
          Gets the axis height.
 java.awt.Color getAxisLabelFontColor()
          Gets the axis label font color.
 int getAxisLabelFontSize()
          Gets the axis label font size.
 int getAxisTicCount()
          Gets the axis tic count.
 java.awt.Color getAxisTicLabelFontColor()
          Gets the axis tic label font color.
 int getAxisTicLabelFontSize()
          Gets the axis tic label font size.
 java.lang.String getAxisTicLabelFormat()
          Gets the axis tic label format.
 int getAxisTicLength()
          Gets the axis tic length.
 int getAxisWidth()
          Gets the axis width.
 java.lang.String getCurrentDir()
          Gets the directory for the file browsing dialog.
 java.awt.Color getDefaultBackgroundColor()
          Gets the default background color.
 java.lang.String getDelimiter()
          Gets the delimiter for importing data.
 int getDesignIDFontSize()
          Gets the design id font size.
 int getDesignLabelFontSize()
          Gets the design label font size.
 int getDirToImportFrom()
          Gets the dir to import from.
 java.awt.Color getFilterDefaultColor()
          Gets the filter default color.
 java.awt.Color getFilteredDesignDefaultColor()
          Gets the filtered design default color.
 int getFilterHeight()
          Gets the filter height.
 int getFilterWidth()
          Gets the filter width.
 java.lang.String getHomeDir()
          Gets the user home directory.
 java.lang.String getLastFile()
          Gets the last file.
 java.lang.String getOtherDelimiter()
          Gets the user-defined delimiter.
static java.lang.String getPreferenceFileName()
          Gets the preference file name.
 java.lang.String getUserDir()
          Gets the user directory.
 boolean isAutoFitAxis()
          Checks if axes are autofitted.
 boolean isAxisInverted()
          Checks whether axes are inverted.
 boolean isFilterInverted()
          Checks whether filters are inverted.
 boolean isLastFileInitialised()
          Checks if the last file field has been initialised.
 boolean isShowDesignIDs()
          Checks if design id numbers are shown left to the left-most axis.
 boolean isShowFilteredDesigns()
          Checks if filtered designs should be shown.
 boolean isTreatConsecutiveAsOne()
          Checks .
private  void log(java.lang.String message)
          Prints debug information to stdout when printLog is set to true.
static UserPreferences readFromFile(Main mainWindow)
          Read from file.
 void resetToDefault()
          Restores all default settings.
 void saveToFile()
          Save to file.
 void setActiveDesignDefaultColor(java.awt.Color activeDesignDefaultColor)
          Sets the active design default color.
 void setAutoFitAxis(boolean autoFitAxis)
          Specifies whether axes should be autofitted.
 void setAxisColor(java.awt.Color axisColor)
          Sets the axis color.
 void setAxisDefaultMax(double axisDefaultMax)
          Sets the axis default max.
 void setAxisDefaultMin(double axisDefaultMin)
          Sets the axis default minimum value.
 void setAxisHeight(int axisHeight)
          Sets the axis height.
 void setAxisInverted(boolean axisInverted)
          Specifies whether axes are inverted.
 void setAxisLabelFontColor(java.awt.Color axisLabelFontColor)
          Sets the axis label font color.
 void setAxisLabelFontSize(int axisLabelFontSize)
          Sets the axis label font size.
 void setAxisTicCount(int axisTicCount)
          Sets the axis tic count.
 void setAxisTicLabelFontColor(java.awt.Color axisTicLabelFontColor)
          Sets the axis tic label font color.
 void setAxisTicLabelFontSize(int ticLabelFontSize)
          Sets the axis tic label font size.
 void setAxisTicLabelFormat(java.lang.String axisTicLabelFormat)
          Sets the axis tic label format.
 void setAxisTicLength(int axisTicLength)
          Sets the axis tic length.
 void setAxisWidth(int axisWidth)
          Sets the axis width.
 void setDefaultBackgroundColor(java.awt.Color backgroundColor)
          Sets the default background color.
 void setDelimiter(java.lang.String delimiter)
          Sets the delimiter for importing data.
 void setDesignIDFontSize(int designIDFontSize)
          Sets the design id font size.
 void setDesignLabelFontSize(int designLabelFontSize)
          Sets the design label font size.
 void setDirToImportFrom(int dirToImportFrom)
          Sets the dir to import from.
 void setFilterColor(java.awt.Color filterColor)
          Sets the filter color.
 void setFilterHeight(int filterHeight)
          Sets the filter height.
 void setFilterInverted(boolean filterInverted)
          Specifies whether filters inverted.
 void setFilterWidth(int filterWidth)
          Sets the filter width.
 void setHomeDir(java.lang.String homeDir)
          Sets the home directory.
 void setInActiveDesignDefaultColor(java.awt.Color inActiveDesignDefaultColor)
          Sets the in active design default color.
 void setLastFile(java.lang.String lastFileBrowsingDirectory)
          Sets the last file.
 void setOtherDelimiter(java.lang.String otherDelimiter)
          Sets the user-defined delimiter.
 void setShowDesignIDs(boolean showDesignIDs)
          Specifies whether design id numbers are shown left to the left-most axis.
 void setShowFilteredDesigns(boolean showFilteredDesigns)
          Sets whether filtered designs should be shown.
 void setTreatConsecutiveAsOne(boolean treatConsecutiveAsOne)
          Sets whether consecutive delimiters should be treated as one.
 void setUserDir(java.lang.String userDir)
          Sets the user directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
The version tracking unique identifier for Serialization.

See Also:
Constant Field Values

printLog

static final boolean printLog
Flag to enable debug message printing for this class.

See Also:
Constant Field Values

IMPORT_FROM_HOMEDIR

public static final int IMPORT_FROM_HOMEDIR
Open file import browse dialog in the user's home directory by default.

See Also:
dirToImportFrom, Constant Field Values

IMPORT_FROM_LASTDIR

public static final int IMPORT_FROM_LASTDIR
Open file import browse dialog in the last opened directory by default.

See Also:
dirToImportFrom, lastFile, Constant Field Values

IMPORT_FROM_USERDIR

public static final int IMPORT_FROM_USERDIR
Open file import browse dialog in a userspecified directory by default.

See Also:
dirToImportFrom, userDir, Constant Field Values

dirToImportFrom

private int dirToImportFrom
The directory to import from.

See Also:
IMPORT_FROM_HOMEDIR, IMPORT_FROM_LASTDIR, IMPORT_FROM_USERDIR, lastFile, userDir

lastFileInitialised

private boolean lastFileInitialised
Flag to remember when lastFile is initialised.


homeDir

private java.lang.String homeDir
The user's home directory.


lastFile

private java.lang.String lastFile
The last file that was selected. Defaults to the user's home.


userDir

private java.lang.String userDir
User-specified setting where the file browsing dialog should start by default.


showFilteredDesigns

private boolean showFilteredDesigns
Switch that enables displaying filtered designs.


backgroundDefaultColor

private java.awt.Color backgroundDefaultColor
The default background color for charts.


axisWidth

private int axisWidth
The width in pixels that is used by one axis. This setting is used to define the axis spacing. The distance of two axes is defined by the sum of their respective widths, divided by two.


axisHeight

private int axisHeight
The axis height in pixels.


axisTicCount

private int axisTicCount
The number of tics used on the axis count.


axisColor

private java.awt.Color axisColor
The axis color.


axisLabelFontColor

private java.awt.Color axisLabelFontColor
The axis font color used for the axis title labels.


axisTicLabelFontColor

private java.awt.Color axisTicLabelFontColor
The font color used for the axis tic labels.


axisLabelFontSize

private int axisLabelFontSize
The axis label font size.


ticLabelFontSize

private int ticLabelFontSize
The tic label font size.


designLabelFontSize

private int designLabelFontSize
The design label font size.


axisTicLabelFormat

private java.lang.String axisTicLabelFormat
The axis tic label format.


axisTicLength

private int axisTicLength
The axis tic length in pixels.


filterColor

private java.awt.Color filterColor
The filter color.


filterHeight

private int filterHeight
The height of the triangles that represent the filter in pixels.


filterWidth

private int filterWidth
The width of one half triangle that represents a filter in pixels. In other words, the filter triangle will be twice as large as the value entered here.


activeDesignDefaultColor

private java.awt.Color activeDesignDefaultColor
The active design default color.


inActiveDesignDefaultColor

private java.awt.Color inActiveDesignDefaultColor
The inactive (filtered) design default color. Only relevant when showFilteredDesigns is true.


showDesignIDs

private boolean showDesignIDs
Flag to enable plotting design id numbers to the left of the left-most axis.


designIDFontSize

private int designIDFontSize
The design id font size.


delimiter

private java.lang.String delimiter
The delimiter used to distinguish columns when importing data.


otherDelimiter

private java.lang.String otherDelimiter
Character that is used as delimiter when importing data. Only used to store this information internally. When the user makes this setting the character is also written two the field delimiter


treatConsecutiveAsOne

private boolean treatConsecutiveAsOne
Flag to enable treating consecutive delimiters as one.


filterInverted

private boolean filterInverted
Inverts filters. This means that designs between the filters are shown, while designs above the top filter and below the bottom filter are not.


axisInverted

private boolean axisInverted
Flips the axes upside down.


autoFitAxis

private boolean autoFitAxis
Axes are autofitted


axisDefaultMax

private double axisDefaultMax
The axis default maximum value. Only relevant if autoFitAxis is false.


axisDefaultMin

private double axisDefaultMin
The axis default minimum value. Only relevant if autoFitAxis is false.

Constructor Detail

UserPreferences

public UserPreferences()
Instantiates a new user preferences.

Method Detail

getAxisColor

public java.awt.Color getAxisColor()
Gets the axis color.

Returns:
the axis color

setAxisColor

public void setAxisColor(java.awt.Color axisColor)
Sets the axis color.

Parameters:
axisColor - the new axis color

getAxisHeight

public int getAxisHeight()
Gets the axis height.

Returns:
the axis height

setAxisHeight

public void setAxisHeight(int axisHeight)
Sets the axis height.

Parameters:
axisHeight - the new axis height

getAxisLabelFontColor

public java.awt.Color getAxisLabelFontColor()
Gets the axis label font color.

Returns:
the axis label font color

setAxisLabelFontColor

public void setAxisLabelFontColor(java.awt.Color axisLabelFontColor)
Sets the axis label font color.

Parameters:
axisLabelFontColor - the new axis label font color

getAxisLabelFontSize

public int getAxisLabelFontSize()
Gets the axis label font size.

Returns:
the axis label font size

setAxisLabelFontSize

public void setAxisLabelFontSize(int axisLabelFontSize)
Sets the axis label font size.

Parameters:
axisLabelFontSize - the new axis label font size

getAxisTicCount

public int getAxisTicCount()
Gets the axis tic count.

Returns:
the axis tic count

setAxisTicCount

public void setAxisTicCount(int axisTicCount)
Sets the axis tic count.

Parameters:
axisTicCount - the new axis tic count

getAxisTicLabelFontColor

public java.awt.Color getAxisTicLabelFontColor()
Gets the axis tic label font color.

Returns:
the axis tic label font color

setAxisTicLabelFontColor

public void setAxisTicLabelFontColor(java.awt.Color axisTicLabelFontColor)
Sets the axis tic label font color.

Parameters:
axisTicLabelFontColor - the new axis tic label font color

getAxisTicLabelFormat

public java.lang.String getAxisTicLabelFormat()
Gets the axis tic label format.

Returns:
the axis tic label format

setAxisTicLabelFormat

public void setAxisTicLabelFormat(java.lang.String axisTicLabelFormat)
Sets the axis tic label format.

Parameters:
axisTicLabelFormat - the new axis tic label format

getAxisTicLength

public int getAxisTicLength()
Gets the axis tic length.

Returns:
the axis tic length

setAxisTicLength

public void setAxisTicLength(int axisTicLength)
Sets the axis tic length.

Parameters:
axisTicLength - the new axis tic length

getAxisWidth

public int getAxisWidth()
Gets the axis width.

Returns:
the axis width

setAxisWidth

public void setAxisWidth(int axisWidth)
Sets the axis width.

Parameters:
axisWidth - the new axis width

getFilterDefaultColor

public java.awt.Color getFilterDefaultColor()
Gets the filter default color.

Returns:
the filter default color

setFilterColor

public void setFilterColor(java.awt.Color filterColor)
Sets the filter color.

Parameters:
filterColor - the new filter color

getFilterHeight

public int getFilterHeight()
Gets the filter height.

Returns:
the filter height

setFilterHeight

public void setFilterHeight(int filterHeight)
Sets the filter height.

Parameters:
filterHeight - the new filter height

getFilterWidth

public int getFilterWidth()
Gets the filter width.

Returns:
the filter width

setFilterWidth

public void setFilterWidth(int filterWidth)
Sets the filter width.

Parameters:
filterWidth - the new filter width

getAxisTicLabelFontSize

public int getAxisTicLabelFontSize()
Gets the axis tic label font size.

Returns:
the axis tic label font size

setAxisTicLabelFontSize

public void setAxisTicLabelFontSize(int ticLabelFontSize)
Sets the axis tic label font size.

Parameters:
ticLabelFontSize - the new axis tic label font size

saveToFile

public void saveToFile()
Save to file.


readFromFile

public static UserPreferences readFromFile(Main mainWindow)
                                    throws java.io.InvalidClassException,
                                           java.io.IOException
Read from file.

Parameters:
mainWindow - the main window
Returns:
the user preferences
Throws:
InvalidClassException - the invalid class exception
java.io.IOException - Signals that an I/O exception has occurred.

getDesignLabelFontSize

public int getDesignLabelFontSize()
Gets the design label font size.

Returns:
the design label font size

setDesignLabelFontSize

public void setDesignLabelFontSize(int designLabelFontSize)
Sets the design label font size.

Parameters:
designLabelFontSize - the new design label font size

getDirToImportFrom

public int getDirToImportFrom()
Gets the dir to import from.

Returns:
the dir to import from

setDirToImportFrom

public void setDirToImportFrom(int dirToImportFrom)
Sets the dir to import from.

Parameters:
dirToImportFrom - the new dir to import from

getLastFile

public java.lang.String getLastFile()
Gets the last file.

Returns:
the last file

setLastFile

public void setLastFile(java.lang.String lastFileBrowsingDirectory)
Sets the last file.

Parameters:
lastFileBrowsingDirectory - the new last file

isLastFileInitialised

public boolean isLastFileInitialised()
Checks if the last file field has been initialised.

Returns:
true, if is last file field has been initialised

getHomeDir

public java.lang.String getHomeDir()
Gets the user home directory.

Returns:
the user home directory

setHomeDir

public void setHomeDir(java.lang.String homeDir)
Sets the home directory.

Parameters:
homeDir - the new home directory

getUserDir

public java.lang.String getUserDir()
Gets the user directory.

Returns:
the user directory

setUserDir

public void setUserDir(java.lang.String userDir)
Sets the user directory.

Parameters:
userDir - the new user directory

getCurrentDir

public java.lang.String getCurrentDir()
Gets the directory for the file browsing dialog.

Returns:
the current directory based on the user preferences.

getDelimiter

public java.lang.String getDelimiter()
Gets the delimiter for importing data.

Returns:
the delimiter

setDelimiter

public void setDelimiter(java.lang.String delimiter)
Sets the delimiter for importing data.

Parameters:
delimiter - the new delimiter

isTreatConsecutiveAsOne

public boolean isTreatConsecutiveAsOne()
Checks .

Returns:
true, if consecutive delimiters should be treated as one

setTreatConsecutiveAsOne

public void setTreatConsecutiveAsOne(boolean treatConsecutiveAsOne)
Sets whether consecutive delimiters should be treated as one.

Parameters:
treatConsecutiveAsOne - flag for treating consecutive delimiters as one

getOtherDelimiter

public java.lang.String getOtherDelimiter()
Gets the user-defined delimiter.

Returns:
the user-defined delimiter

setOtherDelimiter

public void setOtherDelimiter(java.lang.String otherDelimiter)
Sets the user-defined delimiter.

Parameters:
otherDelimiter - the user-defined delimiter

isShowFilteredDesigns

public boolean isShowFilteredDesigns()
Checks if filtered designs should be shown.

Returns:
true, if filtered designs are shown

setShowFilteredDesigns

public void setShowFilteredDesigns(boolean showFilteredDesigns)
Sets whether filtered designs should be shown.

Parameters:
showFilteredDesigns - flag to set whether filtered designs should be shown.

getActiveDesignDefaultColor

public java.awt.Color getActiveDesignDefaultColor()
Gets the active design default color.

Returns:
the active design default color

setActiveDesignDefaultColor

public void setActiveDesignDefaultColor(java.awt.Color activeDesignDefaultColor)
Sets the active design default color.

Parameters:
activeDesignDefaultColor - the new active design default color

getFilteredDesignDefaultColor

public java.awt.Color getFilteredDesignDefaultColor()
Gets the filtered design default color.

Returns:
the filtered design default color

setInActiveDesignDefaultColor

public void setInActiveDesignDefaultColor(java.awt.Color inActiveDesignDefaultColor)
Sets the in active design default color.

Parameters:
inActiveDesignDefaultColor - the new in active design default color

isShowDesignIDs

public boolean isShowDesignIDs()
Checks if design id numbers are shown left to the left-most axis.

Returns:
whether design id numbers are shown left to the left-most axis.

setShowDesignIDs

public void setShowDesignIDs(boolean showDesignIDs)
Specifies whether design id numbers are shown left to the left-most axis.

Parameters:
showDesignIDs - specifies whether design id numbers are shown left to the left-most axis.

getDesignIDFontSize

public int getDesignIDFontSize()
Gets the design id font size.

Returns:
the design id font size

setDesignIDFontSize

public void setDesignIDFontSize(int designIDFontSize)
Sets the design id font size.

Parameters:
designIDFontSize - the new design id font size

getDefaultBackgroundColor

public java.awt.Color getDefaultBackgroundColor()
Gets the default background color.

Returns:
the default background color

setDefaultBackgroundColor

public void setDefaultBackgroundColor(java.awt.Color backgroundColor)
Sets the default background color.

Parameters:
backgroundColor - the new default background color

isFilterInverted

public boolean isFilterInverted()
Checks whether filters are inverted.

Returns:
true, if filters are inverted.

setFilterInverted

public void setFilterInverted(boolean filterInverted)
Specifies whether filters inverted.

Parameters:
filterInverted - Specifies whether filters inverted.

log

private void log(java.lang.String message)
Prints debug information to stdout when printLog is set to true.

Parameters:
message - the message

isAxisInverted

public boolean isAxisInverted()
Checks whether axes are inverted.

Returns:
true, if axes are inverted

setAxisInverted

public void setAxisInverted(boolean axisInverted)
Specifies whether axes are inverted.

Parameters:
axisInverted - Specifies whether axes are inverted.

isAutoFitAxis

public boolean isAutoFitAxis()
Checks if axes are autofitted.

Returns:
true, if axes are autofitted.

setAutoFitAxis

public void setAutoFitAxis(boolean autoFitAxis)
Specifies whether axes should be autofitted.

Parameters:
autoFitAxis - Specifies whether axes should be autofitted.

getAxisDefaultMax

public double getAxisDefaultMax()
Gets the axis default maximum value.

Returns:
the axis default maximum value

getAxisDefaultMin

public double getAxisDefaultMin()
Gets the axis default minimum value.

Returns:
the axis default minimum value

setAxisDefaultMin

public void setAxisDefaultMin(double axisDefaultMin)
Sets the axis default minimum value.

Parameters:
axisDefaultMin - the new axis default minimum value

setAxisDefaultMax

public void setAxisDefaultMax(double axisDefaultMax)
Sets the axis default max.

Parameters:
axisDefaultMax - the new axis default max

getPreferenceFileName

public static java.lang.String getPreferenceFileName()
Gets the preference file name.

Returns:
the preference file name

resetToDefault

public void resetToDefault()
Restores all default settings.