Top Description Inners Fields Constructors Methods
javafx.css

public Class StyleConverter<F, T>

extends Object
Class Inheritance
Known Direct Subclasses
javafx.css.converter.BooleanConverter, javafx.css.converter.ColorConverter, javafx.css.converter.CursorConverter, javafx.css.converter.DeriveColorConverter, javafx.css.converter.DeriveSizeConverter, javafx.css.converter.DurationConverter, javafx.css.converter.DurationConverter.SequenceConverter, javafx.css.converter.EffectConverter, javafx.css.converter.EnumConverter, javafx.css.converter.FontConverter, javafx.css.converter.FontConverter.FontStyleConverter, javafx.css.converter.FontConverter.FontWeightConverter, javafx.css.converter.FontConverter.FontSizeConverter, javafx.css.converter.InsetsConverter, javafx.css.converter.InsetsConverter.SequenceConverter, javafx.css.converter.LadderConverter, javafx.css.converter.PaintConverter, javafx.css.converter.PaintConverter.SequenceConverter, javafx.css.converter.PaintConverter.LinearGradientConverter, javafx.css.converter.PaintConverter.ImagePatternConverter, javafx.css.converter.PaintConverter.RepeatingImagePatternConverter, javafx.css.converter.PaintConverter.RadialGradientConverter, javafx.css.converter.ShapeConverter, javafx.css.converter.SizeConverter, javafx.css.converter.SizeConverter.SequenceConverter, javafx.css.converter.StopConverter, javafx.css.converter.StringConverter, javafx.css.converter.StringConverter.SequenceConverter, javafx.css.converter.URLConverter, javafx.css.converter.URLConverter.SequenceConverter, javafx.scene.layout.BackgroundConverter, javafx.scene.layout.BorderConverter, com.sun.javafx.css.InterpolatorConverter, com.sun.javafx.css.InterpolatorConverter.SequenceConverter, com.sun.javafx.css.TransitionDefinitionConverter, com.sun.javafx.css.TransitionDefinitionConverter.SequenceConverter, com.sun.javafx.scene.layout.region.BackgroundPositionConverter, com.sun.javafx.scene.layout.region.BackgroundSizeConverter, com.sun.javafx.scene.layout.region.BorderImageSliceConverter, com.sun.javafx.scene.layout.region.BorderImageWidthConverter, com.sun.javafx.scene.layout.region.BorderImageWidthsSequenceConverter, com.sun.javafx.scene.layout.region.BorderStrokeStyleSequenceConverter, com.sun.javafx.scene.layout.region.BorderStyleConverter, com.sun.javafx.scene.layout.region.CornerRadiiConverter, com.sun.javafx.scene.layout.region.LayeredBackgroundPositionConverter, com.sun.javafx.scene.layout.region.LayeredBackgroundSizeConverter, com.sun.javafx.scene.layout.region.LayeredBorderPaintConverter, com.sun.javafx.scene.layout.region.LayeredBorderStyleConverter, com.sun.javafx.scene.layout.region.Margins.Converter, com.sun.javafx.scene.layout.region.Margins.SequenceConverter, com.sun.javafx.scene.layout.region.RepeatStructConverter, com.sun.javafx.scene.layout.region.SliceSequenceConverter, com.sun.javafx.scene.layout.region.StrokeBorderPaintConverter
Type Parameters
<F>
the type of the parsed value
<T>
the converted type of the ParsedValueImpl
Imports
javafx.css.converter.BooleanConverter, .ColorConverter, .DeriveColorConverter, .DeriveSizeConverter, .DurationConverter, .EffectConverter, .EnumConverter, .FontConverter, .InsetsConverter, .LadderConverter, .PaintConverter, .SizeConverter, .StopConverter, .StringConverter, .URLConverter, javafx.geometry.Insets, javafx.scene.effect.Effect, javafx.scene.paint.Color, .Paint, javafx.scene.text.Font, javafx.util.Duration, com.sun.javafx.scene.layout.region.CornerRadiiConverter, com.sun.javafx.util.Logging, com.sun.javafx.logging.PlatformLogger, .PlatformLogger.Level, java.io.DataInputStream, .DataOutputStream, .IOException, java.util.ArrayList, .HashMap, .List, .Map, .WeakHashMap

