Top Description Inners Fields Constructors Methods
javafx.scene

pack-priv final Class CssStyleHelper

extends Object
Class Inheritance
Imports
java.lang.ref.WeakReference, java.util.ArrayList, .Collections, .HashMap, .HashSet, .List, .Locale, .Map, .Map.Entry, .Set, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, javafx.beans.value.WritableValue, com.sun.javafx.css.CascadingStyle, .ImmutablePseudoClassSetsCache, .CalculatedValue, .ParsedValueImpl, .PseudoClassState, .StyleCache, .StyleCacheEntry, .StyleManager, .StyleMap, .TransitionDefinitionCssMetaData, javafx.css.CssMetaData, .CssParser, .FontCssMetaData, .ParsedValue, .PseudoClass, .Rule, .Selector, .Style, .StyleConverter, .StyleOrigin, .Styleable, .StyleableProperty, .Stylesheet, javafx.scene.text.Font, .FontPosture, .FontWeight, javafx.css.converter.FontConverter, com.sun.javafx.util.Logging, .Utils, com.sun.javafx.logging.PlatformLogger, .PlatformLogger.Level

The StyleHelper is a helper class used for applying CSS information to Nodes.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private CssStyleHelper.CacheContainer
private static final CssMetaData<S extends Styleable, V>
private static final WeakReference<Node>
private WeakReference<Node>
private static final PlatformLogger
private static final Set<PseudoClass>
private boolean
private boolean
private final PseudoClassState
triggerStates

A Set of all the pseudo-class states which, if they change, need to cause the Node to be set to UPDATE its CSS styles on the next pulse.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private CalculatedValue
calculateValue(final CascadingStyle style, final Styleable styleable, final CssMetaData<S extends Styleable, V> cssMetaData, final StyleMap styleMap, final Set<PseudoClass> states, final Styleable originatingStyleable, final CalculatedValue fontFromCacheEntry)

private static boolean
canReuseStyleHelper(final Node node, final StyleMap styleMap)

pack-priv static CssStyleHelper
createStyleHelper(final Node node)

Creates a new StyleHelper.

pack-priv Font
deriveFont(Font font, String fontFamily, FontWeight fontWeight, FontPosture fontPosture, double fontSize)

private static Node
private String
formatExceptionMessage(Styleable styleable, CssMetaData<S extends Styleable, V> cssMetaData, Style style, Exception e)

private String
formatUnresolvedLookupMessage(Styleable styleable, CssMetaData<S extends Styleable, V> cssMetaData, Style style, ParsedValue<V, T> resolved, ClassCastException cce)

private CalculatedValue
getCachedFont(final Styleable styleable)

pack-priv String
pack-priv FontPosture
pack-priv FontWeight
private CascadingStyle
getInheritedStyle(final Styleable styleable, final String property)

Called when we must getInheritedStyle a value from a parent node in the scenegraph.

private void
getMatchingLookupStyles(final Styleable node, final ParsedValue<V, T> parsedValue, final List<CascadingStyle> styleList, boolean matchState)

pack-priv static List<Style>
getMatchingStyles(final Styleable styleable, final CssMetaData<S extends Styleable, V> styleableProperty)

Called from Node NodeHelper.getMatchingStyles

pack-priv static Map<StyleableProperty<?>, List<Style>>
private List<Style>
getMatchingStyles(final Styleable node, final CssMetaData<S extends Styleable, V> styleableProperty, boolean matchState)

private void
getMatchingStyles(final Styleable node, final CssMetaData<S extends Styleable, V> styleableProperty, final List<CascadingStyle> styleList, boolean matchState)

private CascadingStyle
getStyle(final Styleable styleable, final String property, final StyleMap styleMap, final Set<PseudoClass>
@return
states
)

Gets the CSS CascadingStyle for the property of this node in these pseudo-class states.

private static CssStyleHelper
private StyleMap
private Set<PseudoClass>[]
getTransitionStates(final Node node)

