ikayaki
Class Settings

java.lang.Object
  extended by ikayaki.Settings

public class Settings
extends Object

Singleton class for holding all global settings. All changes are automatically written to file after a short delay.

Author:
Esko Luontola

Field Summary
private static LastExecutor autosaveQueue
          Queue for scheduling save operations after properties/sequences have been changed
private static Runnable autosaveRunnable
          Operation that will save the properties/sequences.
private static StyledWrapper defaultWrapper
           
private static int DIRECTORY_HISTORY_SIZE
           
private static List<File> directoryHistory
          List for holding the recently used directories.
private static StyledWrapper doneRecentlyWrapper
           
private static StyledWrapper measuringWrapper
           
private static int PROJECT_HISTORY_SIZE
           
private static List<File> projectHistory
          List for holding the recently used project files.
private static Properties properties
          All properties in a map.
private static File propertiesFile
          File where the properties will be saved in XML format
private static boolean propertiesModified
          true if the properties have been modified, otherwise false
private static List<MeasurementSequence> sequences
          All saved sequences
private static File sequencesFile
          File where the sequences will be saved in XML format
private static boolean sequencesModified
          true if the sequences have been modified, otherwise false
 
Constructor Summary
Settings()
           
 
Method Summary
static void addSequence(MeasurementSequence sequence)
          Adds a sequence to the sequence list.
static void firePropertiesModified()
          Invokes autosaving for the properities.
static void fireSequencesModified()
          Invokes autosaving for the sequences.
static File[] getCalibrationProjectFiles()
           
static List<SequenceColumn> getDefaultColumns()
           
static StyledWrapper getDefaultWrapperInstance()
          Returns a copy of the default StyledWrapper.
static int getDegausserDelay()
           
static double getDegausserMaximumField()
           
static double getDegausserMinimumField()
           
static double getDegausserMinimumFieldIncrement()
           
static String getDegausserPort()
           
static int getDegausserRamp()
           
static File[] getDirectoryHistory()
           
static StyledWrapper getDoneRecentlyWrapperInstance()
          Returns a copy of the StyledWrapper for recently measured projects.
static int getHandlerAcceleration()
           
static int getHandlerAxialAFPosition()
           
static int getHandlerBackgroundPosition()
           
static int getHandlerDeceleration()
           
static int getHandlerMeasurementPosition()
           
static int getHandlerMeasurementVelocity()
           
static String getHandlerPort()
           
static int getHandlerRightLimit()
           
static int getHandlerRotation()
           
static int getHandlerRotationAcceleration()
           
static int getHandlerRotationDeceleration()
           
static int getHandlerRotationVelocity()
           
static int getHandlerSampleLoadPosition()
           
static int getHandlerTransverseYAFPosition()
           
static int getHandlerVelocity()
           
static MeasurementResult getHolderCalibration()
           
static File getHolderCalibrationFile()
           
static File getLastDirectory()
           
static String getMagnetometerPort()
           
static double getMagnetometerXAxisCalibration()
           
static double getMagnetometerYAxisCalibration()
           
static double getMagnetometerZAxisCalibration()
           
static int getMeasurementRotations()
          How many times the handler should rotate itself when taking the measurements.
static StyledWrapper getMeasuringWrapperInstance()
          Returns a copy of the StyledWrapper for measuring projects.
static File[] getProjectHistory()
           
private static String getProperty(String key)
          Returns the value that maps to the specified key.
private static String getProperty(String key, String defaultValue)
          Returns the value that maps to the specified key.
static MeasurementSequence[] getSequences()
          Returns all saved sequences in sorted order.
static int getWindowHeight()
           
static boolean getWindowMaximized()
           
static int getWindowWidth()
           
static Object getXXX()
          Generic accessor for all properties.
private static void loadDirectoryHistory()
           
private static void loadProjectHistory()
           
static void removeSequence(MeasurementSequence sequence)
          Removes a sequence from the sequence list.
static void save()
          Saves the settings after a while when no changes have come.
static boolean saveNow()
          Saves the settings and keeps waiting until its done.
static void setDefaultColumn(SequenceColumn column, boolean enabled)
           
static boolean setDegausserDelay(int value)
           
static boolean setDegausserMaximumField(double value)
           
static boolean setDegausserPort(String value)
           
static boolean setDegausserRamp(int value)
           
static boolean setHandlerAcceleration(int value)
           
static boolean setHandlerAxialAFPosition(int value)
           
static boolean setHandlerBackgroundPosition(int value)
           
static boolean setHandlerDeceleration(int value)
           
static boolean setHandlerMeasurementPosition(int value)
           
static boolean setHandlerMeasurementVelocity(int value)
           
static boolean setHandlerPort(String value)
           
static boolean setHandlerRightLimit(int value)
           
static boolean setHandlerRotation(int value)
           
static boolean setHandlerRotationAcceleration(int value)
           
static boolean setHandlerRotationDeceleration(int value)
           
static boolean setHandlerRotationVelocity(int value)
           
