net.sf.jomic.tools
Class BasicSettings

java.lang.Object
  extended by java.util.Dictionary
      extended by java.util.Hashtable
          extended by java.util.Properties
              extended by net.sf.jomic.tools.BasicSettings
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map
Direct Known Subclasses:
Conversion, ImageRenderSettings

public class BasicSettings
extends java.util.Properties

Extended Properties with additional features.

Author:
Thomas Aglassinger
See Also:
Properties, PropertyChangeSupport, Serialized Form

Field Summary
 
Fields inherited from class java.util.Properties
defaults
 
Constructor Summary
protected BasicSettings()
           
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
           
 void applyComponentAreaProperty(java.lang.String propertyName, java.awt.Component component)
          Apply the component location and dimension stored in propertyName on component .
 void clear()
          Reset all settings to their default value.
protected  void firePropertyChangeEvent(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Notify all listeners that have registered interest for notification on this event type.
 boolean getBooleanProperty(java.lang.String key)
           
 java.lang.String getChoiceProperty(java.lang.String propertyName, java.lang.String[] possibleChoices)
           
 java.awt.Color getColorProperty(java.lang.String propertyName)
           
 java.io.File getFileProperty(java.lang.String propertyName)
           
 int getIntProperty(java.lang.String propertyName)
           
 int getLimitedIntProperty(java.lang.String propertyName, int minValue, int maxValue)
          Get property propertyName and make sure that it is within minValue and maxValue.
 java.lang.String getProperty(java.lang.String name)
           
 java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
          Deprecated. use setDefault() to specify a default value
 java.lang.String getSystemPropertyName(java.lang.String name)
          Get name of system property corresponding to application property name.
protected  boolean isValidPropertyName(java.lang.String propertyName)
          True if propertyName is valid.
 void remove(java.lang.String key)
          Remove the property key.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
           
 void setBooleanProperty(java.lang.String key, boolean value)
           
 void setChoiceProperty(java.lang.String key, java.lang.String newValue, java.lang.String[] possibleChoices)
          Set property key to newValue, and notify all listeners about the change.
 void setColorProperty(java.lang.String key, java.awt.Color newColor)
          Sets property key to a string representation of newColor, and notifies all listeners about the change.
 void setComponentAreaProperty(java.lang.String propertyName, java.awt.Component component)
          Set property propertyName to store the location and dimension of component .
protected  void setDefault(java.lang.String key, boolean value)
          Set the default value for boolean property key to value.
protected  void setDefault(java.lang.String key, int value)
          Set the default value for integer property key to value.
protected  void setDefault(java.lang.String key, java.lang.String value)
          Set the default value for property key to value.
 void setFileProperty(java.lang.String propertyName, java.io.File newValue)
           
 void setIntProperty(java.lang.String key, int value)
           
 void setLimitedIntProperty(java.lang.String key, int value, int minValue, int maxValue)
           
 java.lang.Object setProperty(java.lang.String key, java.lang.String value)
          Set property with name key to value.
 void setSystemPropertyPrefix(java.lang.String newSystemPropertyPrefix)
           
 
Methods inherited from class java.util.Properties
list, list, load, load, loadFromXML, propertyNames, save, store, store, storeToXML, storeToXML, stringPropertyNames
 
Methods inherited from class java.util.Hashtable
clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicSettings

protected BasicSettings()
Method Detail

setBooleanProperty

public void setBooleanProperty(java.lang.String key,
                               boolean value)

setChoiceProperty

public void setChoiceProperty(java.lang.String key,
                              java.lang.String newValue,
                              java.lang.String[] possibleChoices)
Set property key to newValue, and notify all listeners about the change.

Throws:
java.lang.IllegalArgumentException - if newValue is not within possibleChoices.

setColorProperty

public void setColorProperty(java.lang.String key,
                             java.awt.Color newColor)
Sets property key to a string representation of newColor, and notifies all listeners about the change.


setComponentAreaProperty

public void setComponentAreaProperty(java.lang.String propertyName,
                                     java.awt.Component component)
Set property propertyName to store the location and dimension of component .


setFileProperty

public void setFileProperty(java.lang.String propertyName,
                            java.io.File newValue)

setIntProperty

public void setIntProperty(java.lang.String key,
                           int value)

setLimitedIntProperty

public void setLimitedIntProperty(java.lang.String key,
                                  int value,
                                  int minValue,
                                  int maxValue)

setProperty

public java.lang.Object setProperty(java.lang.String key,
                                    java.lang.String value)
Set property with name key to value.

Overrides:
setProperty in class java.util.Properties

setSystemPropertyPrefix

public void setSystemPropertyPrefix(java.lang.String newSystemPropertyPrefix)

setDefault

protected void setDefault(java.lang.String key,
                          java.lang.String value)
Set the default value for property key to value.


setDefault

protected void setDefault(java.lang.String key,
                          int value)
Set the default value for integer property key to value.


setDefault

protected void setDefault(java.lang.String key,
                          boolean value)
Set the default value for boolean property key to value.


getBooleanProperty

public boolean getBooleanProperty(java.lang.String key)

getChoiceProperty

public java.lang.String getChoiceProperty(java.lang.String propertyName,
                                          java.lang.String[] possibleChoices)

getColorProperty

public java.awt.Color getColorProperty(java.lang.String propertyName)

getFileProperty

public java.io.File getFileProperty(java.lang.String propertyName)

getIntProperty

public int getIntProperty(java.lang.String propertyName)

getLimitedIntProperty

public int getLimitedIntProperty(java.lang.String propertyName,
                                 int minValue,
                                 int maxValue)
Get property propertyName and make sure that it is within minValue and maxValue. If it is not, fix it by resetting it to its default. If there is no default for this property, reset it to the average of minValue and maxValue.


getProperty

public java.lang.String getProperty(java.lang.String name,
                                    java.lang.String defaultValue)
Deprecated. use setDefault() to specify a default value

Overrides:
getProperty in class java.util.Properties
See Also:
setDefault(String, String)

getProperty

public java.lang.String getProperty(java.lang.String name)
Overrides:
getProperty in class java.util.Properties

getSystemPropertyName

public java.lang.String getSystemPropertyName(java.lang.String name)
Get name of system property corresponding to application property name.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)

applyComponentAreaProperty

public void applyComponentAreaProperty(java.lang.String propertyName,
                                       java.awt.Component component)
Apply the component location and dimension stored in propertyName on component .


clear

public void clear()
Reset all settings to their default value.

Specified by:
clear in interface java.util.Map
Overrides:
clear in class java.util.Hashtable

remove

public void remove(java.lang.String key)
Remove the property key. This either resets it to the internal default, or the value optionally specified in the corresponding system property.


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)

isValidPropertyName

protected boolean isValidPropertyName(java.lang.String propertyName)
True if propertyName is valid. Invalid names cause an error message to be logged that explains why the name was rejected.


firePropertyChangeEvent

protected void firePropertyChangeEvent(java.lang.String propertyName,
                                       java.lang.Object oldValue,
                                       java.lang.Object newValue)
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.