StyleConverter converts ParsedValue<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. F is the type of the parsed value and T is the converted type of the ParsedValueImpl. For example, a converter from String to Color would be declared

     public Color convert(ParsedValueImpl<String,Color> value, Font font)

Since
JavaFX 8.0
See Also
ParsedValue, StyleableProperty

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
StyleConverter.StringStore

The StringStore class.

Field Summary

Modifier and TypeField and Description
private static Map<ParsedValue<V, T>, Object>
private static Map<String, StyleConverter<?, ?>>

Constructor Summary

AccessConstructor and Description
public
StyleConverter()

Creates a StyleConverter.

Method Summary

Modifier and TypeMethod and Description
protected void
cacheValue(ParsedValue<V, T>
the key
key
,
Object
the value
value
)

Cache the value for the specified key.

public static void
clearCache()

Clear the cache.

public T

Returns:

the converted target property type
convert
(ParsedValue<F, T>
The ParsedValue to convert
value
,
Font
The Font to use when converting a relative value.
font
)

Convert from the parsed CSS value to the target property type.

public T

Returns:

the target property type
convert
(Map<CssMetaData<? extends Styleable, ?>, Object>
the constituent values
convertedValues
)

Convert from the constituent values to the target property type.

public static StyleConverter<String, Boolean>

Returns:

A StyleConverter that converts "true" or "false" to Boolean
getBooleanConverter
()

Return a StyleConverter that converts "true" or "false" to Boolean.

protected T

Returns:

the cached value
getCachedValue
(ParsedValue<V, T>
the key
key
)

Get the cached value for the specified key.

public static StyleConverter<String, Color>

Returns:

A StyleConverter that converts a String representation of a web color to a Color
getColorConverter
()

Return a StyleConverter that converts a String representation of a web color to a Color.

public static StyleConverter<?, Duration>

Returns:

A StyleConverter that converts a String representation of a duration to a Duration
getDurationConverter
()

Return a StyleConverter that converts a String representation of a duration to a Duration.

public static StyleConverter<ParsedValue<V, T>[], Effect>

Returns:

A StyleConverter that converts a parsed representation of an Effect to an Effect
getEffectConverter
()

Return a StyleConverter that converts a parsed representation of an Effect to an Effect

public static <
the type of the Enum
E extends Enum<E>
>
StyleConverter<String, E>

Returns:

A StyleConverter that converts a String representation of an Enum to an Enum
getEnumConverter
(Class<E>
the enum Class
enumClass
)

Return a StyleConverter that converts a String representation of an Enum to an Enum.

public static StyleConverter<ParsedValue<V, T>[], Font>

Returns:

A StyleConverter that converts a parsed representation of a Font to an Font
getFontConverter
()

Return a StyleConverter that converts a parsed representation of a Font to an Font.

public static StyleConverter<ParsedValue<V, T>[], Insets>

Returns:

A StyleConverter that converts a [<length> | <percentage>]{1,4} to an Insets
getInsetsConverter
()

Return a StyleConverter that converts a [<length> | <percentage>]{1,4} to an Insets.

pack-priv static StyleConverter<?, ?>
getInstance(final String converterClass)

public static StyleConverter<ParsedValue<?, Paint>, Paint>

Returns:

A StyleConverter that converts a parsed representation of a Paint to a Paint
getPaintConverter
()

Return a StyleConverter that converts a parsed representation of a Paint to a Paint.

public static StyleConverter<?, Number>

Returns:

A StyleConverter that converts a parsed representation of a CSS length or number value to a Number that is an instance of Double
getSizeConverter
()

CSS length and number values are parsed into a Size object that is converted to a Number before the value is applied.

public static StyleConverter<String, String>

Returns:

A StyleConverter that converts a representation of a CSS string value to a String
getStringConverter
()

A converter for quoted strings which may have embedded unicode characters.

public static StyleConverter<ParsedValue<V, T>[], String>

