Class CssPropertyFactory<S extends javafx.css.Styleable>

  • Type Parameters:
    S - the type of Styleable

    public class CssPropertyFactory<S extends javafx.css.Styleable>
    extends java.lang.Object
    Extension of the StylablePropertyFactory. Adds types like [Stylish]DoubleProperties and provides callbacks for changes and filters for updates (e.g. clamping the value of a property to a given range). Also adds an enum property which sets the currently selected enum as a pseudo class.
    Author:
    Alexander Krimm, rstein
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> metaData  
      protected java.util.Map<java.lang.String,​javafx.css.CssMetaData<S,​?>> metaDataSet  
      protected java.util.Map<javafx.css.Styleable,​java.util.List<java.lang.String>> propertyNames  
      protected java.util.Map<java.lang.String,​javafx.css.PseudoClass> pseudoClasses  
      protected java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> unmodifiableList  
    • Constructor Summary

      Constructors 
      Constructor Description
      CssPropertyFactory()
      Create a property factory without any properties from the parent class.
      CssPropertyFactory​(java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> parentCss)
      Create a property factory which also provides the styleableBean properties of the parent class.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javafx.css.StyleableBooleanProperty createBooleanProperty​(S styleableBean, java.lang.String propertyName, boolean initialValue, boolean inherits, java.util.function.BinaryOperator<java.lang.Boolean> filter, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      javafx.css.StyleableBooleanProperty createBooleanProperty​(S styleableBean, java.lang.String propertyName, boolean initialValue, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      javafx.css.StyleableDoubleProperty createDoubleProperty​(S styleableBean, java.lang.String propertyName, double initialValue, boolean inherits, java.util.function.DoubleBinaryOperator filter, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Double> with initial value and inherit flag.
      javafx.css.StyleableDoubleProperty createDoubleProperty​(S styleableBean, java.lang.String propertyName, double initialValue, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Double> with initial value and inherit flag.
      <T extends java.lang.Enum<T>>
      javafx.css.StyleableObjectProperty<T>
      createEnumPropertyWithPseudoclasses​(javafx.css.Styleable styleableBean, java.lang.String propertyName, T initialValue, boolean inherits, java.lang.Class<T> enumClass, java.util.function.BinaryOperator<T> filter, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      <T extends java.lang.Enum<T>>
      javafx.css.StyleableObjectProperty<T>
      createEnumPropertyWithPseudoclasses​(javafx.css.Styleable styleableBean, java.lang.String propertyName, T initialValue, java.lang.Class<T> enumClass, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      javafx.css.StyleableFloatProperty createFloatProperty​(S styleableBean, java.lang.String propertyName, float initialValue, boolean inherits, java.util.function.BinaryOperator<java.lang.Float> filter, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Float> with initial value and inherit flag.
      javafx.css.StyleableFloatProperty createFloatProperty​(S styleableBean, java.lang.String propertyName, float initialValue, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Float> with initial value and inherit flag.
      javafx.css.StyleableIntegerProperty createIntegerProperty​(S styleableBean, java.lang.String propertyName, int initialValue, boolean inherits, java.util.function.IntBinaryOperator filter, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      javafx.css.StyleableIntegerProperty createIntegerProperty​(S styleableBean, java.lang.String propertyName, int initialValue, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      javafx.css.StyleableLongProperty createLongProperty​(S styleableBean, java.lang.String propertyName, long initialValue, boolean inherits, java.util.function.LongBinaryOperator filter, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Long> with initial value and inherit flag.
      javafx.css.StyleableLongProperty createLongProperty​(S styleableBean, java.lang.String propertyName, long initialValue, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Long> with initial value and inherit flag.
      <T> javafx.css.StyleableObjectProperty<T> createObjectProperty​(S styleableBean, java.lang.String propertyName, T initialValue, boolean inherits, javafx.css.StyleConverter<?,​T> converter, java.util.function.BinaryOperator<T> filter, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      <T> javafx.css.StyleableObjectProperty<T> createObjectProperty​(S styleableBean, java.lang.String propertyName, T initialValue, javafx.css.StyleConverter<?,​T> converter, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      javafx.css.StyleableStringProperty createStringProperty​(S styleableBean, java.lang.String propertyName, java.lang.String initialValue, boolean inherits, java.util.function.BinaryOperator<java.lang.String> filter, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      javafx.css.StyleableStringProperty createStringProperty​(S styleableBean, java.lang.String propertyName, java.lang.String initialValue, java.lang.Runnable... invalidateActions)
      Create a StyleableProperty<Boolean> with initial value and inherit flag.
      static java.util.List<java.lang.reflect.Field> getAllFields​(java.util.List<java.lang.reflect.Field> fields, java.lang.Class<?> clazz)  
      java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getCssMetaData()  
      java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getCssMetaDataModifyable()  
      protected java.lang.String getCssPropertyName​(java.lang.String propertyName)  
      static java.lang.reflect.Field getField​(java.lang.Class<?> clazz, java.lang.String fieldName)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • metaData

        protected final java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> metaData
      • unmodifiableList

        protected final java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> unmodifiableList
      • metaDataSet

        protected final java.util.Map<java.lang.String,​javafx.css.CssMetaData<S extends javafx.css.Styleable,​?>> metaDataSet
      • pseudoClasses

        protected final java.util.Map<java.lang.String,​javafx.css.PseudoClass> pseudoClasses
      • propertyNames

        protected final java.util.Map<javafx.css.Styleable,​java.util.List<java.lang.String>> propertyNames
    • Constructor Detail

      • CssPropertyFactory

        public CssPropertyFactory()
        Create a property factory without any properties from the parent class. Only use this, if the parent class does not provide any styleableBean properties.
      • CssPropertyFactory

        public CssPropertyFactory​(java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> parentCss)
        Create a property factory which also provides the styleableBean properties of the parent class. private static final CssPropertyFactory<MyStyleable> CSS = new CssPropertyFactory<>(Parent.getClassCssMetaData()
        Parameters:
        parentCss - List containing all styleableBean properties of the parent class
    • Method Detail

      • getAllFields

        public static java.util.List<java.lang.reflect.Field> getAllFields​(java.util.List<java.lang.reflect.Field> fields,
                                                                           java.lang.Class<?> clazz)
      • getField

        public static java.lang.reflect.Field getField​(java.lang.Class<?> clazz,
                                                       java.lang.String fieldName)
      • getCssMetaData

        public final java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getCssMetaData()
        Returns:
        all styleableBean properties added via the factory and the ones for the parents.
      • getCssMetaDataModifyable

        public final java.util.List<javafx.css.CssMetaData<? extends javafx.css.Styleable,​?>> getCssMetaDataModifyable()
        Returns:
        all styleableBean properties added via the factory and the ones for the parents (modifiable).
      • createDoubleProperty

        public final javafx.css.StyleableDoubleProperty createDoubleProperty​(S styleableBean,
                                                                             java.lang.String propertyName,
                                                                             double initialValue,
                                                                             boolean inherits,
                                                                             java.util.function.DoubleBinaryOperator filter,
                                                                             java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Double> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        inherits - whether or not the CSS style can be inherited by child nodes
        filter - a filter to react on changes and limit them: (oldVal, newVal) -&gt; filteredVal
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a #StyleableDoubleProperty created with initial value and inherit flag
      • createDoubleProperty

        public final javafx.css.StyleableDoubleProperty createDoubleProperty​(S styleableBean,
                                                                             java.lang.String propertyName,
                                                                             double initialValue,
                                                                             java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Double> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a #StyleableDoubleProperty created with initial value and inherit flag
      • createIntegerProperty

        public final javafx.css.StyleableIntegerProperty createIntegerProperty​(S styleableBean,
                                                                               java.lang.String propertyName,
                                                                               int initialValue,
                                                                               boolean inherits,
                                                                               java.util.function.IntBinaryOperator filter,
                                                                               java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        inherits - whether or not the CSS style can be inherited by child nodes
        filter - a filter to react on changes and limit them: (oldVal, newVal) -&gt; filteredVal
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a #StyleableIntegerProperty created with initial value and inherit flag
      • createIntegerProperty

        public final javafx.css.StyleableIntegerProperty createIntegerProperty​(S styleableBean,
                                                                               java.lang.String propertyName,
                                                                               int initialValue,
                                                                               java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a #StyleableIntegerProperty created with initial value and inherit flag
      • createLongProperty

        public final javafx.css.StyleableLongProperty createLongProperty​(S styleableBean,
                                                                         java.lang.String propertyName,
                                                                         long initialValue,
                                                                         boolean inherits,
                                                                         java.util.function.LongBinaryOperator filter,
                                                                         java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Long> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        inherits - whether or not the CSS style can be inherited by child nodes
        filter - a filter to react on changes and limit them: (oldVal, newVal) -&gt; filteredVal
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a #StyleableLongProperty created with initial value and inherit flag
      • createLongProperty

        public final javafx.css.StyleableLongProperty createLongProperty​(S styleableBean,
                                                                         java.lang.String propertyName,
                                                                         long initialValue,
                                                                         java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Long> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a #StyleableLongProperty created with initial value and inherit flag
      • createFloatProperty

        public final javafx.css.StyleableFloatProperty createFloatProperty​(S styleableBean,
                                                                           java.lang.String propertyName,
                                                                           float initialValue,
                                                                           boolean inherits,
                                                                           java.util.function.BinaryOperator<java.lang.Float> filter,
                                                                           java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Float> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        inherits - whether or not the CSS style can be inherited by child nodes
        filter - a filter to react on changes and limit them: (oldVal, newVal) -&gt; filteredVal
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a #StyleableFloatProperty created with initial value and inherit flag
      • createFloatProperty

        public final javafx.css.StyleableFloatProperty createFloatProperty​(S styleableBean,
                                                                           java.lang.String propertyName,
                                                                           float initialValue,
                                                                           java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Float> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a #StyleableFloatProperty created with initial value and inherit flag
      • createBooleanProperty

        public final javafx.css.StyleableBooleanProperty createBooleanProperty​(S styleableBean,
                                                                               java.lang.String propertyName,
                                                                               boolean initialValue,
                                                                               boolean inherits,
                                                                               java.util.function.BinaryOperator<java.lang.Boolean> filter,
                                                                               java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        inherits - whether or not the CSS style can be inherited by child nodes
        filter - a filter to react on changes and limit them: (oldVal, newVal) -&gt; filteredVal
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a StyleableProperty created with initial value and inherit flag
      • createBooleanProperty

        public final javafx.css.StyleableBooleanProperty createBooleanProperty​(S styleableBean,
                                                                               java.lang.String propertyName,
                                                                               boolean initialValue,
                                                                               java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a StyleableProperty created with initial value and inherit flag
      • createObjectProperty

        public final <T> javafx.css.StyleableObjectProperty<T> createObjectProperty​(S styleableBean,
                                                                                    java.lang.String propertyName,
                                                                                    T initialValue,
                                                                                    boolean inherits,
                                                                                    javafx.css.StyleConverter<?,​T> converter,
                                                                                    java.util.function.BinaryOperator<T> filter,
                                                                                    java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag.
        Type Parameters:
        T - Type of the Property
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        inherits - whether or not the CSS style can be inherited by child nodes
        converter - the style converter to convert the style to the object
        filter - a filter to react on changes and limit them: (oldVal, newVal) -&gt; filteredVal
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a StyleableProperty created with initial value and inherit flag
      • createObjectProperty

        public final <T> javafx.css.StyleableObjectProperty<T> createObjectProperty​(S styleableBean,
                                                                                    java.lang.String propertyName,
                                                                                    T initialValue,
                                                                                    javafx.css.StyleConverter<?,​T> converter,
                                                                                    java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag.
        Type Parameters:
        T - Type of the Property
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        converter - the style converter to convert the style to the object
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a StyleableProperty created with initial value and inherit flag
      • createStringProperty

        public final javafx.css.StyleableStringProperty createStringProperty​(S styleableBean,
                                                                             java.lang.String propertyName,
                                                                             java.lang.String initialValue,
                                                                             boolean inherits,
                                                                             java.util.function.BinaryOperator<java.lang.String> filter,
                                                                             java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        inherits - whether or not the CSS style can be inherited by child nodes
        filter - a filter to react on changes and limit them: (oldVal, newVal) -&gt; filteredVal
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a StyleableProperty created with initial value and inherit flag
      • createStringProperty

        public final javafx.css.StyleableStringProperty createStringProperty​(S styleableBean,
                                                                             java.lang.String propertyName,
                                                                             java.lang.String initialValue,
                                                                             java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag.
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a StyleableProperty created with initial value and inherit flag
      • createEnumPropertyWithPseudoclasses

        public <T extends java.lang.Enum<T>> javafx.css.StyleableObjectProperty<T> createEnumPropertyWithPseudoclasses​(javafx.css.Styleable styleableBean,
                                                                                                                       java.lang.String propertyName,
                                                                                                                       T initialValue,
                                                                                                                       boolean inherits,
                                                                                                                       java.lang.Class<T> enumClass,
                                                                                                                       java.util.function.BinaryOperator<T> filter,
                                                                                                                       java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag. This also creates pseudoclasses for each enum value and keeps them up to date with the property.
        Type Parameters:
        T - Type of the Property
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        inherits - whether or not the CSS style can be inherited by child nodes
        enumClass - the type of enum to read
        filter - a filter to react on changes and limit them: (oldVal, newVal) -&gt; filteredVal
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a StyleableProperty created with initial value and inherit flag
      • createEnumPropertyWithPseudoclasses

        public <T extends java.lang.Enum<T>> javafx.css.StyleableObjectProperty<T> createEnumPropertyWithPseudoclasses​(javafx.css.Styleable styleableBean,
                                                                                                                       java.lang.String propertyName,
                                                                                                                       T initialValue,
                                                                                                                       java.lang.Class<T> enumClass,
                                                                                                                       java.lang.Runnable... invalidateActions)
        Create a StyleableProperty<Boolean> with initial value and inherit flag. This also creates pseudoclasses for each enum value and keeps them up to date with the property.
        Type Parameters:
        T - Type of the Property
        Parameters:
        styleableBean - the this reference of the returned property. This is also the property bean.
        propertyName - the field name of the StyleableProperty<Boolean>
        initialValue - the initial value of the property. CSS may reset the property to this value.
        enumClass - the type of enum to read
        invalidateActions - zero, one or two Runnables (vararg) first one will be executed before and second one after invalidation
        Returns:
        a StyleableProperty created with initial value and inherit flag
      • getCssPropertyName

        protected java.lang.String getCssPropertyName​(java.lang.String propertyName)