Search in sources :

Example 1 with WiresConnector

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

the class WiresCanvasView method addShape.

@Override
public WiresCanvas.View addShape(final ShapeView<?> shapeView) {
    if (WiresUtils.isWiresShape(shapeView)) {
        WiresShape wiresShape = (WiresShape) shapeView;
        wiresManager.register(wiresShape);
        wiresManager.getMagnetManager().createMagnets(wiresShape, getMagnetCardinals());
        WiresUtils.assertShapeGroup(wiresShape.getGroup(), WiresCanvas.WIRES_CANVAS_GROUP_ID);
    } else if (WiresUtils.isWiresConnector(shapeView)) {
        WiresConnector wiresConnector = (WiresConnector) shapeView;
        final WiresConnectorControl connectorControl = wiresManager.register(wiresConnector);
        if (shapeView instanceof WiresConnectorView) {
            ((WiresConnectorView) shapeView).setControl(connectorControl);
        }
        WiresUtils.assertShapeGroup(wiresConnector.getGroup(), WiresCanvas.WIRES_CANVAS_GROUP_ID);
    } else {
        super.addShape(shapeView);
    }
    return this;
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector) WiresConnectorView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresConnectorView) WiresConnectorControl(com.ait.lienzo.client.core.shape.wires.handlers.WiresConnectorControl)

Example 2 with WiresConnector

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

the class WiresCanvasView method removeShape.

@Override
public WiresCanvas.View removeShape(final ShapeView<?> shapeView) {
    if (WiresUtils.isWiresShape(shapeView)) {
        WiresShape wiresShape = (WiresShape) shapeView;
        wiresManager.deregister(wiresShape);
    } else if (WiresUtils.isWiresConnector(shapeView)) {
        WiresConnector wiresConnector = (WiresConnector) shapeView;
        wiresManager.deregister(wiresConnector);
    } else {
        super.removeShape(shapeView);
    }
    return this;
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector)

Example 3 with WiresConnector

use of com.ait.lienzo.client.core.shape.wires.WiresConnector in project lienzo-core by ahome-it.

the class WiresCompositeControlImpl method onMoveStart.

@Override
public void onMoveStart(final double x, final double y) {
    delta = new Point2D(0, 0);
    selectedShapes = new ArrayList<>(selectionContext.getShapes());
    selectedConnectors = new ArrayList<>(selectionContext.getConnectors());
    final Map<String, WiresConnector> connectors = new HashMap<>();
    for (final WiresShape shape : selectedShapes) {
        ShapeControlUtils.collectionSpecialConnectors(shape, connectors);
        if (shape.getMagnets() != null) {
            // Must do magnets first, to avoid attribute change updates being processed.
            shape.getMagnets().onNodeDragStart(null);
        // Don't need to do this for nested objects, as those just move with their containers, without attribute changes
        }
        disableDocking(shape.getControl());
        final Point2D location = shape.getComputedLocation();
        final double sx = location.getX();
        final double sy = location.getY();
        shape.getControl().onMoveStart(sx, sy);
    }
    m_connectorsWithSpecialConnections = connectors.values().toArray(new WiresConnector[connectors.size()]);
    for (final WiresConnector connector : selectedConnectors) {
        final WiresConnector.WiresConnectorHandler handler = connector.getWiresConnectorHandler();
        // records the start position of all the points
        handler.getControl().onMoveStart(x, y);
        WiresConnector.updateHeadTailForRefreshedConnector(connector);
    }
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector) Point2D(com.ait.lienzo.client.core.types.Point2D) HashMap(java.util.HashMap)

Example 4 with WiresConnector

use of com.ait.lienzo.client.core.shape.wires.WiresConnector in project lienzo-core by ahome-it.

the class WiresCompositeControlImpl method onMoveComplete.

@Override
public boolean onMoveComplete() {
    boolean completeResult = true;
    final Collection<WiresShape> shapes = selectedShapes;
    if (!shapes.isEmpty()) {
        shapes.iterator().next().getWiresManager();
        for (final WiresShape shape : shapes) {
            if (!shape.getControl().onMoveComplete()) {
                completeResult = false;
            }
        }
    }
    final Collection<WiresConnector> connectors = selectedConnectors;
    if (!connectors.isEmpty()) {
        // Update connectors and connections.
        for (final WiresConnector connector : connectors) {
            if (!connector.getWiresConnectorHandler().getControl().onMoveComplete()) {
                completeResult = false;
            }
        }
    }
    delta = new Point2D(0, 0);
    return completeResult;
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector) Point2D(com.ait.lienzo.client.core.types.Point2D)

Example 5 with WiresConnector

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

the class ShapeViewDragProxyImpl method show.

@Override
public DragProxy<AbstractCanvas, ShapeView<?>, DragProxyCallback> show(final ShapeView<?> item, final int x, final int y, final DragProxyCallback callback) {
    final AbstractDragProxy.Callback c = new AbstractDragProxy.Callback() {

        @Override
        public void onStart(final int x, final int y) {
            callback.onStart(x, y);
        }

        @Override
        public void onMove(final int x, final int y) {
            callback.onMove(x, y);
        }

        @Override
        public void onComplete(final int x, final int y) {
            callback.onComplete(x, y);
        }
    };
    if (item instanceof WiresShape) {
        final WiresShape wiresShape = (WiresShape) item;
        this.proxy = new WiresShapeDragProxy(getLayer().getLienzoLayer(), wiresShape, x, y, 100, c);
    } else if (item instanceof WiresConnector) {
        final WiresConnector wiresConnector = (WiresConnector) item;
        this.proxy = new WiresConnectorDragProxy(getLayer().getLienzoLayer(), wiresConnector, x, y, 100, c);
    }
    return this;
}
Also used : AbstractDragProxy(org.kie.workbench.common.stunner.lienzo.primitive.AbstractDragProxy) WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector) DragProxyCallback(org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback) WiresConnectorDragProxy(org.kie.workbench.common.stunner.lienzo.primitive.WiresConnectorDragProxy) WiresShapeDragProxy(org.kie.workbench.common.stunner.lienzo.primitive.WiresShapeDragProxy)

Aggregations

WiresConnector (com.ait.lienzo.client.core.shape.wires.WiresConnector)11 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)9 Point2D (com.ait.lienzo.client.core.types.Point2D)4 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)1 OrthogonalPolyLine (com.ait.lienzo.client.core.shape.OrthogonalPolyLine)1 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)1 WiresMagnet (com.ait.lienzo.client.core.shape.wires.WiresMagnet)1 WiresManager (com.ait.lienzo.client.core.shape.wires.WiresManager)1 WiresConnectorControl (com.ait.lienzo.client.core.shape.wires.handlers.WiresConnectorControl)1 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)1 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)1 HashMap (java.util.HashMap)1 WiresConnectorView (org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresConnectorView)1 DragProxyCallback (org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback)1 AbstractDragProxy (org.kie.workbench.common.stunner.lienzo.primitive.AbstractDragProxy)1 WiresConnectorDragProxy (org.kie.workbench.common.stunner.lienzo.primitive.WiresConnectorDragProxy)1 WiresShapeDragProxy (org.kie.workbench.common.stunner.lienzo.primitive.WiresShapeDragProxy)1