public class ColorPropertyType extends PropertyType<Color>
java.awt.Color. #RGB' - example '#ffff00'| Constructor Example | Comments | ||
|---|---|---|---|
Property<Color> A_PROPERTY = |
No default value. No min or max color constraints. | ||
Property<Color> A_PROPERTY = |
Default value is "Color.blue". No min or max color constraints. | ||
Property<Color> A_PROPERTY = |
Default value is "Color.blue". The color value must be between #333333 and #999999 both inclusive. | ||
| Type of value(s) | Examples | Result | Comments |
| Invalid | cow | null |
Validate will throw an exception. The resulting value is null. |
| Invalid | horse | null |
|
| Invalid | «empty string» | null |
|
| Invalid | «empty string after trim» | null |
|
| Invalid | null |
defaultValue OR null |
Validate will throw an exception. Return default value if set, otherwise null. |
Color,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static String |
TYPE
The type name string constant of ColorPropertyType
|
| Constructor and Description |
|---|
ColorPropertyType()
Returns ColorPropertyType where the default value is
null.Color Formatter is default RGBAColorFormat() for colors with alpha value that differs from 255, and HexColorFormat() when not |
ColorPropertyType(Color defaultValue)
Returns ColorPropertyType with default value.
|
ColorPropertyType(Color minColor,
Color maxColor)
Returns ColorPropertyType with no default value, but with min or max color value.
Color Formatter is default RGBAColorFormat() for colors with alpha value that differs from 255, and HexColorFormat() when not |
ColorPropertyType(Color defaultValue,
Color minColor,
Color maxColor)
Returns ColorPropertyType with default value and min or max color value.
Color Formatter is default RGBAColorFormat() for colors with alpha value that differs from 255, and HexColorFormat() when not |
| Modifier and Type | Method and Description |
|---|---|
protected ColorComparator |
getColorComparator()
Gets a new instance of the current ColorComparator.
|
List<ColorFormat> |
getColorFormats()
All known color formats for the PropertyType in a Collections.unmodifiableList.
|
ColorFormat |
getFormatterWithAlpha()
Gets the ColorFormat used when making a string representation with alpha value of a color.
|
ColorFormat |
getFormatterWithoutAlpha()
Gets the ColorFormat used when making a string representation without alpha value of a color.
|
ColorFormat |
getLastFormatterUsed()
Gets the last ColorFormat instance used to read and convert a String value into a Color.
|
Color |
getMaxColor()
Gets the maximum color a value is allowed to be.
|
Color |
getMinColor()
Gets the minimum color a value is allowed to be.
|
List<String> |
getRestrictions()
Gets a detailed description of the PropertyType with any constraints that might influence the validation.
|
boolean |
isUseLastFormatter()
Will we be using the last ColorFormat to set Color values.
|
boolean |
isUseMaxColor()
If there is maximum limit on the color value.
|
boolean |
isUseMinColor()
If there is minimum limit on the color value.
|
void |
setFormatterWithAlpha(ColorFormat formatter)
Sets the ColorFormat used when constructing a string version of a color which has an alpha value different from 255.
|
void |
setFormatterWithoutAlpha(ColorFormat formatter)
Sets the ColorFormat used when constructing a string version of a color which has an alpha value equal to 255, meaning that alpha value will not be rendered.
|
void |
setLastFormatterUsed(ColorFormat lastFormatterUsed)
Set the ColorFormat we want to use when converting a Color to String an setting the Color in a PropertyIO.
|
void |
setMaxColor(Color maxColor)
Sets the maximum color a value is allowed to be.
|
void |
setMinColor(Color minColor)
Sets the minimum color a value is allowed to be.
|
String |
toString(String propertyName,
Color t)
A string version of the color.
|
void |
validateConstraints(String propertyName)
A PropertyType can have some constraints here is where they are
validated.
|
Color |
validateValue(String propertyName,
String value)
Converts the string representation of to a typed value.
|
equals, getDefaultValue, getDefaultValueAsString, getDefaultValueDescription, getDescription, getDescription, getInitializationPriority, getIo, getLogger, getTypeName, hasDefaultValue, isDefaultValueValid, postGetValueProcessing, setDefaultValue, setInitializationPriority, setIo, setTypedValue, setTypeName, toType, validate, validateNullTypepublic static final String TYPE
public ColorPropertyType()
null.public ColorPropertyType(Color defaultValue)
defaultValue - default value returned if property value is undefined.public ColorPropertyType(Color minColor, Color maxColor)
minColor - the min color allowed, if null no min color limit, all RGB values must be less than maxColor RGB values (if not null).maxColor - the max color allowed, if null no max color limit, all RGB values must be greather than minColor RGB values (if not null).public ColorPropertyType(Color defaultValue, Color minColor, Color maxColor)
defaultValue - default value returned if property value is undefined.minColor - the min color allowed, if null no min color limit, all RGB values must be less than maxColor RGB values (if not null).maxColor - the max color allowed, if null no max color limit, all RGB values must be greather than minColor RGB values (if not null).public List<ColorFormat> getColorFormats()
public List<String> getRestrictions()
PropertyTypegetRestrictions in class PropertyType<Color>public String toString(String propertyName, Color t) throws PropertyException
true and the getLastFormatterUsed() is not null, then we use this to convert the Color to a String.
Otherwise if the color has a alpha value that differs from 255, the a string is return in the, getFormatterWithAlpha(), otherwise the getFormatterWithoutAlpha() is used.
Color Formatter is default RGBAColorFormat() for colors with alpha value that differs from 255, and HexColorFormat() when not.toString in class PropertyType<Color>propertyName - the name of the property used for logging purposes.t - the type T.PropertyException - if conversion failed in validation.getFormatterWithAlpha(),
getFormatterWithoutAlpha(),
isUseLastFormatter(),
getLastFormatterUsed()public Color validateValue(String propertyName, String value) throws PropertyException
PropertyTypevalidateValue in class PropertyType<Color>propertyName - the name of the property used for logging purposes. To uniquely identify the Property with validation issues.value - the string representation of the propertyPropertyException - if the conversion failed.public void validateConstraints(String propertyName) throws PropertyException
PropertyTypevalidateConstraints in class PropertyType<Color>propertyName - the name of the property used for logging purposes, to
identify the unique property which PropertyType has constraint
issues.PropertyException - if the constraints have invalid/conflicting values.Property.validate()public Color getMinColor()
null means no limit.public Color getMaxColor()
null means no limit.public void setMinColor(Color minColor)
minColor - the minimum color, null means no limit.public void setMaxColor(Color maxColor)
maxColor - the maximum color, null means no limit.public boolean isUseMinColor()
true, if getMinColor is different from null meaning there is a minimum limit. Otherwise false.public boolean isUseMaxColor()
true, if getMaxColor is different from null meaning there is a maximum limit. Otherwise false.public ColorFormat getFormatterWithAlpha()
public ColorFormat getFormatterWithoutAlpha()
public void setFormatterWithAlpha(ColorFormat formatter) throws NullPointerException, IllegalArgumentException
formatter - the ColorFormat used when an alpha value also shall be represented.NullPointerException - if the formatter is null.IllegalArgumentException - if the formatter do not supports alpha.ColorFormat.isAlphaSupported()public void setFormatterWithoutAlpha(ColorFormat formatter) throws NullPointerException
formatter - formatter the ColorFormat used when an alpha value shall not be represented.NullPointerException - if the formatter is null.public ColorFormat getLastFormatterUsed()
public boolean isUseLastFormatter()
public void setLastFormatterUsed(ColorFormat lastFormatterUsed)
lastFormatterUsed - the lastFormatterUsed to set a the color value.protected ColorComparator getColorComparator()