Returns:

A StyleConverter that converts a representation of a CSS URL value to a String
getUrlConverter
()

A converter for URL strings.

public static StyleConverter<?, ?>

Returns:

the style converter
readBinary
(DataInputStream
the data input stream
is
,
String[]
the strings
strings
)

Read binary data stream.

public void
writeBinary(DataOutputStream
the data output stream
os
,
StyleConverter.StringStore
the string store
sstore
)

Write binary data.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private static Map<ParsedValue<V, T>, Object> cache
tmapback to summary
private static Map<String, StyleConverter<?, ?>> tmap

Constructor Detail

StyleConverterback to summary
public StyleConverter()

Creates a StyleConverter.

Method Detail

cacheValueback to summary
protected void cacheValue(ParsedValue<V, T> key, Object value)

Cache the value for the specified key.

Parameters
key:ParsedValue<V, T>

the key

value:Object

the value

Since
9
clearCacheback to summary
public static void clearCache()

Clear the cache.

Since
9
convertback to summary
public T convert(ParsedValue<F, T> value, Font font)

Convert from the parsed CSS value to the target property type.

Parameters
value:ParsedValue<F, T>

The ParsedValue to convert

font:Font

The Font to use when converting a relative value.

Returns:T

the converted target property type

Annotations
@SuppressWarnings:unchecked
convertback to summary
public T convert(Map<CssMetaData<? extends Styleable, ?>, Object> convertedValues)

Convert from the constituent values to the target property type. Implemented by Types that have Keys with subKeys.

Parameters
convertedValues:Map<CssMetaData<? extends Styleable, ?>, Object>

the constituent values

Returns:T

the target property type

Since
9
getBooleanConverterback to summary
public static StyleConverter<String, Boolean> getBooleanConverter()

Return a StyleConverter that converts "true" or "false" to Boolean.

Returns:StyleConverter<String, Boolean>

A StyleConverter that converts "true" or "false" to Boolean

See Also
Boolean#valueOf(java.lang.String)
getCachedValueback to summary
protected T getCachedValue(ParsedValue<V, T> key)

Get the cached value for the specified key.

Parameters
key:ParsedValue<V, T>

the key

Returns:T

the cached value

Since
9
getColorConverterback to summary
public static StyleConverter<String, Color> getColorConverter()

Return a StyleConverter that converts a String representation of a web color to a Color.

Returns:StyleConverter<String, Color>

A StyleConverter that converts a String representation of a web color to a Color

See Also
Color#web(java.lang.String)
getDurationConverterback to summary
public static StyleConverter<?, Duration> getDurationConverter()

Return a StyleConverter that converts a String representation of a duration to a Duration.

Returns:StyleConverter<?, Duration>

A StyleConverter that converts a String representation of a duration to a Duration

Since
JavaFX 8u40
getEffectConverterback to summary
public static StyleConverter<ParsedValue<V, T>[], Effect> getEffectConverter()

Return a StyleConverter that converts a parsed representation of an Effect to an Effect

Returns:StyleConverter<ParsedValue<V, T>[], Effect>

A StyleConverter that converts a parsed representation of an Effect to an Effect

See Also
Effect
getEnumConverterback to summary
public static <E extends Enum<E>> StyleConverter<String, E> getEnumConverter(Class<E> enumClass)

Return a StyleConverter that converts a String representation of an Enum to an Enum.

Parameters
<E>
the type of the Enum
enumClass:Class<E>

the enum Class

Returns:StyleConverter<String, E>

A StyleConverter that converts a String representation of an Enum to an Enum

See Also
Enum#valueOf(java.lang.Class, java.lang.String)
getFontConverterback to summary
public static StyleConverter<ParsedValue<V, T>[], Font> getFontConverter()

Return a StyleConverter that converts a parsed representation of a Font to an Font.

Returns:StyleConverter<ParsedValue<V, T>[], Font>

A StyleConverter that converts a parsed representation of a Font to an Font

See Also
Font#font(java.lang.String, javafx.scene.text.FontWeight, javafx.scene.text.FontPosture, double)
getInsetsConverterback to summary
public static StyleConverter<ParsedValue<V, T>[], Insets> getInsetsConverter()

