use of org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition in project kie-wb-common by kiegroup.
the class SVGTranslationTestAssertions method assertCircle.
public static void assertCircle(final CircleDefinition circleDefinition) {
assertNotNull(circleDefinition);
assertEquals("c1", circleDefinition.getId());
assertEquals(1d, circleDefinition.getAlpha(), 0d);
assertEquals(50d, circleDefinition.getX(), 0d);
assertEquals(51d, circleDefinition.getY(), 0d);
assertEquals(40d, circleDefinition.getRadius(), 0d);
final TransformDefinition transformDefinition = circleDefinition.getTransformDefinition();
assertTransformDef(transformDefinition, 0.85d, 0.67d, 4.5d, 2.39d);
final StyleDefinition styleDefinition = circleDefinition.getStyleDefinition();
assertStyleDef(styleDefinition, 1d, "#ff0000", 1d, "#ffff00", 1d, 5d);
}
use of org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition in project kie-wb-common by kiegroup.
the class SVGShapeTextCodeBuilder method generate.
public static String generate(final String viewInstanceName, final String viewId, final StyleSheetDefinition styleSheetDefinition) {
final StyleDefinition globalStyle = styleSheetDefinition.getStyle(CSS_SELECTOR_TEXT);
final StyleDefinition customStyle = styleSheetDefinition.getStyle("#" + viewId + " " + CSS_SELECTOR_TEXT);
return null != globalStyle || null != customStyle ? generateTextSetters(viewInstanceName, globalStyle, customStyle) : "";
}
use of org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition in project kie-wb-common by kiegroup.
the class SVGTranslationTestAssertions method assertRectangle.
public static void assertRectangle(final RectDefinition rectDefinition) {
assertNotNull(rectDefinition);
assertEquals("r1", rectDefinition.getId());
assertEquals(1d, rectDefinition.getAlpha(), 0d);
assertEquals(1d, rectDefinition.getX(), 0d);
assertEquals(2d, rectDefinition.getY(), 0d);
assertEquals(200d, rectDefinition.getWidth(), 0d);
assertEquals(230d, rectDefinition.getHeight(), 0d);
assertEquals(15d, rectDefinition.getCornerRadius(), 0d);
final TransformDefinition transformDefinition = rectDefinition.getTransformDefinition();
assertTransformDef(transformDefinition, 0.5d, 0.5d, 25d, 30d);
final StyleDefinition styleDefinition = rectDefinition.getStyleDefinition();
assertStyleDef(styleDefinition, 1d, "#0000ff", 1d, "#000000", 1d, 3d);
}
use of org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition in project kie-wb-common by kiegroup.
the class SVGTranslationTestAssertions method assertPath.
public static void assertPath(final MultiPathDefinition pathDefinition) {
assertEquals("M150 0 L75 200 L225 200 Z", pathDefinition.getPath());
assertEquals("p1", pathDefinition.getId());
assertEquals(1d, pathDefinition.getAlpha(), 0d);
assertEquals(0d, pathDefinition.getX(), 0d);
assertEquals(0d, pathDefinition.getY(), 0d);
final TransformDefinition transformDefinition = pathDefinition.getTransformDefinition();
assertTransformDef(transformDefinition, 0.25d, 0.25d, 10d, 10d);
final StyleDefinition styleDefinition = pathDefinition.getStyleDefinition();
assertStyleDef(styleDefinition, 1d, "#ff0000", 1d, "#0000ff", 1d, 2d);
}
use of org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition 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