static boolean setHandlerSampleLoadPosition(int value)
           
static boolean setHandlerTransverseYAFPosition(int value)
           
static boolean setHandlerVelocity(int value)
           
static void setHolderCalibrationFile(File file)
           
static boolean setMagnetometerPort(String value)
           
static boolean setMagnetometerXAxisCalibration(double value)
           
static boolean setMagnetometerYAxisCalibration(double value)
           
static boolean setMagnetometerZAxisCalibration(double value)
           
static boolean setMeasurementRotations(int value)
           
private static void setProperty(String key, String value)
          Associates the specified value with the specified key.
static boolean setWindowHeight(int value)
           
static boolean setWindowMaximized(boolean value)
           
static boolean setWindowWidth(int value)
           
static boolean setXXX(Object value)
          Generic accessor for all properties.
static boolean updateDirectoryHistory(File visited)
           
static boolean updateProjectHistory(File visited)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIRECTORY_HISTORY_SIZE

private static final int DIRECTORY_HISTORY_SIZE
See Also:
Constant Field Values

PROJECT_HISTORY_SIZE

private static final int PROJECT_HISTORY_SIZE
See Also:
Constant Field Values

defaultWrapper

private static final StyledWrapper defaultWrapper

measuringWrapper

private static final StyledWrapper measuringWrapper

doneRecentlyWrapper

private static final StyledWrapper doneRecentlyWrapper

properties

private static Properties properties
All properties in a map.


propertiesFile

private static File propertiesFile
File where the properties will be saved in XML format


propertiesModified

private static boolean propertiesModified
true if the properties have been modified, otherwise false


sequences

private static List<MeasurementSequence> sequences
All saved sequences


sequencesFile

private static File sequencesFile
File where the sequences will be saved in XML format


sequencesModified

private static boolean sequencesModified
true if the sequences have been modified, otherwise false


directoryHistory

private static List<File> directoryHistory
List for holding the recently used directories. Used to cache the values read from the properties.


projectHistory

private static List<File> projectHistory
List for holding the recently used project files. Used to cache the values read from the properties.


autosaveQueue

private static LastExecutor autosaveQueue
Queue for scheduling save operations after properties/sequences have been changed


autosaveRunnable

private static Runnable autosaveRunnable
Operation that will save the properties/sequences.

Constructor Detail

Settings

public Settings()
Method Detail

firePropertiesModified

public static void firePropertiesModified()
Invokes autosaving for the properities.


fireSequencesModified

public static void fireSequencesModified()
Invokes autosaving for the sequences.


save

public static void save()
Saves the settings after a while when no changes have come. The method call will return immediately and will not wait for the file to be written.


saveNow

public static boolean saveNow()
Saves the settings and keeps waiting until its done. If no settings have been modified, will do nothing.

Returns:
true if there were no errors in writing the files or everything was already saved. Otherwise false.

getProperty

private static String getProperty(String key)
Returns the value that maps to the specified key.

Parameters:
key - key whose associated value is to be returned.
Returns:
the value associated with key, or null if none exists.

getProperty

private static String getProperty(String key,
                                  String defaultValue)
Returns the value that maps to the specified key.

Parameters:
key - key whose associated value is to be returned.
defaultValue - a default value
Returns:
the value associated with key, or defaultValue if none exists.

setProperty

private static void setProperty(String key,
                                String value)
Associates the specified value with the specified key. Will invoke autosaving.

Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key, or null to remove the value.
Throws:
NullPointerException - if key is null.

getXXX

public static Object getXXX()
Generic accessor for all properties. Returns the value from Properties in appropriate type.

Returns:
Value associated with key

setXXX

public static boolean setXXX(Object value)
Generic accessor for all properties. Checks whether the value is ok and sets it. Will invoke autosaving.

Returns:
true if value was correct, otherwise false.

getMagnetometerPort

public static String getMagnetometerPort()

setMagnetometerPort

public static boolean setMagnetometerPort(String value)

getHandlerPort

public static String getHandlerPort()

setHandlerPort

public static boolean setHandlerPort(String value)

getDegausserPort

public static String getDegausserPort()

setDegausserPort

public static boolean setDegausserPort(String value)

getMagnetometerXAxisCalibration

public static double getMagnetometerXAxisCalibration()

setMagnetometerXAxisCalibration

public static boolean setMagnetometerXAxisCalibration(double value)

getMagnetometerYAxisCalibration

public static double getMagnetometerYAxisCalibration()

setMagnetometerYAxisCalibration

public static boolean setMagnetometerYAxisCalibration(double value)

getMagnetometerZAxisCalibration

public static double getMagnetometerZAxisCalibration()

setMagnetometerZAxisCalibration

public static boolean setMagnetometerZAxisCalibration(double value)

getDegausserRamp

public static int getDegausserRamp()

setDegausserRamp

public static boolean setDegausserRamp(int value)

getDegausserDelay

public static int getDegausserDelay()

setDegausserDelay

