/** * Retrieves for a preprocessing-symbol for each defined CSS-attribute. When the attribute * ticker-step is defined, the preprocessing-symbol "polish.css.ticker-step" will be defined. * * @param device the current device * @return a map containing all defined symbols as keys with each having a Boolean.TRUE as value. */ public HashMap<String, Boolean> getCssPreprocessingSymbols(Device device) { CssAttributesManager cssAttributesManager = CssAttributesManager.getInstance(); if (this.cssPreprocessingSymbols == null) { HashMap<String, Boolean> symbols = new HashMap<String, Boolean>(); HashMap<String, Boolean> attributesByName = new HashMap<String, Boolean>(); if (this.mediaQueries != null) { symbols.put("polish.css.mediaquery", Boolean.TRUE); } Style[] myStyles = getAllStyles(); for (int i = 0; i < myStyles.length; i++) { Style style = myStyles[i]; symbols.put("polish.css.style." + style.getStyleName(), Boolean.TRUE); String[] attributes = style.getDefinedAttributes(device); for (int j = 0; j < attributes.length; j++) { String attribute = attributes[j]; // System.out.println("adding symbol polish.css." + attribute + " of style " + // style.getSelector() ); symbols.put("polish.css." + attribute, Boolean.TRUE); attributesByName.put(attribute, Boolean.TRUE); } CssDeclarationBlock[] blocks = style.getDeclarationBlocksEndingWith("-animation"); if (blocks.length > 0) { symbols.put("polish.css.animations", Boolean.TRUE); } for (int j = 0; j < blocks.length; j++) { CssDeclarationBlock block = blocks[j]; String cssAttributeName = block .getBlockName() .substring(0, block.getBlockName().length() - "-animation".length()); CssAttribute cssAttribute = cssAttributesManager.getAttribute(cssAttributeName); if (cssAttribute == null) { int hyphenPos = cssAttributeName.indexOf('-'); if (hyphenPos != -1) { String groupName = cssAttributeName.substring(0, hyphenPos); String type = style.getValue(groupName, "type"); if (type == null) { type = "simple"; } String alternativeCssAttributeName = groupName + "-" + type + cssAttributeName.substring(hyphenPos); cssAttribute = cssAttributesManager.getAttribute(alternativeCssAttributeName); if (cssAttribute != null) { cssAttributeName = alternativeCssAttributeName; block.setBlockName(cssAttributeName + "-animation"); } } } if (cssAttribute != null) { symbols.put("polish.css." + cssAttributeName, Boolean.TRUE); } } } this.cssPreprocessingSymbols = symbols; this.cssAttributes = attributesByName; } return this.cssPreprocessingSymbols; }
static Style fromInt(int enumValue) { for (Style style : values()) { if (style.getValue() == enumValue) { return style; } } return null; }