Package javafx.css

Class Selector

  • Direct Known Subclasses:
    CompoundSelector, SimpleSelector

    public abstract class Selector
    extends Object
    Used by CSSRule to determine whether or not the Selector applies to a given object.
    Since:
    9
    • Method Detail

      • getRule

        public Rule getRule()
        Gets the Rule of this Selector.
        Returns:
        rule
      • setOrdinal

        public void setOrdinal​(int ordinal)
        Sets the ordinal of this Selector.
        Parameters:
        ordinal - the ordinal of this Selector
      • getOrdinal

        public int getOrdinal()
        Gets the ordinal of this Selector.
        Returns:
        the ordinal of this Selector
      • createMatch

        public abstract Match createMatch()
        Creates a Match.
        Returns:
        match
      • applies

        public abstract boolean applies​(Styleable styleable)
        Gets whether this Selector applies to the given Styleable.
        Parameters:
        styleable - the Styleable to match
        Returns:
        true if this Selector applies to the given Styleable
      • applies

        public abstract boolean applies​(Styleable styleable,
                                        Set<PseudoClass>[] triggerStates,
                                        int depth)
        Gets whether this Selector applies to the given Styleable. It is the same as the applies(javafx.css.Styleable) method except it also returns PseudoClass state that it finds along the way.
        Parameters:
        styleable - the Styleable to match
        triggerStates - a set of PseudoClass states
        depth - depth of the Node heirarchy to look for
        Returns:
        true if this Selector and a set of PseudoClass applies to the given Styleable
      • stateMatches

        public abstract boolean stateMatches​(Styleable styleable,
                                             Set<PseudoClass> state)
        Determines whether the current state of the Node and its parents matches the pseudo-classes defined (if any) for this selector.
        Parameters:
        styleable - the styleable
        state - the state
        Returns:
        true if the current state of the node and its parents matches the pseudo-classes defined (if any) for this selector
      • writeBinary

        protected void writeBinary​(DataOutputStream os,
                                   StyleConverter.StringStore stringStore)
                            throws IOException
        Writes Selector data in binary form to given DataOutputStream.
        Parameters:
        os - DataOutputStream to write Selector data to
        stringStore - unused
        Throws:
        IOException - if writing to DataOutputStream fails
      • createSelector

        public static Selector createSelector​(String cssSelector)
        Creates a Selector object.
        Parameters:
        cssSelector - CSS selector string
        Returns:
        a Selector