public class StyleConverter<F,T> extends Object
ParsedValue&tl;F,T> from type F to type T. the
CssMetaData API requires a StyleConverter which is used
when computing a value for the StyleableProperty. There are
a number of predefined converters which are accessible by the static
methods of this class.ParsedValue,
StyleableProperty| Constructor and Description |
|---|
StyleConverter() |
| Modifier and Type | Method and Description |
|---|---|
T |
convert(ParsedValue<F,T> value,
Font font)
Convert from the parsed CSS value to the target property type.
|
static StyleConverter<String,Boolean> |
getBooleanConverter() |
static StyleConverter<String,Color> |
getColorConverter() |
static StyleConverter<ParsedValue[],Effect> |
getEffectConverter() |
static <E extends Enum<E>> |
getEnumConverter(Class<E> enumClass) |
static StyleConverter<ParsedValue[],Font> |
getFontConverter() |
static StyleConverter<ParsedValue[],Insets> |
getInsetsConverter() |
static StyleConverter<ParsedValue<?,Paint>,Paint> |
getPaintConverter() |
static StyleConverter<?,Number> |
getSizeConverter()
CSS length and number values are parsed into a Size object that is
converted to a Number before the value is applied.
|
static StyleConverter<String,String> |
getStringConverter()
A converter for quoted strings which may have embedded unicode characters.
|
static StyleConverter<ParsedValue[],String> |
getUrlConverter()
A converter for URL strings.
|
public T convert(ParsedValue<F,T> value, Font font)
value - The ParsedValue to convertfont - The Font to use when converting a
relative
value.public static StyleConverter<String,Boolean> getBooleanConverter()
StyleConverter that converts "true" or "false" to BooleanBoolean.valueOf(java.lang.String)public static StyleConverter<String,Color> getColorConverter()
StyleConverter that converts a String
representation of a web color to a ColorColor.web(java.lang.String)public static StyleConverter<ParsedValue[],Effect> getEffectConverter()
StyleConverter that converts a parsed representation
of an Effect to an EffectEffectpublic static <E extends Enum<E>> StyleConverter<String,? extends Enum<?>> getEnumConverter(Class<E> enumClass)
StyleConverter that converts a String representation
of an Enum to an EnumEnum.valueOf(java.lang.Class, java.lang.String)public static StyleConverter<ParsedValue[],Font> getFontConverter()
StyleConverter that converts a parsed representation
of a Font to an Font.Font.font(java.lang.String, javafx.scene.text.FontWeight, javafx.scene.text.FontPosture, double)public static StyleConverter<ParsedValue[],Insets> getInsetsConverter()
StyleConverter that converts a [<length> |
<percentage>]{1,4} to an Insets.public static StyleConverter<ParsedValue<?,Paint>,Paint> getPaintConverter()
StyleConverter that converts a parsed representation
of a Paint to a Paint.public static StyleConverter<?,Number> getSizeConverter()
Number type other than Double, the
set
method of (CssMetaData can be over-ridden to convert the Number
to the correct type. For example, if the property is an IntegerProperty:
@Override public void set(MyNode node, Number value, Origin origin) {
if (value != null) {
super.set(node, value.intValue(), origin);
} else {
super.set(node, value, origin);
}
}
StyleConverter that converts a parsed representation
of a CSS length or number value to a Number that is an instance
of Double.public static StyleConverter<String,String> getStringConverter()
StyleConverter that converts a representation of a
CSS string value to a String.public static StyleConverter<ParsedValue[],String> getUrlConverter()
StyleConverter that converts a representation of a
CSS URL value to a String.Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.