Package javafx.css

Class StyleConverter<F,T>

    • Constructor Detail

      • StyleConverter

        public StyleConverter​()
    • Method Detail

      • convert

        public T convert​(ParsedValue<F,T> value,
                         Font font)
        Convert from the parsed CSS value to the target property type.
        Parameters:
        value - The ParsedValue to convert
        font - The Font to use when converting a relative value.
        Returns:
        the converted target property type
      • getDurationConverter

        public static StyleConverter<?,Duration> getDurationConverter​()
        Return a StyleConverter that converts a String representation of a duration to a Duration.
        Returns:
        A StyleConverter that converts a String representation of a duration to a Duration
        Since:
        JavaFX 8u40
      • getColorConverter

        public static StyleConverter<String,Color> getColorConverter​()
        Return a StyleConverter that converts a String representation of a web color to a Color.
        Returns:
        A StyleConverter that converts a String representation of a web color to a Color
        See Also:
        Color.web(java.lang.String)
      • getEffectConverter

        public static StyleConverter<ParsedValue[],Effect> getEffectConverter​()
        Return a StyleConverter that converts a parsed representation of an Effect to an Effect
        Returns:
        A StyleConverter that converts a parsed representation of an Effect to an Effect
        See Also:
        Effect
      • getEnumConverter

        public static <E extends Enum<E>> StyleConverter<String,? extends Enum<?>> getEnumConverter​(Class<E> enumClass)
        Return a StyleConverter that converts a String representation of an Enum to an Enum.
        Type Parameters:
        E - the type of the Enum
        Parameters:
        enumClass - the enum Class
        Returns:
        A StyleConverter that converts a String representation of an Enum to an Enum
        See Also:
        Enum.valueOf(java.lang.Class, java.lang.String)
      • getInsetsConverter

        public static StyleConverter<ParsedValue[],Insets> getInsetsConverter​()
        Return a StyleConverter that converts a [<length> | <percentage>]{1,4} to an Insets.
        Returns:
        A StyleConverter that converts a [<length> | <percentage>]{1,4} to an Insets
      • getPaintConverter

        public static StyleConverter<ParsedValue<?,Paint>,Paint> getPaintConverter​()
        Return a StyleConverter that converts a parsed representation of a Paint to a Paint.
        Returns:
        A StyleConverter that converts a parsed representation of a Paint to a Paint
      • getSizeConverter

        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:
        A StyleConverter that converts a parsed representation of a CSS length or number value to a Number that is an instance of Double
      • getStringConverter

        public static StyleConverter<String,String> getStringConverter​()
        A converter for quoted strings which may have embedded unicode characters.
        Returns:
        A StyleConverter that converts a representation of a CSS string value to a String
      • getUrlConverter

        public static StyleConverter<ParsedValue[],String> getUrlConverter​()
        A converter for URL strings.
        Returns:
        A StyleConverter that converts a representation of a CSS URL value to a String
      • convert

        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 - the constituent values
        Returns:
        the target property type
        Since:
        9
      • clearCache

        public static void clearCache​()
        Clear the cache.
        Since:
        9
      • getCachedValue

        protected T getCachedValue​(ParsedValue key)
        Get the cached value for the specified key.
        Parameters:
        key - the key
        Returns:
        the cached value
        Since:
        9
      • cacheValue

        protected void cacheValue​(ParsedValue key,
                                  Object value)
        Cache the value for the specified key.
        Parameters:
        key - the key
        value - the value
        Since:
        9