Search in sources :

Example 46 with WiresShape

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

the class WiresCompositeControlImpl method onMove.

@Override
public boolean onMove(final double dx, final double dy) {
    if (isOutOfBounds(dx, dy)) {
        return true;
    }
    delta = new Point2D(dx, dy);
    // Delegate location deltas to shape controls and obtain current locations for each one.
    final Collection<WiresShape> shapes = selectedShapes;
    if (!shapes.isEmpty()) {
        final WiresManager wiresManager = shapes.iterator().next().getWiresManager();
        final Point2D[] locs = new Point2D[shapes.size()];
        int i = 0;
        for (final WiresShape shape : shapes) {
            shape.getControl().onMove(dx, dy);
            locs[i++] = getCandidateShapeLocationRelativeToInitialParent(shape);
        }
        // Check if new locations are allowed.
        final WiresShape[] shapesArray = toArray(shapes);
        final boolean locationAllowed = wiresManager.getLocationAcceptor().allow(shapesArray, locs);
        // Do the updates.
        if (locationAllowed) {
            i = 0;
            for (final WiresShape shape : shapes) {
                shape.getControl().getParentPickerControl().setShapeLocation(locs[i++]);
                postUpdateShape(shape);
            }
        }
    }
    final Collection<WiresConnector> connectors = selectedConnectors;
    if (!connectors.isEmpty()) {
        // Update connectors and connections.
        for (final WiresConnector connector : connectors) {
            final WiresConnector.WiresConnectorHandler handler = connector.getWiresConnectorHandler();
            handler.getControl().move(dx, dy, true, true);
            WiresConnector.updateHeadTailForRefreshedConnector(connector);
        }
    }
    ShapeControlUtils.updateSpecialConnections(m_connectorsWithSpecialConnections, false);
    return false;
}
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) WiresManager(com.ait.lienzo.client.core.shape.wires.WiresManager)

Example 47 with WiresShape

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

the class WiresCompositeControlImpl method reset.

@Override
public void reset() {
    for (final WiresShape shape : selectedShapes) {
        shape.getControl().reset();
        enableDocking(shape.getControl());
    }
    for (final WiresConnector connector : selectedConnectors) {
        final WiresConnector.WiresConnectorHandler handler = connector.getWiresConnectorHandler();
        handler.getControl().reset();
        WiresConnector.updateHeadTailForRefreshedConnector(connector);
    }
    clearState();
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector)

Example 48 with WiresShape

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

the class WiresCompositeControlImpl method execute.

@Override
public void execute() {
    for (final WiresShape shape : selectedShapes) {
        shape.getControl().getContainmentControl().execute();
        postUpdateShape(shape);
    }
    for (final WiresConnector connector : selectedConnectors) {
        connector.getWiresConnectorHandler();
        WiresConnector.updateHeadTailForRefreshedConnector(connector);
    }
    ShapeControlUtils.updateSpecialConnections(m_connectorsWithSpecialConnections, true);
    clear();
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector)

Example 49 with WiresShape

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

the class WiresCompositeControlImpl method clear.

@Override
public void clear() {
    for (final WiresShape shape : selectedShapes) {
        shape.getControl().clear();
        enableDocking(shape.getControl());
    }
    clearState();
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape)

Example 50 with WiresShape

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

the class WiresCompositeShapeHandler method doAdjust.

@Override
protected boolean doAdjust(final Point2D dxy) {
    final boolean adjusted = shapeControl.onMove(dxy.getX(), dxy.getY());
    if (adjusted) {
        dxy.set(shapeControl.getAdjust());
        return true;
    }
    boolean shouldRestore = true;
    if (shapeControl.isAllowed()) {
        final WiresContainer parent = shapeControl.getSharedParent();
        if ((null != parent) && (parent instanceof WiresShape)) {
            highlight.highlight((WiresShape) parent, PickerPart.ShapePart.BODY);
            shouldRestore = false;
        }
    }
    if (shouldRestore) {
        highlight.restore();
    }
    return false;
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresContainer(com.ait.lienzo.client.core.shape.wires.WiresContainer)

Aggregations

WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)58 Test (org.junit.Test)14 Point2D (com.ait.lienzo.client.core.types.Point2D)11 WiresConnector (com.ait.lienzo.client.core.shape.wires.WiresConnector)9 WiresContainer (com.ait.lienzo.client.core.shape.wires.WiresContainer)7 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)6 WiresManager (com.ait.lienzo.client.core.shape.wires.WiresManager)4 PickerPart (com.ait.lienzo.client.core.shape.wires.PickerPart)3 IContainmentAcceptor (com.ait.lienzo.client.core.shape.wires.IContainmentAcceptor)2 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)2 WiresLayer (com.ait.lienzo.client.core.shape.wires.WiresLayer)2 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)2 AbstractCaseManagementShape (org.kie.workbench.common.stunner.cm.client.wires.AbstractCaseManagementShape)2 MockCaseManagementShape (org.kie.workbench.common.stunner.cm.client.wires.MockCaseManagementShape)2 Node (org.kie.workbench.common.stunner.core.graph.Node)2 Group (com.ait.lienzo.client.core.shape.Group)1 Layer (com.ait.lienzo.client.core.shape.Layer)1 Shape (com.ait.lienzo.client.core.shape.Shape)1 IDockingAcceptor (com.ait.lienzo.client.core.shape.wires.IDockingAcceptor)1 ILayoutHandler (com.ait.lienzo.client.core.shape.wires.ILayoutHandler)1