Search in sources :

Example 1 with SVGShapeView

use of org.kie.workbench.common.stunner.svg.client.shape.view.SVGShapeView in project kie-wb-common by kiegroup.

the class DMNViewHandlersTest method testNewSizeHandler.

@Test
public void testNewSizeHandler() {
    final SizeHandler<DMNViewDefinition, SVGShapeView> handler = new DMNSVGShapeDefImpl().newSizeHandler();
    handler.handle(view, shape);
    verify(shape).setSizeConstraints(eq(Width.MIN), eq(Height.MIN), eq(Width.MAX), eq(Height.MAX));
}
Also used : DMNSVGShapeDefImpl(org.kie.workbench.common.dmn.client.shape.def.DMNSVGShapeDefImpl) DMNViewDefinition(org.kie.workbench.common.dmn.api.definition.DMNViewDefinition) SVGShapeView(org.kie.workbench.common.stunner.svg.client.shape.view.SVGShapeView) Test(org.junit.Test)

Example 2 with SVGShapeView

use of org.kie.workbench.common.stunner.svg.client.shape.view.SVGShapeView in project kie-wb-common by kiegroup.

the class SVGShapeFactory method newSVGMutableShape.

@SuppressWarnings("unchecked")
private SVGShape<?> newSVGMutableShape(final Object instance, final SVGShapeDef shapeDef) {
    final SVGShapeViewDef mutableShapeDef = (SVGShapeViewDef) shapeDef;
    final SVGShapeView view = newSVGShapeView(instance, mutableShapeDef);
    return new SVGMutableShapeImpl<Object, SVGShapeViewDef<Object, Object>>(mutableShapeDef, (SVGShapeViewImpl) view);
}
Also used : SVGShapeViewDef(org.kie.workbench.common.stunner.svg.client.shape.def.SVGShapeViewDef) SVGMutableShapeImpl(org.kie.workbench.common.stunner.svg.client.shape.impl.SVGMutableShapeImpl) SVGShapeView(org.kie.workbench.common.stunner.svg.client.shape.view.SVGShapeView)

Example 3 with SVGShapeView

use of org.kie.workbench.common.stunner.svg.client.shape.view.SVGShapeView in project kie-wb-common by kiegroup.

the class SVGDocumentTranslatorTest method testTranslate.

@Test
public void testTranslate() throws Exception {
    final ViewDefinition<SVGShapeView> viewDefinition = translator.translate(new SVGTranslatorContext(svgTest, "", styleSheetDefinition));
    assertNotNull(viewDefinition);
    assertEquals("svg-test-file", viewDefinition.getId());
    // View definition's viewBox.
    final ViewDefinition.ViewBoxDefinition viewBox = viewDefinition.getViewBox();
    assertNotNull(viewBox);
    final double minX = viewBox.getMinX();
    final double minY = viewBox.getMinY();
    final double width = viewBox.getWidth();
    final double height = viewBox.getHeight();
    assertEquals(minX, 0d, 0d);
    assertEquals(minY, 0d, 0d);
    assertEquals(width, 448d, 0d);
    assertEquals(height, 448d, 0d);
    // View definition's main shape.
    final PrimitiveDefinition mainShapeDef = viewDefinition.getMain();
    assertNotNull(mainShapeDef);
    assertTrue(mainShapeDef instanceof MultiPathDefinition);
    final MultiPathDefinition mainPathDef = (MultiPathDefinition) mainShapeDef;
    SVGTranslationTestAssertions.assertPath(mainPathDef);
    assertTrue(mainPathDef.isListening());
    // View definition's child shapes.
    final List<PrimitiveDefinition> childrenDefs = viewDefinition.getChildren();
    assertNotNull(childrenDefs);
    assertTrue(childrenDefs.size() == 3);
    final RectDefinition rectDefinition = (RectDefinition) childrenDefs.get(0);
    SVGTranslationTestAssertions.assertRectangle(rectDefinition);
    assertFalse(rectDefinition.isListening());
    final CircleDefinition circleDefinition = (CircleDefinition) childrenDefs.get(1);
    SVGTranslationTestAssertions.assertCircle(circleDefinition);
    assertFalse(circleDefinition.isListening());
    // Assert other svg reference elements.
    final GroupDefinition groupDefinition = (GroupDefinition) childrenDefs.get(2);
    assertFalse(groupDefinition.isListening());
    SVGTranslationTestAssertions.assertGroupRef(groupDefinition);
    final List<ViewRefDefinition> svgViewRefs = viewDefinition.getSVGViewRefs();
    assertNotNull(svgViewRefs);
    assertTrue(svgViewRefs.size() == 1);
    final ViewRefDefinition viewRefDef = svgViewRefs.get(0);
    SVGTranslationTestAssertions.assertViewRef(viewRefDef);
}
Also used : CircleDefinition(org.kie.workbench.common.stunner.svg.gen.model.impl.CircleDefinition) ViewDefinition(org.kie.workbench.common.stunner.svg.gen.model.ViewDefinition) SVGShapeView(org.kie.workbench.common.stunner.svg.client.shape.view.SVGShapeView) PrimitiveDefinition(org.kie.workbench.common.stunner.svg.gen.model.PrimitiveDefinition) MultiPathDefinition(org.kie.workbench.common.stunner.svg.gen.model.impl.MultiPathDefinition) GroupDefinition(org.kie.workbench.common.stunner.svg.gen.model.impl.GroupDefinition) ViewRefDefinition(org.kie.workbench.common.stunner.svg.gen.model.ViewRefDefinition) SVGTranslatorContext(org.kie.workbench.common.stunner.svg.gen.translator.SVGTranslatorContext) RectDefinition(org.kie.workbench.common.stunner.svg.gen.model.impl.RectDefinition) Test(org.junit.Test)

Aggregations

SVGShapeView (org.kie.workbench.common.stunner.svg.client.shape.view.SVGShapeView)3 Test (org.junit.Test)2 DMNViewDefinition (org.kie.workbench.common.dmn.api.definition.DMNViewDefinition)1 DMNSVGShapeDefImpl (org.kie.workbench.common.dmn.client.shape.def.DMNSVGShapeDefImpl)1 SVGShapeViewDef (org.kie.workbench.common.stunner.svg.client.shape.def.SVGShapeViewDef)1 SVGMutableShapeImpl (org.kie.workbench.common.stunner.svg.client.shape.impl.SVGMutableShapeImpl)1 PrimitiveDefinition (org.kie.workbench.common.stunner.svg.gen.model.PrimitiveDefinition)1 ViewDefinition (org.kie.workbench.common.stunner.svg.gen.model.ViewDefinition)1 ViewRefDefinition (org.kie.workbench.common.stunner.svg.gen.model.ViewRefDefinition)1 CircleDefinition (org.kie.workbench.common.stunner.svg.gen.model.impl.CircleDefinition)1 GroupDefinition (org.kie.workbench.common.stunner.svg.gen.model.impl.GroupDefinition)1 MultiPathDefinition (org.kie.workbench.common.stunner.svg.gen.model.impl.MultiPathDefinition)1 RectDefinition (org.kie.workbench.common.stunner.svg.gen.model.impl.RectDefinition)1 SVGTranslatorContext (org.kie.workbench.common.stunner.svg.gen.translator.SVGTranslatorContext)1