use of com.steadystate.css.dom.CSSStyleRuleImpl in project kie-wb-common by kiegroup.
the class SVGStyleTranslator method parseElementStyleDefinition.
private static StyleDefinition parseElementStyleDefinition(final String styleRaw) throws TranslatorException {
final CSSStyleSheetImpl sheet = parseElementStyleSheet(styleRaw);
final CSSRuleList cssRules = sheet.getCssRules();
for (int i = 0; i < cssRules.getLength(); i++) {
final CSSRule item = cssRules.item(i);
if (CSSRule.STYLE_RULE == item.getType()) {
final CSSStyleRuleImpl rule = (CSSStyleRuleImpl) item;
final CSSStyleDeclaration declaration = rule.getStyle();
return parseStyleDefinition(declaration);
}
}
return null;
}
use of com.steadystate.css.dom.CSSStyleRuleImpl in project kie-wb-common by kiegroup.
the class SVGStyleTranslator method parseStyleSheetDefinition.
public static StyleSheetDefinition parseStyleSheetDefinition(final String cssPath, final InputStream cssStream) throws TranslatorException {
final CSSStyleSheetImpl sheet = parseStyleSheet(new InputSource(new InputStreamReader(cssStream)));
final CSSRuleList cssRules = sheet.getCssRules();
final StyleSheetDefinition result = new StyleSheetDefinition(cssPath);
for (int i = 0; i < cssRules.getLength(); i++) {
final CSSRule item = cssRules.item(i);
if (CSSRule.STYLE_RULE == item.getType()) {
final CSSStyleRuleImpl rule = (CSSStyleRuleImpl) item;
final String selectorText = rule.getSelectorText();
final CSSStyleDeclaration declaration = rule.getStyle();
final StyleDefinition styleDefinition = parseStyleDefinition(declaration);
result.addStyle(selectorText, styleDefinition);
}
}
return result;
}
Aggregations