public class StyleConverter<F,T>
extends java.lang.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<java.lang.String,java.lang.Boolean> |
getBooleanConverter() |
static StyleConverter<java.lang.String,Color> |
getColorConverter() |
static StyleConverter<?,Duration> |
getDurationConverter() |
static StyleConverter<ParsedValue[],Effect> |
getEffectConverter() |
static <E extends java.lang.Enum<E>> |
getEnumConverter(java.lang.Class<E> enumClass) |
static StyleConverter<ParsedValue[],Font> |
getFontConverter() |
static StyleConverter<ParsedValue[],Insets> |
getInsetsConverter() |
static StyleConverter<ParsedValue<?,Paint>,Paint> |
getPaintConverter() |
static StyleConverter<?,java.lang.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<java.lang.String,java.lang.String> |
getStringConverter()
A converter for quoted strings which may have embedded unicode characters.
|
static StyleConverter<ParsedValue[],java.lang.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<java.lang.String,java.lang.Boolean> getBooleanConverter()
StyleConverter that converts "true" or "false" to BooleanBoolean.valueOf(java.lang.String)public static StyleConverter<?,Duration> getDurationConverter()
StyleConverter that converts a String
representation of a duration to a Durationpublic static StyleConverter<java.lang.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 java.lang.Enum<E>> StyleConverter<java.lang.String,? extends java.lang.Enum<?>> getEnumConverter(java.lang.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<?,java.lang.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<java.lang.String,java.lang.String> getStringConverter()
StyleConverter that converts a representation of a
CSS string value to a String.public static StyleConverter<ParsedValue[],java.lang.String> getUrlConverter()
StyleConverter that converts a representation of a
CSS URL value to a String.Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.