Search in sources :

Example 6 with WiresManager

use of com.ait.lienzo.client.core.shape.wires.WiresManager 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 7 with WiresManager

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

the class WiresDockingControlImpl method _isAccept.

private boolean _isAccept() {
    final WiresLayer layer = getParentPickerControl().getWiresLayer();
    final WiresManager wiresManager = layer.getWiresManager();
    final IDockingAcceptor dockingAcceptor = wiresManager.getDockingAcceptor();
    return (null != getParent()) && (null != getParentShapePart()) && (getParentShapePart() == PickerPart.ShapePart.BORDER) && dockingAcceptor.acceptDocking(getParent(), getShape());
}
Also used : IDockingAcceptor(com.ait.lienzo.client.core.shape.wires.IDockingAcceptor) WiresManager(com.ait.lienzo.client.core.shape.wires.WiresManager) WiresLayer(com.ait.lienzo.client.core.shape.wires.WiresLayer)

Aggregations

WiresManager (com.ait.lienzo.client.core.shape.wires.WiresManager)7 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)4 WiresLayer (com.ait.lienzo.client.core.shape.wires.WiresLayer)3 IDockingAcceptor (com.ait.lienzo.client.core.shape.wires.IDockingAcceptor)2 WiresContainer (com.ait.lienzo.client.core.shape.wires.WiresContainer)2 Point2D (com.ait.lienzo.client.core.types.Point2D)2 IContainmentAcceptor (com.ait.lienzo.client.core.shape.wires.IContainmentAcceptor)1 WiresConnector (com.ait.lienzo.client.core.shape.wires.WiresConnector)1 Test (org.junit.Test)1