modules/graphics/src/main/java/javafx/css/SimpleSelector.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization

*** 21,34 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package com.sun.javafx.css; - import javafx.css.PseudoClass; - import javafx.css.Styleable; import javafx.geometry.NodeOrientation; import javafx.scene.Node; import java.io.DataInputStream; import java.io.DataOutputStream; --- 21,32 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package javafx.css; import javafx.geometry.NodeOrientation; import javafx.scene.Node; import java.io.DataInputStream; import java.io.DataOutputStream;
*** 37,53 **** --- 35,55 ---- import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; + import com.sun.javafx.css.PseudoClassState; + import com.sun.javafx.css.StyleClassSet; + import static javafx.geometry.NodeOrientation.INHERIT; import static javafx.geometry.NodeOrientation.LEFT_TO_RIGHT; import static javafx.geometry.NodeOrientation.RIGHT_TO_LEFT; /** * A simple selector which behaves according to the CSS standard. * + * @since 9 */ final public class SimpleSelector extends Selector { /** * If specified in the CSS file, the name of the java class to which
*** 78,88 **** } return Collections.unmodifiableList(names); } ! Set<StyleClass> getStyleClassSet() { return styleClassSet; } /** styleClasses converted to a set of bit masks */ final private StyleClassSet styleClassSet; --- 80,90 ---- } return Collections.unmodifiableList(names); } ! public Set<StyleClass> getStyleClassSet() { return styleClassSet; } /** styleClasses converted to a set of bit masks */ final private StyleClassSet styleClassSet;
*** 103,113 **** } /** * @return Immutable List&lt;String&gt; of pseudo-classes of the selector */ ! public List<String> getPseudoclasses() { final List<String> names = new ArrayList<String>(); Iterator<PseudoClass> iter = pseudoClassState.iterator(); while (iter.hasNext()) { --- 105,115 ---- } /** * @return Immutable List&lt;String&gt; of pseudo-classes of the selector */ ! List<String> getPseudoclasses() { final List<String> names = new ArrayList<String>(); Iterator<PseudoClass> iter = pseudoClassState.iterator(); while (iter.hasNext()) {
*** 135,150 **** // dir(ltr) or dir(rtl), otherwise inherit final private NodeOrientation nodeOrientation; // Used in Match. If nodeOrientation is ltr or rtl, // then count it as a pseudoclass ! NodeOrientation getNodeOrientation() { return nodeOrientation; } // TODO: The parser passes styleClasses as a List. Should be array? ! public SimpleSelector(final String name, final List<String> styleClasses, final List<String> pseudoClasses, final String id) { this.name = name == null ? "*" : name; // if name is not null and not empty or wildcard, // then match needs to check name --- 137,152 ---- // dir(ltr) or dir(rtl), otherwise inherit final private NodeOrientation nodeOrientation; // Used in Match. If nodeOrientation is ltr or rtl, // then count it as a pseudoclass ! public NodeOrientation getNodeOrientation() { return nodeOrientation; } // TODO: The parser passes styleClasses as a List. Should be array? ! SimpleSelector(final String name, final List<String> styleClasses, final List<String> pseudoClasses, final String id) { this.name = name == null ? "*" : name; // if name is not null and not empty or wildcard, // then match needs to check name
*** 190,207 **** // if id is not null and not empty, then match needs to check id this.matchOnId = (id != null && !("".equals(id))); } ! Match createMatch() { final int idCount = (matchOnId) ? 1 : 0; int styleClassCount = styleClassSet.size(); return new Match(this, pseudoClassState, idCount, styleClassCount); } ! @Override ! public boolean applies(Styleable styleable) { // handle functional pseudo-class :dir() // INHERIT applies to both :dir(rtl) and :dir(ltr) if (nodeOrientation != INHERIT && styleable instanceof Node) { final Node node = (Node)styleable; --- 192,208 ---- // if id is not null and not empty, then match needs to check id this.matchOnId = (id != null && !("".equals(id))); } ! @Override public Match createMatch() { final int idCount = (matchOnId) ? 1 : 0; int styleClassCount = styleClassSet.size(); return new Match(this, pseudoClassState, idCount, styleClassCount); } ! @Override public boolean applies(Styleable styleable) { // handle functional pseudo-class :dir() // INHERIT applies to both :dir(rtl) and :dir(ltr) if (nodeOrientation != INHERIT && styleable instanceof Node) { final Node node = (Node)styleable;
*** 251,262 **** } return true; } ! @Override ! boolean applies(Styleable styleable, Set<PseudoClass>[] pseudoClasses, int depth) { final boolean applies = applies(styleable); // --- 252,262 ---- } return true; } ! @Override public boolean applies(Styleable styleable, Set<PseudoClass>[] pseudoClasses, int depth) { final boolean applies = applies(styleable); //
*** 272,283 **** } return applies; } ! @Override ! public boolean stateMatches(final Styleable styleable, Set<PseudoClass> states) { // [foo bar] matches [foo bar bang], // but [foo bar bang] doesn't match [foo bar] return states != null ? states.containsAll(pseudoClassState) : false; } --- 272,282 ---- } return applies; } ! @Override public boolean stateMatches(final Styleable styleable, Set<PseudoClass> states) { // [foo bar] matches [foo bar bang], // but [foo bar bang] doesn't match [foo bar] return states != null ? states.containsAll(pseudoClassState) : false; }
*** 294,305 **** // match for class="pastoral blue". private boolean matchStyleClasses(StyleClassSet otherStyleClasses) { return otherStyleClasses.containsAll(styleClassSet); } ! @Override ! public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; --- 293,303 ---- // match for class="pastoral blue". private boolean matchStyleClasses(StyleClassSet otherStyleClasses) { return otherStyleClasses.containsAll(styleClassSet); } ! @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false;
*** 355,365 **** } return sbuf.toString(); } ! public final void writeBinary(final DataOutputStream os, final StringStore stringStore) throws IOException { super.writeBinary(os, stringStore); os.writeShort(stringStore.addString(name)); os.writeShort(styleClassSet.size()); --- 353,363 ---- } return sbuf.toString(); } ! @Override protected final void writeBinary(final DataOutputStream os, final StyleConverter.StringStore stringStore) throws IOException { super.writeBinary(os, stringStore); os.writeShort(stringStore.addString(name)); os.writeShort(styleClassSet.size());