Return a StyleConverter that converts a [<length> | <percentage>]{1,4} to an Insets.

Returns:StyleConverter<ParsedValue<V, T>[], Insets>

A StyleConverter that converts a [<length> | <percentage>]{1,4} to an Insets

getInstanceback to summary
pack-priv static StyleConverter<?, ?> getInstance(final String converterClass)
getPaintConverterback to summary
public static StyleConverter<ParsedValue<?, Paint>, Paint> getPaintConverter()

Return a StyleConverter that converts a parsed representation of a Paint to a Paint.

Returns:StyleConverter<ParsedValue<?, Paint>, Paint>

A StyleConverter that converts a parsed representation of a Paint to a Paint

getSizeConverterback to summary
public 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. If the property is a Number type other than Double, the set method of (CssMetaData can be overridden 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);
        }
    }
Returns:StyleConverter<?, Number>

A StyleConverter that converts a parsed representation of a CSS length or number value to a Number that is an instance of Double

getStringConverterback to summary
public static StyleConverter<String, String> getStringConverter()

A converter for quoted strings which may have embedded unicode characters.

Returns:StyleConverter<String, String>

A StyleConverter that converts a representation of a CSS string value to a String

getUrlConverterback to summary
public static StyleConverter<ParsedValue<V, T>[], String> getUrlConverter()

A converter for URL strings.

Returns:StyleConverter<ParsedValue<V, T>[], String>

A StyleConverter that converts a representation of a CSS URL value to a String

readBinaryback to summary
public static StyleConverter<?, ?> readBinary(DataInputStream is, String[] strings) throws IOException

Read binary data stream.

Parameters
is:DataInputStream

the data input stream

strings:String[]

the strings

Returns:StyleConverter<?, ?>

the style converter

Exceptions
IOException:
the exception
Since
9
writeBinaryback to summary
public void writeBinary(DataOutputStream os, StyleConverter.StringStore sstore) throws IOException

Write binary data.

Parameters
os:DataOutputStream

the data output stream

sstore:StyleConverter.StringStore

the string store

Exceptions
IOException:
the exception
Since
9
javafx.css back to summary

public Class StyleConverter.StringStore

extends Object
Class Inheritance

The StringStore class.
Since
9

Field Summary

Modifier and TypeField and Description
private final Map<String, Integer>
public final List<String>
strings

List of strings of this StringStore.

Constructor Summary

AccessConstructor and Description
public
StringStore()

Creates a StringStore.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

index at which the given string gets added
addString
(String
string to be added to the StringStore
s
)

Adds given string to the StringStore.

public static String[]

Returns:

a String array constructed by reading DataInputStream
readBinary
(DataInputStream
DataInputStream from where StringStore strings need to be read from
is
)

Read the StringStore strings from a given DataInputStream.

public void
writeBinary(DataOutputStream
DataOutputStream where the StringStore strings need to be written
os
)

Writes the StringStore strings to a given DataOutputStream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

stringMapback to summary
private final Map<String, Integer> stringMap
stringsback to summary
public final List<String> strings

List of strings of this StringStore.

Constructor Detail

StringStoreback to summary
public StringStore()

Creates a StringStore.

Method Detail

addStringback to summary
public int addString(String s)

Adds given string to the StringStore.

Parameters
s:String

string to be added to the StringStore

Returns:int

index at which the given string gets added

readBinaryback to summary
public static String[] readBinary(DataInputStream is) throws IOException

Read the StringStore strings from a given DataInputStream.

Parameters
is:DataInputStream

DataInputStream from where StringStore strings need to be read from

Returns:String[]

a String array constructed by reading DataInputStream

Exceptions
IOException:
if reading from DataInputStream fails
writeBinaryback to summary
public void writeBinary(DataOutputStream os) throws IOException

Writes the StringStore strings to a given DataOutputStream.

Parameters
os:DataOutputStream

DataOutputStream where the StringStore strings need to be written

Exceptions
IOException:
if writing to DataOutputStream fails