Dynamic pseudo-class state of the node and its parents.

private String
getUnresolvedLookup(final ParsedValue<V, T> resolved)

private CalculatedValue
handleNoStyleFound(final Styleable styleable, final CssMetaData<S extends Styleable, V> cssMetaData, final StyleMap styleMap, Set<PseudoClass> pseudoClassStates, Styleable originatingStyleable, final CalculatedValue cachedFont)

Called when there is no style found.

private static boolean
isTrue(WritableValue<Boolean> booleanProperty)

private boolean
private CalculatedValue
lookup(final Styleable styleable, final CssMetaData<S extends Styleable, V> cssMetaData, final StyleMap styleMap, final Set<PseudoClass> states, final Styleable originatingStyleable, final CalculatedValue cachedFont)

The main workhorse of this class, the lookup method walks up the CSS style tree looking for the style information for the Node, the property associated with the given styleable, in these states for this font.

pack-priv CalculatedValue
lookupFont(final Styleable styleable, final String property, final StyleMap styleMap, final CalculatedValue cachedFont)

Look up a font property.

private CascadingStyle
lookupInheritedFontProperty(final Styleable styleable, final String property, final StyleMap styleMap, final int distance, CascadingStyle fontShorthand)

pack-priv boolean
pack-priv void
recalculateRelativeSizeProperties(final Node node, Font fontForRelativeSizes)

private void
private ParsedValue<V, T>
resolveLookups(final Styleable styleable, final ParsedValue<V, T> parsedValue, final StyleMap styleMap, Set<PseudoClass> states, Set<ParsedValue<V, T>> resolves)

private CascadingStyle
resolveRef(final Styleable styleable, final String property, final StyleMap styleMap, final Set<PseudoClass> states)

Find the property among the styles that pertain to the Node

private static void
setTrue(WritableValue<Boolean> booleanProperty)

pack-priv void
transitionToState(final Node node)

Called by the Node whenever it has transitioned from one set of pseudo-class states to another.

private static void
updateParentTriggerStates(Styleable styleable, int depth, PseudoClassState[] triggerStates)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheContainerback to summary
private CssStyleHelper.CacheContainer cacheContainer
dummyFontPropertyback to summary
private static final CssMetaData<S extends Styleable, V> dummyFontProperty
EMPTY_NODEback to summary
private static final WeakReference<Node> EMPTY_NODE
firstStyleableAncestorback to summary
private WeakReference<Node> firstStyleableAncestor
LOGGERback to summary
private static final PlatformLogger LOGGER
NULL_PSEUDO_CLASS_STATEback to summary
private static final Set<PseudoClass> NULL_PSEUDO_CLASS_STATE
resetInProgressback to summary
private boolean resetInProgress
transitionStateInProgressback to summary
private boolean transitionStateInProgress
triggerStatesback to summary
private final PseudoClassState triggerStates

A Set of all the pseudo-class states which, if they change, need to cause the Node to be set to UPDATE its CSS styles on the next pulse. For example, your stylesheet might have:


.button { ... }
.button:hover { ... }
.button *.label { text-fill: black }
.button:hover *.label { text-fill: blue }
In this case, the first 2 rules apply to the Button itself, but the second two rules apply to the label within a Button. When the hover changes on the Button, however, we must mark the Button as needing an UPDATE. StyleHelper though only contains styles for the first two rules for Button. The pseudoclassStateMask would in this case have only a single bit set for "hover". In this way the StyleHelper associated with the Button would know whether a change to "hover" requires the button and all children to be update. Other pseudo-class state changes that are not in this hash set are ignored. * Called "triggerStates" since they would trigger a CSS update.

Constructor Detail

CssStyleHelperback to summary
private CssStyleHelper()

Method Detail

