cz.psika.numerist
Class StyleManager

java.lang.Object
  extended by cz.psika.numerist.StyleManager

public class StyleManager
extends java.lang.Object

Management of entry styles.

Author:
Tomas Psika

Field Summary
protected static Style currentStyle
          Current Style object.
protected static java.util.Map<java.lang.String,java.io.File> styleFiles
          Cache of style files.
protected static java.util.Map<java.lang.String,Style> stylesMap
          Map of all currently usable styles.
 
Constructor Summary
StyleManager()
           
 
Method Summary
static java.lang.String[] findAllStyles()
          Get all style names available for now and initialize cache of style files in order of later use.
static Style getCurrentStyle()
          Load current numerology style of characteristics.
static Style getStyle(java.lang.String styleName)
          Get numerology style of characteristics by name.
protected static Style loadStyle(java.lang.String loadingStyle)
          Loads style from configuration file.
static boolean setCurrentStyle(java.lang.String styleName)
          Set current default style of characteristics used for newly created entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentStyle

protected static Style currentStyle
Current Style object.


stylesMap

protected static final java.util.Map<java.lang.String,Style> stylesMap
Map of all currently usable styles.


styleFiles

protected static final java.util.Map<java.lang.String,java.io.File> styleFiles
Cache of style files. There is no need find out regular style files every time, this cache prevents some performance loss.

Constructor Detail

StyleManager

public StyleManager()
Method Detail

getStyle

public static Style getStyle(java.lang.String styleName)
Get numerology style of characteristics by name.

Parameters:
styleName - name of style wanted
Returns:
Style object or null on error

setCurrentStyle

public static boolean setCurrentStyle(java.lang.String styleName)
Set current default style of characteristics used for newly created entries. In case of some error, old settings are rollbacked and we could probably continue.

Parameters:
styleName - name of style
Returns:
true on success, false otherwise

getCurrentStyle

public static Style getCurrentStyle()
Load current numerology style of characteristics.

Returns:
current style or null when not initialized yet

loadStyle

protected static Style loadStyle(java.lang.String loadingStyle)
Loads style from configuration file.

Parameters:
loadingStyle - style to load
Returns:
found style or null

findAllStyles

public static java.lang.String[] findAllStyles()
Get all style names available for now and initialize cache of style files in order of later use. Standard style definitions could be overloaded, next list shows priority of directories checked when searching for style files used in application. First items has higher priority. It is possible to e.g. copy style file from /usr/share/numerist/styles directory, copy it to ~/.numerist/styles and change settings. Your settings will be used instead.

Directory priorities (first items have higher priority):

Returns:
array of style names
See Also:
ConfigurationUtils.getApplicationFiles(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String[])