Search in sources :

Example 1 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.

the class ConnectorDragProxyImpl method show.

@Override
@SuppressWarnings("unchecked")
public DragProxy<AbstractCanvasHandler, Item, DragProxyCallback> show(final Item item, final int x, final int y, final DragProxyCallback callback) {
    // Source connector's shape - Obtain the shape for the source node.
    final Node<View<?>, Edge> sourceNode = item.getSourceNode();
    final Shape<?> sourceNodeShape = getCanvas().getShape(sourceNode.getUUID());
    // Target connector's shape - Create a temporary shape view, that will act as the connector's target node.
    final WiresShapeView transientShapeView = new WiresShapeView<>(new MultiPath().rect(0, 0, 1, 1).setFillAlpha(0).setStrokeAlpha(0));
    getWiresManager().getMagnetManager().createMagnets(transientShapeView);
    // Create the transient connector's shape and view.
    final Edge<View<?>, Node> edge = item.getEdge();
    final Shape<?> edgeShape = ((ShapeFactory<Object, ?>) item.getShapeFactory()).newShape(edge.getContent().getDefinition());
    final EdgeShape connectorShape = (EdgeShape) edgeShape;
    this.connectorShapeView = (WiresConnectorView<?>) edgeShape.getShapeView();
    // Register and update shape's view as for edge bean's state.
    getWiresManager().register(connectorShapeView);
    connectorShape.applyProperties(edge, MutationContext.STATIC);
    // Apply connector's connections for both source and target shapes.
    // Using center connector strategy, so magnet index 0.
    final MagnetConnection centerConnection = new MagnetConnection.Builder().atX(0).atY(0).magnet(0).build();
    connectorShapeView.connect(sourceNodeShape.getShapeView(), centerConnection, transientShapeView, centerConnection);
    // Optimize the index and show the drag proxy for the temporary shape view.
    graphBoundsIndexer.build(canvasHandler.getDiagram().getGraph());
    shapeViewDragProxyFactory.show(transientShapeView, x, y, new DragProxyCallback() {

        @Override
        public void onStart(final int x, final int y) {
            callback.onStart(x, y);
            // As using center magnet, update the connection.
            connectorShapeView.updateForCenterConnection();
        }

        @Override
        public void onMove(final int x, final int y) {
            callback.onMove(x, y);
            // As using center magnet, update the connection.
            connectorShapeView.updateForCenterConnection();
        }

        @Override
        public void onComplete(final int x, final int y) {
            callback.onComplete(x, y);
            deregisterTransientConnector();
            getCanvas().draw();
        }
    });
    return this;
}
Also used : MultiPath(com.ait.lienzo.client.core.shape.MultiPath) EdgeShape(org.kie.workbench.common.stunner.core.client.shape.EdgeShape) Node(org.kie.workbench.common.stunner.core.graph.Node) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory) WiresShapeView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView) View(org.kie.workbench.common.stunner.core.graph.content.view.View) WiresConnectorView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresConnectorView) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) WiresShapeView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView) DragProxyCallback(org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 2 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.

the class CaseManagementColorMapBackedPicker method addDropZone.

void addDropZone(final AbstractCaseManagementShape<?> prim) {
    final Optional<MultiPath> optMultiPath = prim.getDropZone();
    if (optMultiPath.isPresent()) {
        final MultiPath multiPath = optMultiPath.get();
        multiPath.getAttributes().setX(prim.getX());
        multiPath.getAttributes().setY(prim.getY());
        drawShape(m_colorKeyRotor.next(), multiPath.getStrokeWidth(), multiPath, new PickerPart(prim, PickerPart.ShapePart.BODY), true);
    }
}
Also used : MultiPath(com.ait.lienzo.client.core.shape.MultiPath) PickerPart(com.ait.lienzo.client.core.shape.wires.PickerPart)

Example 3 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.

the class CaseManagementShapeDefFactoryTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    this.pictureShapeView = new PictureShapeView(new MultiPath().rect(0, 0, 10, 10));
    when(stageView.setWidth(anyDouble())).thenReturn(stageView);
    when(stageView.setHeight(anyDouble())).thenReturn(stageView);
    when(basicShapeViewFactory.pictureFromUri(any(SafeUri.class), anyDouble(), anyDouble())).thenReturn(pictureShapeView);
    when(basicShapeViewFactory.connector(anyDouble(), anyDouble(), anyDouble(), anyDouble())).thenReturn(connectorShapeView);
    when(cmShapeViewFactory.newNullView()).thenReturn(nullView);
    when(cmShapeViewFactory.newStageView(anyDouble(), anyDouble(), anyDouble())).thenReturn(stageView);
    when(cmShapeViewFactory.newActivityView(anyDouble(), anyDouble())).thenReturn(activityView);
    when(cmShapeViewFactory.newDiagramView(anyDouble(), anyDouble())).thenReturn(diagramView);
    this.tested = new CaseManagementShapeDefFactory(cmShapeViewFactory, basicShapeViewFactory, new ShapeDefFunctionalFactory<>());
    this.tested.init();
}
Also used : MultiPath(com.ait.lienzo.client.core.shape.MultiPath) ShapeDefFunctionalFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeDefFunctionalFactory) SafeUri(com.google.gwt.safehtml.shared.SafeUri) PictureShapeView(org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView) Before(org.junit.Before)

