< prev index next >

modules/graphics/src/main/java/javafx/scene/CssStyleHelper.java

Print this page




 557      * Called by the Node whenever it has transitioned from one set of
 558      * pseudo-class states to another. This function will then lookup the
 559      * new values for each of the styleable variables on the Node, and
 560      * then either set the value directly or start an animation based on
 561      * how things are specified in the CSS file. Currently animation support
 562      * is disabled until the new parser comes online with support for
 563      * animations and that support is detectable via the API.
 564      */
 565     void transitionToState(final Node node) {
 566 
 567         if (cacheContainer == null) {
 568             return;
 569         }
 570 
 571         //
 572         // If styleMap is null, then StyleManager has blown it away and we need to reapply CSS.
 573         //
 574         final StyleMap styleMap = getStyleMap(node);
 575         if (styleMap == null) {
 576             cacheContainer = null;
 577             node.impl_reapplyCSS();
 578             return;
 579         }
 580 
 581         // if the style-map is empty, then we are only looking for inherited styles.
 582         final boolean inheritOnly = styleMap.isEmpty();
 583 
 584         //
 585         // Styles that need lookup can be cached provided none of the styles
 586         // are from Node.style.
 587         //
 588         final StyleCache sharedCache = StyleManager.getInstance().getSharedCache(node, node.getSubScene(), cacheContainer.styleCacheKey);
 589 
 590         if (sharedCache == null) {
 591             // Shared cache was blown away by StyleManager.
 592             // Therefore, this CssStyleHelper is no good.
 593             cacheContainer = null;
 594             node.impl_reapplyCSS();
 595             return;
 596 
 597         }
 598 
 599         final Set<PseudoClass>[] transitionStates = getTransitionStates(node);
 600 
 601         final StyleCacheEntry.Key fontCacheKey = new StyleCacheEntry.Key(transitionStates, Font.getDefault());
 602         CalculatedValue cachedFont = cacheContainer.fontSizeCache.get(fontCacheKey);
 603 
 604         if (cachedFont == null) {
 605 
 606             cachedFont = lookupFont(node, "-fx-font", styleMap, cachedFont);
 607 
 608             if (cachedFont == SKIP) cachedFont = getCachedFont(node.getStyleableParent());
 609             if (cachedFont == null) cachedFont = new CalculatedValue(Font.getDefault(), null, false);
 610 
 611             cacheContainer.fontSizeCache.put(fontCacheKey,cachedFont);
 612 
 613         }
 614 


1980                     }
1981 
1982                     final ParsedValue cssValue = cascadingStyle.getParsedValue();
1983 
1984                     if ("inherit".equals(cssValue.getValue()) == false) {
1985                         return cascadingStyle;
1986                     }
1987                 }
1988 
1989             }
1990 
1991             parent = parent.getStyleableParent();
1992 
1993         }
1994 
1995         return null;
1996     }
1997 
1998 
1999     /**
2000      * Called from Node impl_getMatchingStyles
2001      * @param styleable
2002      * @param styleableProperty
2003      * @return
2004      */
2005     static List<Style> getMatchingStyles(final Styleable styleable, final CssMetaData styleableProperty) {
2006 
2007         if (!(styleable instanceof Node)) return Collections.<Style>emptyList();
2008 
2009         Node node = (Node)styleable;
2010         final CssStyleHelper helper = (node.styleHelper != null) ? node.styleHelper : createStyleHelper(node);
2011 
2012         if (helper != null) {
2013             return helper.getMatchingStyles(node, styleableProperty, false);
2014         }
2015         else {
2016             return Collections.<Style>emptyList();
2017         }
2018     }
2019 
2020     static Map<StyleableProperty<?>, List<Style>> getMatchingStyles(Map<StyleableProperty<?>, List<Style>> map, final Node node) {




 557      * Called by the Node whenever it has transitioned from one set of
 558      * pseudo-class states to another. This function will then lookup the
 559      * new values for each of the styleable variables on the Node, and
 560      * then either set the value directly or start an animation based on
 561      * how things are specified in the CSS file. Currently animation support
 562      * is disabled until the new parser comes online with support for
 563      * animations and that support is detectable via the API.
 564      */
 565     void transitionToState(final Node node) {
 566 
 567         if (cacheContainer == null) {
 568             return;
 569         }
 570 
 571         //
 572         // If styleMap is null, then StyleManager has blown it away and we need to reapply CSS.
 573         //
 574         final StyleMap styleMap = getStyleMap(node);
 575         if (styleMap == null) {
 576             cacheContainer = null;
 577             node.reapplyCSS();
 578             return;
 579         }
 580 
 581         // if the style-map is empty, then we are only looking for inherited styles.
 582         final boolean inheritOnly = styleMap.isEmpty();
 583 
 584         //
 585         // Styles that need lookup can be cached provided none of the styles
 586         // are from Node.style.
 587         //
 588         final StyleCache sharedCache = StyleManager.getInstance().getSharedCache(node, node.getSubScene(), cacheContainer.styleCacheKey);
 589 
 590         if (sharedCache == null) {
 591             // Shared cache was blown away by StyleManager.
 592             // Therefore, this CssStyleHelper is no good.
 593             cacheContainer = null;
 594             node.reapplyCSS();
 595             return;
 596 
 597         }
 598 
 599         final Set<PseudoClass>[] transitionStates = getTransitionStates(node);
 600 
 601         final StyleCacheEntry.Key fontCacheKey = new StyleCacheEntry.Key(transitionStates, Font.getDefault());
 602         CalculatedValue cachedFont = cacheContainer.fontSizeCache.get(fontCacheKey);
 603 
 604         if (cachedFont == null) {
 605 
 606             cachedFont = lookupFont(node, "-fx-font", styleMap, cachedFont);
 607 
 608             if (cachedFont == SKIP) cachedFont = getCachedFont(node.getStyleableParent());
 609             if (cachedFont == null) cachedFont = new CalculatedValue(Font.getDefault(), null, false);
 610 
 611             cacheContainer.fontSizeCache.put(fontCacheKey,cachedFont);
 612 
 613         }
 614 


1980                     }
1981 
1982                     final ParsedValue cssValue = cascadingStyle.getParsedValue();
1983 
1984                     if ("inherit".equals(cssValue.getValue()) == false) {
1985                         return cascadingStyle;
1986                     }
1987                 }
1988 
1989             }
1990 
1991             parent = parent.getStyleableParent();
1992 
1993         }
1994 
1995         return null;
1996     }
1997 
1998 
1999     /**
2000      * Called from Node NodeHelper.getMatchingStyles
2001      * @param styleable
2002      * @param styleableProperty
2003      * @return
2004      */
2005     static List<Style> getMatchingStyles(final Styleable styleable, final CssMetaData styleableProperty) {
2006 
2007         if (!(styleable instanceof Node)) return Collections.<Style>emptyList();
2008 
2009         Node node = (Node)styleable;
2010         final CssStyleHelper helper = (node.styleHelper != null) ? node.styleHelper : createStyleHelper(node);
2011 
2012         if (helper != null) {
2013             return helper.getMatchingStyles(node, styleableProperty, false);
2014         }
2015         else {
2016             return Collections.<Style>emptyList();
2017         }
2018     }
2019 
2020     static Map<StyleableProperty<?>, List<Style>> getMatchingStyles(Map<StyleableProperty<?>, List<Style>> map, final Node node) {


< prev index next >