calculateValueback to summary
private CalculatedValue calculateValue(final CascadingStyle style, final Styleable styleable, final CssMetaData<S extends Styleable, V> cssMetaData, final StyleMap styleMap, final Set<PseudoClass> states, final Styleable originatingStyleable, final CalculatedValue fontFromCacheEntry)
canReuseStyleHelperback to summary
private static boolean canReuseStyleHelper(final Node node, final StyleMap styleMap)
createStyleHelperback to summary
pack-priv static CssStyleHelper createStyleHelper(final Node node)

Creates a new StyleHelper.

deriveFontback to summary
pack-priv Font deriveFont(Font font, String fontFamily, FontWeight fontWeight, FontPosture fontPosture, double fontSize)
findFirstStyleableAncestorback to summary
private static Node findFirstStyleableAncestor(Styleable st)
formatExceptionMessageback to summary
private String formatExceptionMessage(Styleable styleable, CssMetaData<S extends Styleable, V> cssMetaData, Style style, Exception e)
formatUnresolvedLookupMessageback to summary
private String formatUnresolvedLookupMessage(Styleable styleable, CssMetaData<S extends Styleable, V> cssMetaData, Style style, ParsedValue<V, T> resolved, ClassCastException cce)
getCachedFontback to summary
private CalculatedValue getCachedFont(final Styleable styleable)
getFontFamilyback to summary
pack-priv String getFontFamily(Font font)
getFontPostureback to summary
pack-priv FontPosture getFontPosture(Font font)
getFontWeightback to summary
pack-priv FontWeight getFontWeight(Font font)
getInheritedStyleback to summary
private CascadingStyle getInheritedStyle(final Styleable styleable, final String property)

Called when we must getInheritedStyle a value from a parent node in the scenegraph.

getMatchingLookupStylesback to summary
private void getMatchingLookupStyles(final Styleable node, final ParsedValue<V, T> parsedValue, final List<CascadingStyle> styleList, boolean matchState)
getMatchingStylesback to summary
pack-priv static List<Style> getMatchingStyles(final Styleable styleable, final CssMetaData<S extends Styleable, V> styleableProperty)

Called from Node NodeHelper.getMatchingStyles

getMatchingStylesback to summary
pack-priv static Map<StyleableProperty<?>, List<Style>> getMatchingStyles(Map<StyleableProperty<?>, List<Style>> map, final Node node)
getMatchingStylesback to summary
private List<Style> getMatchingStyles(final Styleable node, final CssMetaData<S extends Styleable, V> styleableProperty, boolean matchState)
getMatchingStylesback to summary
private void getMatchingStyles(final Styleable node, final CssMetaData<S extends Styleable, V> styleableProperty, final List<CascadingStyle> styleList, boolean matchState)
getStyleback to summary
private CascadingStyle getStyle(final Styleable styleable, final String property, final StyleMap styleMap, final Set<PseudoClass> states)

Gets the CSS CascadingStyle for the property of this node in these pseudo-class states. A null style may be returned if there is no style information for this combination of input parameters.

Parameters
states:Set<PseudoClass>

@return

getStyleHelperback to summary
private static CssStyleHelper getStyleHelper(Node n)
getStyleMapback to summary
private StyleMap getStyleMap(Styleable styleable)
getTransitionStatesback to summary
private Set<PseudoClass>[] getTransitionStates(final Node node)

Dynamic pseudo-class state of the node and its parents. Only valid during a pulse. The StyleCacheEntry to choose depends on the Node's pseudo-class state and the pseudo-class state of its parents. Without the parent pseudo-class state, the fact that the the node in this pseudo-class state matched foo:blah bar { } is lost.

getUnresolvedLookupback to summary
private String getUnresolvedLookup(final ParsedValue<V, T> resolved)
handleNoStyleFoundback to summary
private CalculatedValue handleNoStyleFound(final Styleable styleable, final CssMetaData<S extends Styleable, V> cssMetaData, final StyleMap styleMap, Set<PseudoClass> pseudoClassStates, Styleable originatingStyleable, final CalculatedValue cachedFont)

Called when there is no style found.

