modules/graphics/src/main/java/javafx/css/CascadingStyle.java
Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization
@@ -21,19 +21,18 @@
* 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.StyleOrigin;
+package javafx.css;
import java.util.Set;
-
-/** A marriage of pseudo-classes (potentially empty) to property and value */
+/** A marriage of pseudo-classes (potentially empty) to property and value
+ *
+ * @since 9
+ */
public class CascadingStyle implements Comparable<CascadingStyle> {
/** */
private final Style style;
public Style getStyle() {
@@ -62,10 +61,17 @@
this.specificity = specificity;
this.ordinal = ordinal;
this.skinProp = "-fx-skin".equals(style.getDeclaration().getProperty());
}
+ public CascadingStyle(final Declaration decl, final Match match, final int ordinal) {
+ this(new Style(match.getSelector(), decl),
+ match.getPseudoClasses(),
+ match.getSpecificity(),
+ ordinal);
+ }
+
// Wrapper to make StyleHelper's life a little easier
public String getProperty() {
return style.getDeclaration().getProperty();
}
@@ -83,12 +89,12 @@
public StyleOrigin getOrigin() {
return getRule().getOrigin();
}
// Wrapper to make StyleHelper's life a little easier
- public ParsedValueImpl getParsedValueImpl() {
- return style.getDeclaration().getParsedValueImpl();
+ public ParsedValue getParsedValue() {
+ return style.getDeclaration().getParsedValue();
}
@Override public String toString() { return getProperty(); }
/**
@@ -122,12 +128,11 @@
/*
* Hash on property and pseudoclasses since
* obj1.hashCode() should equal obj2.hashCode() if obj1.equals(obj2)
*/
- @Override
- public int hashCode() {
+ @Override public int hashCode() {
int hash = 7;
final String property = getProperty();
hash = 47 * hash + (property != null ? property.hashCode() : 0);
hash = 47 * hash + (pseudoClasses != null ? pseudoClasses.hashCode() : 0);
return hash;
@@ -135,12 +140,11 @@
/**
* Implementation of Comparable such that more specific styles get
* sorted before less specific ones.
*/
- @Override
- public int compareTo(CascadingStyle other) {
+ @Override public int compareTo(CascadingStyle other) {
//
// Important styles take the cake
// Importance being equal, then specificity is considered
// Specificity being equal, then the order of declaration decides.