public static boolean setDegausserDelay(int value)

setDegausserMaximumField

public static boolean setDegausserMaximumField(double value)

getDegausserMaximumField

public static double getDegausserMaximumField()

getDegausserMinimumField

public static double getDegausserMinimumField()

getDegausserMinimumFieldIncrement

public static double getDegausserMinimumFieldIncrement()

getHandlerAcceleration

public static int getHandlerAcceleration()

setHandlerAcceleration

public static boolean setHandlerAcceleration(int value)

getHandlerDeceleration

public static int getHandlerDeceleration()

setHandlerDeceleration

public static boolean setHandlerDeceleration(int value)

getHandlerVelocity

public static int getHandlerVelocity()

setHandlerVelocity

public static boolean setHandlerVelocity(int value)

getHandlerMeasurementVelocity

public static int getHandlerMeasurementVelocity()

setHandlerMeasurementVelocity

public static boolean setHandlerMeasurementVelocity(int value)

getHandlerRotationVelocity

public static int getHandlerRotationVelocity()

setHandlerRotationVelocity

public static boolean setHandlerRotationVelocity(int value)

getHandlerRotationAcceleration

public static int getHandlerRotationAcceleration()

setHandlerRotationAcceleration

public static boolean setHandlerRotationAcceleration(int value)

getHandlerRotationDeceleration

public static int getHandlerRotationDeceleration()

setHandlerRotationDeceleration

public static boolean setHandlerRotationDeceleration(int value)

getHandlerTransverseYAFPosition

public static int getHandlerTransverseYAFPosition()

setHandlerTransverseYAFPosition

public static boolean setHandlerTransverseYAFPosition(int value)

getHandlerAxialAFPosition

public static int getHandlerAxialAFPosition()

setHandlerAxialAFPosition

public static boolean setHandlerAxialAFPosition(int value)

getHandlerSampleLoadPosition

public static int getHandlerSampleLoadPosition()

setHandlerSampleLoadPosition

public static boolean setHandlerSampleLoadPosition(int value)

getHandlerBackgroundPosition

public static int getHandlerBackgroundPosition()

setHandlerBackgroundPosition

public static boolean setHandlerBackgroundPosition(int value)

getHandlerMeasurementPosition

public static int getHandlerMeasurementPosition()

setHandlerMeasurementPosition

public static boolean setHandlerMeasurementPosition(int value)

getHandlerRightLimit

public static int getHandlerRightLimit()

setHandlerRightLimit

public static boolean setHandlerRightLimit(int value)

getHandlerRotation

public static int getHandlerRotation()

setHandlerRotation

public static boolean setHandlerRotation(int value)

getMeasurementRotations

public static int getMeasurementRotations()
How many times the handler should rotate itself when taking the measurements. Possible values are 0, 1 or more.


setMeasurementRotations

public static boolean setMeasurementRotations(int value)

getWindowWidth

public static int getWindowWidth()

setWindowWidth

public static boolean setWindowWidth(int value)

getWindowHeight

public static int getWindowHeight()

setWindowHeight

public static boolean setWindowHeight(int value)

getWindowMaximized

public static boolean getWindowMaximized()

setWindowMaximized

public static boolean setWindowMaximized(boolean value)

getLastDirectory

public static File getLastDirectory()

getDirectoryHistory

public static File[] getDirectoryHistory()

updateDirectoryHistory

public static boolean updateDirectoryHistory(File visited)

loadDirectoryHistory

private static void loadDirectoryHistory()

getProjectHistory

public static File[] getProjectHistory()

updateProjectHistory

public static boolean updateProjectHistory(File visited)

loadProjectHistory

private static void loadProjectHistory()

getSequences

public static MeasurementSequence[] getSequences()
Returns all saved sequences in sorted order.


addSequence

public static void addSequence(MeasurementSequence sequence)
Adds a sequence to the sequence list. Each sequence may be added only once.


removeSequence

public static void removeSequence(MeasurementSequence sequence)
Removes a sequence from the sequence list. If the specified sequence is not in the list, it will be ignored.


getDefaultColumns

public static List<SequenceColumn> getDefaultColumns()

setDefaultColumn

public static void setDefaultColumn(SequenceColumn column,
                                    boolean enabled)

getCalibrationProjectFiles

public static File[] getCalibrationProjectFiles()

getHolderCalibrationFile

public static File getHolderCalibrationFile()

setHolderCalibrationFile

public static void setHolderCalibrationFile(File file)

getHolderCalibration

public static MeasurementResult getHolderCalibration()

getDefaultWrapperInstance

public static StyledWrapper getDefaultWrapperInstance()
Returns a copy of the default StyledWrapper.


getMeasuringWrapperInstance

public static StyledWrapper getMeasuringWrapperInstance()
Returns a copy of the StyledWrapper for measuring projects.


getDoneRecentlyWrapperInstance

public static StyledWrapper getDoneRecentlyWrapperInstance()
Returns a copy of the StyledWrapper for recently measured projects.