Example 4 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.

the class CaseManagementShapeFactoryTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.pictureShapeView = new PictureShapeView(new MultiPath().rect(0, 0, 10, 10));
    this.cmShapeViewFactory = new CaseManagementShapeViewFactory();
    final BasicShapesFactory basicShapesFactory = new BasicShapesFactory(new ShapeDefFunctionalFactory<>(), basicViewFactory);
    basicShapesFactory.init();
    final CaseManagementShapeDefFactory cmShapeDefFactory = new CaseManagementShapeDefFactory(cmShapeViewFactory, basicViewFactory, new ShapeDefFunctionalFactory<>());
    cmShapeDefFactory.init();
    this.delegate = spy(new DelegateShapeFactory());
    doReturn(glyph).when(delegate).getGlyph(anyString());
    this.factory = new CaseManagementShapeFactory(cmShapeDefFactory, basicShapesFactory, delegate);
    this.factory.init();
    when(basicViewFactory.pictureFromUri(any(SafeUri.class), anyDouble(), anyDouble())).thenReturn(pictureShapeView);
    when(basicViewFactory.connector(anyDouble(), anyDouble(), anyDouble(), anyDouble())).thenReturn(connectorShapeView);
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.forDefinition()).thenReturn(definitionAdapter);
}
Also used : MultiPath(com.ait.lienzo.client.core.shape.MultiPath) DelegateShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.DelegateShapeFactory) BasicShapesFactory(org.kie.workbench.common.stunner.shapes.client.factory.BasicShapesFactory) SafeUri(com.google.gwt.safehtml.shared.SafeUri) PictureShapeView(org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView) Before(org.junit.Before)

Example 5 with MultiPath

use of com.ait.lienzo.client.core.shape.MultiPath in project kie-wb-common by kiegroup.

the class BaseLayoutManagerTest method setup.

public void setup() {
    this.shapes = new ArrayList<>();
    this.handler = getLayoutHandler();
    this.container = spy(new MockCaseManagementShape());
    this.container.setLayoutHandler(handler);
    // Shapes are at (0,15), (0,30) and (0,45) by default. Set by LayoutManager.
    for (int i = 0; i < 3; i++) {
        final int index = i;
        final WiresShape shape = new WiresShape(new MultiPath()) {

            @Override
            public String toString() {
                return "WiresShape:" + index;
            }
        };
        container.add(shape);
        shapes.add(shape);
    }
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) MultiPath(com.ait.lienzo.client.core.shape.MultiPath)

Aggregations

MultiPath (com.ait.lienzo.client.core.shape.MultiPath)39 Test (org.junit.Test)16 WiresShapeView (org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView)10 MultiPathDecorator (com.ait.lienzo.client.core.shape.MultiPathDecorator)9 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)9 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)7 Point2D (com.ait.lienzo.client.core.types.Point2D)7 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)4 Before (org.junit.Before)4 Layer (com.ait.lienzo.client.core.shape.Layer)3 PickerPart (com.ait.lienzo.client.core.shape.wires.PickerPart)3 DashArray (com.ait.lienzo.client.core.types.DashArray)3 PictureShapeView (org.kie.workbench.common.stunner.shapes.client.view.PictureShapeView)3 Group (com.ait.lienzo.client.core.shape.Group)2 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)2 WiresConnector (com.ait.lienzo.client.core.shape.wires.WiresConnector)2 WiresMagnet (com.ait.lienzo.client.core.shape.wires.WiresMagnet)2 NFastArrayList (com.ait.tooling.nativetools.client.collection.NFastArrayList)2 SafeUri (com.google.gwt.safehtml.shared.SafeUri)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2