isTrueback to summary
private static boolean isTrue(WritableValue<Boolean> booleanProperty)
isUserSetFontback to summary
private boolean isUserSetFont(Styleable node)
lookupback to summary
private CalculatedValue lookup(final Styleable styleable, final CssMetaData<S extends Styleable, V> cssMetaData, final StyleMap styleMap, final Set<PseudoClass> states, final Styleable originatingStyleable, final CalculatedValue cachedFont)

The main workhorse of this class, the lookup method walks up the CSS style tree looking for the style information for the Node, the property associated with the given styleable, in these states for this font.

lookupFontback to summary
pack-priv CalculatedValue lookupFont(final Styleable styleable, final String property, final StyleMap styleMap, final CalculatedValue cachedFont)

Look up a font property. This is handled separately from lookup since font is inherited and has sub-properties. One should expect that the text font for the following would be 16px Arial. The lookup method would give 16px system since it would look only for font-size, font-family, etc only if the lookup on font failed.

Text text = new Text("Hello World");
text.setStyle("-fx-font-size: 16px;");
Group group = new Group();
group.setStyle("-fx-font: 12px Arial;");
group.getChildren().add(text);
lookupInheritedFontPropertyback to summary
private CascadingStyle lookupInheritedFontProperty(final Styleable styleable, final String property, final StyleMap styleMap, final int distance, CascadingStyle fontShorthand)
pseudoClassStateChangedback to summary
pack-priv boolean pseudoClassStateChanged(PseudoClass pseudoClass)
recalculateRelativeSizePropertiesback to summary
pack-priv void recalculateRelativeSizeProperties(final Node node, Font fontForRelativeSizes)
resetToInitialValuesback to summary
private void resetToInitialValues(final Styleable styleable)
resolveLookupsback to summary
private ParsedValue<V, T> resolveLookups(final Styleable styleable, final ParsedValue<V, T> parsedValue, final StyleMap styleMap, Set<PseudoClass> states, Set<ParsedValue<V, T>> resolves)
resolveRefback to summary
private CascadingStyle resolveRef(final Styleable styleable, final String property, final StyleMap styleMap, final Set<PseudoClass> states)

Find the property among the styles that pertain to the Node

setTrueback to summary
private static void setTrue(WritableValue<Boolean> booleanProperty)
transitionToStateback to summary
pack-priv void transitionToState(final Node node)

Called by the Node whenever it has transitioned from one set of pseudo-class states to another. This function will then lookup the new values for each of the styleable variables on the Node, and then set the new value via StyleableProperty#applyStyle.

updateParentTriggerStatesback to summary
private static void updateParentTriggerStates(Styleable styleable, int depth, PseudoClassState[] triggerStates)
javafx.scene back to summary

private final Class CssStyleHelper.CacheContainer

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Map<CssMetaData<S extends Styleable, V>, CalculatedValue>
private final CssMetaData<Styleable, Font>
private final Map<StyleCacheEntry.Key, CalculatedValue>
private boolean
private final int
private final StyleCache.Key

Constructor Summary

AccessConstructor and Description
private
CacheContainer(Node node, final StyleMap styleMap, int depth)

Method Summary

Modifier and TypeMethod and Description
private StyleMap
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cssSetPropertiesback to summary
private final Map<CssMetaData<S extends Styleable, V>, CalculatedValue> cssSetProperties
fontPropback to summary
private final CssMetaData<Styleable, Font> fontProp
fontSizeCacheback to summary
private final Map<StyleCacheEntry.Key, CalculatedValue> fontSizeCache
forceSlowpathback to summary
private boolean forceSlowpath
smapIdback to summary
private final int smapId
styleCacheKeyback to summary
private final StyleCache.Key styleCacheKey

Constructor Detail

CacheContainerback to summary
private CacheContainer(Node node, final StyleMap styleMap, int depth)

Method Detail

getStyleMapback to summary
private StyleMap getStyleMap(Styleable styleable)