net.ctdp.rfdynhud.properties
Class ColorProperty

java.lang.Object
  extended by net.ctdp.rfdynhud.properties.Property
      extended by net.ctdp.rfdynhud.properties.ColorProperty

public class ColorProperty
extends Property

The ColorProperty serves for customizing a color value.

Author:
Marvin Froehlich (CTDP)

Field Summary
static java.awt.Color FALLBACK_COLOR
           
static java.lang.String STANDARD_BACKGROUND_COLOR_NAME
           
static java.lang.String STANDARD_FONT_COLOR_NAME
           
 
Constructor Summary
ColorProperty(java.lang.String name, java.lang.String defaultValue)
           
ColorProperty(java.lang.String name, java.lang.String defaultValue, boolean readonly)
           
ColorProperty(java.lang.String name, java.lang.String nameForDisplay, java.lang.String defaultValue)
           
ColorProperty(java.lang.String name, java.lang.String nameForDisplay, java.lang.String defaultValue, boolean readonly)
           
 
Method Summary
 java.awt.Color getColor()
          Gets the property's current value.
 java.lang.String getColorKey()
          Gets the property's current value.
static java.lang.String getDefaultNamedColorValue(java.lang.String name)
           
 java.lang.String getValue()
          Gets the current value fo this property.
 boolean hasVisibleColor()
          Gets, whether this ColorProperty hosts a visible color value.
 void loadValue(PropertyLoader loader, java.lang.String value)
          Loads the value from the configuration file.
protected  void onKeeperSet()
          
protected  void onValueChanged(java.lang.String oldValue, java.lang.String newValue)
          Invoked when the value has changed.
 void refresh()
          Must be called after color names have changed in the editor.
 boolean setColor(java.awt.Color color)
          Sets the new property's value.
 boolean setColor(int red, int green, int blue)
          Sets the new property's value.
 boolean setColor(java.lang.String colorKey)
          Sets the new property's value.
protected  boolean setColor(java.lang.String colorKey, boolean firstTime)
          Sets the new property's value.
 void setValue(java.lang.Object value)
          Sets the new value for this property.
 
Methods inherited from class net.ctdp.rfdynhud.properties.Property
getButtonText, getButtonTooltip, getDocumentationSource, getEditorType, getKeeper, getName, getNameForDisplay, getValueForConfigurationFile, isMatchingKey, isReadOnly, onButtonClicked, quoteValueInConfigurationFile, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STANDARD_BACKGROUND_COLOR_NAME

public static final java.lang.String STANDARD_BACKGROUND_COLOR_NAME
See Also:
Constant Field Values

STANDARD_FONT_COLOR_NAME

public static final java.lang.String STANDARD_FONT_COLOR_NAME
See Also:
Constant Field Values

FALLBACK_COLOR

public static final java.awt.Color FALLBACK_COLOR
Constructor Detail

ColorProperty

public ColorProperty(java.lang.String name,
                     java.lang.String nameForDisplay,
                     java.lang.String defaultValue,
                     boolean readonly)
Parameters:
name - the technical name used internally. See Property.getName().
nameForDisplay - the name displayed in the editor. See Property.getNameForDisplay(). If null is passed, the value of the name parameter is used.
defaultValue - the default value
readonly - read only property?

ColorProperty

public ColorProperty(java.lang.String name,
                     java.lang.String nameForDisplay,
                     java.lang.String defaultValue)
Parameters:
name - the technical name used internally. See Property.getName().
nameForDisplay - the name displayed in the editor. See Property.getNameForDisplay(). If null is passed, the value of the name parameter is used.
defaultValue - the default value

ColorProperty

public ColorProperty(java.lang.String name,
                     java.lang.String defaultValue,
                     boolean readonly)
Parameters:
name - the technical name used internally. See Property.getName(). 'nameForDisplay' is set to the same value.
defaultValue - the default value
readonly - read only property?

ColorProperty

public ColorProperty(java.lang.String name,
                     java.lang.String defaultValue)
Parameters:
name - the technical name used internally. See Property.getName(). 'nameForDisplay' is set to the same value.
defaultValue - the default value
Method Detail

getDefaultNamedColorValue

public static java.lang.String getDefaultNamedColorValue(java.lang.String name)

onKeeperSet

protected void onKeeperSet()

Overrides:
onKeeperSet in class Property

onValueChanged

protected void onValueChanged(java.lang.String oldValue,
                              java.lang.String newValue)
Invoked when the value has changed.

Parameters:
oldValue - the old value
newValue - the new value

refresh

public void refresh()
Must be called after color names have changed in the editor.


setColor

protected final boolean setColor(java.lang.String colorKey,
                                 boolean firstTime)
Sets the new property's value.

Parameters:
colorKey - the new value
firstTime -
Returns:
changed?

setColor

public final boolean setColor(java.lang.String colorKey)
Sets the new property's value.

Parameters:
colorKey - the new value
Returns:
changed?

setColor

public final boolean setColor(java.awt.Color color)
Sets the new property's value.

Parameters:
color - the new value
Returns:
changed?

setColor

public final boolean setColor(int red,
                              int green,
                              int blue)
Sets the new property's value.

Parameters:
red -
green -
blue -
Returns:
changed?

getColorKey

public final java.lang.String getColorKey()
Gets the property's current value.

Returns:
the property's current value.

getColor

public final java.awt.Color getColor()
Gets the property's current value.

Returns:
the property's current value.

hasVisibleColor

public final boolean hasVisibleColor()
Gets, whether this ColorProperty hosts a visible color value.

Returns:
true, if and only if getColor() returns a non null value with an alpha channel > 0.

setValue

public void setValue(java.lang.Object value)
Sets the new value for this property.

Specified by:
setValue in class Property
Parameters:
value - the new value

getValue

public java.lang.String getValue()
Gets the current value fo this property.

Specified by:
getValue in class Property
Returns:
the current value fo this property.

loadValue

public void loadValue(PropertyLoader loader,
                      java.lang.String value)
Loads the value from the configuration file.

Specified by:
loadValue in class Property
Parameters:
loader - the loader
value - the value to load