Search in sources :

Example 1 with StyleDefinition

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);
}
Also used : TransformDefinition(org.kie.workbench.common.stunner.svg.gen.model.TransformDefinition) StyleDefinition(org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition)

Example 2 with StyleDefinition

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) : "";
}
Also used : StyleDefinition(org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition)

Example 3 with StyleDefinition

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);
}
Also used : TransformDefinition(org.kie.workbench.common.stunner.svg.gen.model.TransformDefinition) StyleDefinition(org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition)

Example 4 with StyleDefinition

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);
}
Also used : TransformDefinition(org.kie.workbench.common.stunner.svg.gen.model.TransformDefinition) StyleDefinition(org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition)

Example 5 with StyleDefinition

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;
}
Also used : InputSource(org.w3c.css.sac.InputSource) CSSRule(org.w3c.dom.css.CSSRule) CSSStyleSheetImpl(com.steadystate.css.dom.CSSStyleSheetImpl) InputStreamReader(java.io.InputStreamReader) CSSStyleRuleImpl(com.steadystate.css.dom.CSSStyleRuleImpl) StyleSheetDefinition(org.kie.workbench.common.stunner.svg.gen.model.StyleSheetDefinition) CSSStyleDeclaration(org.w3c.dom.css.CSSStyleDeclaration) StyleDefinition(org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition) CSSRuleList(org.w3c.dom.css.CSSRuleList)

Aggregations

StyleDefinition (org.kie.workbench.common.stunner.svg.gen.model.StyleDefinition)7 TransformDefinition (org.kie.workbench.common.stunner.svg.gen.model.TransformDefinition)3 CSSStyleRuleImpl (com.steadystate.css.dom.CSSStyleRuleImpl)1 CSSStyleSheetImpl (com.steadystate.css.dom.CSSStyleSheetImpl)1 InputStreamReader (java.io.InputStreamReader)1 StyleSheetDefinition (org.kie.workbench.common.stunner.svg.gen.model.StyleSheetDefinition)1 InputSource (org.w3c.css.sac.InputSource)1 CSSRule (org.w3c.dom.css.CSSRule)1 CSSRuleList (org.w3c.dom.css.CSSRuleList)1 CSSStyleDeclaration (org.w3c.dom.css.CSSStyleDeclaration)1