cz.cuni.jagrlib.gui
Class Options

java.lang.Object
  extended by cz.cuni.jagrlib.gui.Options

public class Options
extends Object

Class storing global Skel preferences.

Version:
0.26 $Rev: 586 $ $Date: 2007-11-03 10:49:26 +0100 (so, 03 XI 2007) $ $Author: pepca $
See Also:
Options.java

Field Summary
static String FILE_NAME_REG
          Default resource directory.
static String optionsFileName
          Options file name - user preferences.
protected static String PATH_DATA
          Default data directory.
protected static String PATH_EDITOR
          Default external viewer/editor.
protected static String PATH_REG
          Default path to registry database.
protected static String PATH_RESOURCES
          Default resource directory.
protected static String PATH_SOURCE
          Default source path.
protected static String PATH_SYS_OPTIONS
          Default file name of system preferences.
static String pathData
          Actual data directory.
static String pathEditor
          Actual external viewer/editor.
static String pathReg
          Actual path to registry database.
static String pathResources
          Actual resource directory.
static String pathSource
          Actual source path.
protected static Properties pref
          User options in "key->value" format.
static String sysOptionsFileName
          Options file name - system preferences.
static String sysOptionsOrigFileName
          Options file name - system preferences (original values).
protected static Properties system
          System options in "key->value" format.
protected static HashSet<String> systemKeys
          Keys which are updated in 'system' rather than in 'pref'.
 
Constructor Summary
Options()
           
 
Method Summary
static String colorToHexString(Color c)
          Converts Color to HexString (#AARRGGBB).
static boolean getBoolean(String key)
          Parses boolean parameter.
static Color getColor(String key)
          Parses color description and returns valid Color instance.
static ImageIcon getIcon(String fileName)
          Retrieves icon object from resource (JAR) or disk file.
static int getInteger(String key)
          Parses integer parameter w/o bounds checking.
static int getInteger(String key, int min, int max, int deflt)
          Parses integer parameter and checks its bounds.
static InputStream getResource(String fileName)
          Retrieves resource stream object from URL resource (JAR).
static String getString(String key)
          Parses string parameter.
static String getString(String key, String deflt)
          Parses string parameter.
static void init()
          Loads preference files from the disk and [re-]initializes working values.
static void interpret()
          Interprets preference dictionaries.
static void load()
          Loads both preference files from disk to the dictionaries.
static void reflect()
          Fills both dictionaries with the actual working values.
static void save()
          Stores both preference files from dictionaries to disk files.
static void set(String key, boolean b)
          Sets the boolean parameter.
static void set(String key, Color c)
          Sets the color parameter.
static void set(String key, int i)
          Sets the integer parameter.
static void set(String key, String value)
          Sets the string parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_RESOURCES

protected static final String PATH_RESOURCES
Default resource directory.

See Also:
Constant Field Values

pathResources

public static String pathResources
Actual resource directory.


PATH_DATA

protected static final String PATH_DATA
Default data directory.

See Also:
Constant Field Values

pathData

public static String pathData
Actual data directory.


FILE_NAME_REG

public static final String FILE_NAME_REG
Default resource directory.

See Also:
Constant Field Values

PATH_REG

protected static final String PATH_REG
Default path to registry database.

See Also:
Constant Field Values

pathReg

public static String pathReg
Actual path to registry database.


PATH_SOURCE

protected static final String PATH_SOURCE
Default source path.

See Also:
Constant Field Values

pathSource

public static String pathSource
Actual source path.


PATH_EDITOR

protected static final String PATH_EDITOR
Default external viewer/editor.

See Also:
Constant Field Values

pathEditor

public static String pathEditor
Actual external viewer/editor.


optionsFileName

public static String optionsFileName
Options file name - user preferences.


sysOptionsFileName

public static String sysOptionsFileName
Options file name - system preferences.


PATH_SYS_OPTIONS

protected static final String PATH_SYS_OPTIONS
Default file name of system preferences.

See Also:
Constant Field Values

sysOptionsOrigFileName

public static String sysOptionsOrigFileName
Options file name - system preferences (original values).


pref

protected static Properties pref
User options in "key->value" format.


system

protected static Properties system
System options in "key->value" format.


systemKeys

protected static HashSet<String> systemKeys
Keys which are updated in 'system' rather than in 'pref'.

Constructor Detail

Options

public Options()
Method Detail

init

public static void init()
Loads preference files from the disk and [re-]initializes working values.


save

public static void save()
                 throws IOException
Stores both preference files from dictionaries to disk files. Doesn't fill dictionaries from working state variables.

Throws:
IOException
See Also:
reflect()

load

public static void load()
                 throws IOException
Loads both preference files from disk to the dictionaries. Doesn't parse (interpret) the read values.

Throws:
IOException
See Also:
interpret()

getColor

public static Color getColor(String key)
Parses color description and returns valid Color instance. If the given string cannot be parsed, returns #ff000000 (black).


getBoolean

public static boolean getBoolean(String key)
Parses boolean parameter. Returns 'false' in case of failure.


getInteger

public static int getInteger(String key,
                             int min,
                             int max,
                             int deflt)
Parses integer parameter and checks its bounds. Returns 'deflt' in case of failure.


getInteger

public static int getInteger(String key)
Parses integer parameter w/o bounds checking.


getString

public static String getString(String key,
                               String deflt)
Parses string parameter. Returns 'deflt' in case of failure.


getString

public static String getString(String key)
Parses string parameter. Returns null in case of failure.


interpret

public static void interpret()
Interprets preference dictionaries. Fills all working state variables from the actual dictionaries.


reflect

public static void reflect()
Fills both dictionaries with the actual working values. Should be called before the save() operation.


colorToHexString

public static String colorToHexString(Color c)
Converts Color to HexString (#AARRGGBB).

Parameters:
c - Color to be converted (const).
Returns:
String representation of the color.

set

public static void set(String key,
                       String value)
Sets the string parameter. interpret() should be called to reflect all changes in working state variables.


set

public static void set(String key,
                       Color c)
Sets the color parameter. interpret() should be called to reflect all changes in working state variables.


set

public static void set(String key,
                       boolean b)
Sets the boolean parameter. interpret() should be called to reflect all changes in working state variables.


set

public static void set(String key,
                       int i)
Sets the integer parameter. interpret() should be called to reflect all changes in working state variables.


getIcon

public static ImageIcon getIcon(String fileName)
Retrieves icon object from resource (JAR) or disk file.


getResource

public static InputStream getResource(String fileName)
Retrieves resource stream object from URL resource (JAR).