Search in sources :

Example 6 with ShapeFactory

use of org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory in project kie-wb-common by kiegroup.

the class LienzoShapeGlyphRenderer method render.

@Override
@SuppressWarnings("unchecked")
public Group render(final ShapeGlyph glyph, final double width, final double height) {
    final String definitionId = glyph.getDefinitionId();
    final Supplier<ShapeFactory> factorySupplier = glyph.getFactorySupplier();
    final Shape shape = factorySupplier.get().newShape(factoryManager.newDefinition(definitionId));
    final ShapeView<?> view = shape.getShapeView();
    final BoundingBox bb = boundingBoxProvider.apply(view);
    Group group = groupProvider.apply(view);
    if (null == group) {
        throw new RuntimeException("Shape view [" + view.toString() + "] not supported for " + "this shape glyph builder [" + this.getClass().getName());
    }
    if (view instanceof HasTitle) {
        final HasTitle hasTitle = (HasTitle) view;
        hasTitle.setTitle(null);
    }
    // Create a copy of this view.
    group = group.copy();
    // Scale, if necessary, to the given glyph size.
    final double[] scale = LienzoUtils.getScaleFactor(bb.getWidth(), bb.getHeight(), width, height);
    group.setScale(scale[0], scale[1]);
    return group;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) HasTitle(org.kie.workbench.common.stunner.core.client.shape.view.HasTitle) Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory)

Example 7 with ShapeFactory

use of org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory in project kie-wb-common by kiegroup.

the class SessionPreviewCanvasHandlerProxyTest method checkRegisterDelegatesToWrapped.

@Test
@SuppressWarnings("unchecked")
public void checkRegisterDelegatesToWrapped() {
    final Shape shape = mock(Shape.class);
    final Element candidate = mock(Element.class);
    final boolean fireEvents = true;
    proxy.register(shape, candidate, fireEvents);
    verify(wrapped).register(eq(shape), eq(candidate), eq(fireEvents));
    final String shapeSetId = "ShapeSetId";
    proxy.register(shapeSetId, candidate);
    verify(wrapped).register(eq(shapeSetId), eq(candidate));
    final ShapeFactory factory = mock(ShapeFactory.class);
    proxy.register(factory, candidate, fireEvents);
    verify(wrapped).register(eq(factory), eq(candidate), eq(fireEvents));
}
Also used : Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) Element(org.kie.workbench.common.stunner.core.graph.Element) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory) Test(org.junit.Test)

Aggregations

ShapeFactory (org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory)7 Edge (org.kie.workbench.common.stunner.core.graph.Edge)3 Node (org.kie.workbench.common.stunner.core.graph.Node)3 DragProxyCallback (org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback)2 Shape (org.kie.workbench.common.stunner.core.client.shape.Shape)2 View (org.kie.workbench.common.stunner.core.graph.content.view.View)2 Group (com.ait.lienzo.client.core.shape.Group)1 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)1 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)1 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)1 Before (org.junit.Before)1 Test (org.junit.Test)1 WiresConnectorView (org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresConnectorView)1 WiresShapeView (org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView)1 ShapeSet (org.kie.workbench.common.stunner.core.client.ShapeSet)1 AbstractCanvas (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvas)1 CanvasHandlerImpl (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandlerImpl)1 AddCanvasNodeCommand (org.kie.workbench.common.stunner.core.client.canvas.command.AddCanvasNodeCommand)1 UpdateElementPositionCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPositionCommand)1 ObserverBuilderControl (org.kie.workbench.common.stunner.core.client.canvas.controls.builder.impl.ObserverBuilderControl)1