Search in sources :

Example 51 with WiresShape

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

the class WiresConnectionControlImpl method allowedMagnetAndUpdateAutoConnections.

public static boolean allowedMagnetAndUpdateAutoConnections(final WiresConnection connection, final boolean isHead, final WiresShape shape, final WiresMagnet currentMagnet, final boolean applyAccept) {
    final WiresConnector connector = connection.getConnector();
    // shape can be null, to see if a connection can be unconnected to a magnet
    boolean accept;
    WiresShape headS;
    WiresShape tailS;
    if (isHead) {
        accept = connector.getConnectionAcceptor().headConnectionAllowed(connection, shape);
        headS = shape;
        tailS = (connector.getTailConnection().getMagnet() != null) ? connector.getTailConnection().getMagnet().getMagnets().getWiresShape() : null;
    } else {
        accept = connector.getConnectionAcceptor().tailConnectionAllowed(connection, shape);
        headS = (connector.getHeadConnection().getMagnet() != null) ? connector.getHeadConnection().getMagnet().getMagnets().getWiresShape() : null;
        tailS = shape;
    }
    if (applyAccept && accept) {
        accept = accept && acceptMagnetAndUpdateAutoConnection(connection, isHead, headS, tailS, currentMagnet);
        if (!accept) {
            throw new RuntimeException("This should never happen, acceptors should not fail if the alled passed. Added for defensive programming checking");
        }
    }
    return accept;
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector)

Example 52 with WiresShape

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

the class WiresConnectionControlImpl method makeAndUpdateSpecialConnections.

private boolean makeAndUpdateSpecialConnections() {
    final WiresConnection connection = getConnection();
    WiresShape shape = null;
    if (m_current_magnet != null) {
        shape = m_current_magnet.getMagnets().getWiresShape();
        connection.setAutoConnection(false);
    } else {
        if (m_colorKey != null) {
            shape = m_shape_color_map.get(m_colorKey);
            if ((shape != null) && (shape.getMagnets() != null)) {
                // no magnet is selected, but if we are over a shape, then auto connect
                connection.setAutoConnection(true);
            } else {
                connection.setAutoConnection(false);
            }
        } else {
            connection.setAutoConnection(false);
        }
    }
    return allowedMagnetAndUpdateAutoConnections(connection, m_head, shape, m_current_magnet, true);
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnection(com.ait.lienzo.client.core.shape.wires.WiresConnection)

Example 53 with WiresShape

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

the class WiresDockingControlImpl method afterMoveStart.

@Override
protected void afterMoveStart(final double x, final double y) {
    super.afterMoveStart(x, y);
    final WiresShape shape = getShape();
    if (null != shape.getDockedTo()) {
        shape.setDockedTo(null);
    }
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape)

Example 54 with WiresShape

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

the class WiresDockingControlImpl method getAdjust.

@Override
public Point2D getAdjust() {
    if (isEnabled() && (intersection != null)) {
        final WiresShape shape = getShape();
        final BoundingBox box = shape.getPath().getBoundingBox();
        // convert to local xy of the path
        final Point2D absLoc = getParent().getComputedLocation();
        final double newX = (absLoc.getX() + intersection.getX()) - (box.getWidth() / 2);
        final double newY = (absLoc.getY() + intersection.getY()) - (box.getHeight() / 2);
        return new Point2D(newX - initialPathLocation.getX(), newY - initialPathLocation.getY());
    }
    return new Point2D(0, 0);
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) Point2D(com.ait.lienzo.client.core.types.Point2D) BoundingBox(com.ait.lienzo.client.core.types.BoundingBox)

Example 55 with WiresShape

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

the class WiresDockingControlImpl method afterMove.

@Override
protected boolean afterMove(final double dx, final double dy) {
    super.afterMove(dx, dy);
    intersection = null;
    if (isAllow()) {
        final Point2D location = getParentPickerControl().getCurrentLocation();
        // convert to local xy of the path
        final Point2D absLoc = getParent().getComputedLocation();
        intersection = Geometry.findIntersection((int) (location.getX() - absLoc.getX()), (int) (location.getY() - absLoc.getY()), ((WiresShape) getParent()).getPath());
    }
    return null != intersection;
}
Also used : WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) Point2D(com.ait.lienzo.client.core.types.Point2D)

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