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() |
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 Boolean
Boolean.valueOf(java.lang.String)
public static StyleConverter<?,Duration> getDurationConverter()
StyleConverter
that converts a String
representation of a duration to a Duration
public static StyleConverter<String,Color> getColorConverter()
StyleConverter
that converts a String
representation of a web color to a Color
Color.web(java.lang.String)
public static StyleConverter<ParsedValue[],Effect> getEffectConverter()
StyleConverter
that converts a parsed representation
of an Effect
to an Effect
Effect
public static <E extends Enum<E>> StyleConverter<String,? extends Enum<?>> getEnumConverter(Class<E> enumClass)
StyleConverter
that converts a String representation
of an Enum
to an Enum
Enum.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, 2015, Oracle and/or its affiliates. All rights reserved.