Search in sources :

Example 6 with IControlHandleList

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

the class WiresMagnetsControlImpl method shapeChanged.

@Override
public void shapeChanged() {
    final IControlHandleList controlHandles = null != getMagnets() ? getMagnets().getMagnets() : null;
    if ((null == controlHandles) || controlHandles.isEmpty()) {
        return;
    }
    final Direction[] cardinals = controlHandles.size() == 9 ? EIGHT_CARDINALS : FOUR_CARDINALS;
    final Point2DArray points = MagnetManager.getWiresIntersectionPoints(shape, cardinals);
    final int size = controlHandles.size() <= points.size() ? controlHandles.size() : points.size();
    for (int i = 0; i < size; i++) {
        final Point2D p = points.get(i);
        final WiresMagnet m = (WiresMagnet) controlHandles.getHandle(i);
        m.setRx(p.getX()).setRy(p.getY());
    }
    shapeMoved();
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) Point2D(com.ait.lienzo.client.core.types.Point2D) WiresMagnet(com.ait.lienzo.client.core.shape.wires.WiresMagnet) Direction(com.ait.lienzo.shared.core.types.Direction) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList)

Aggregations

IControlHandleList (com.ait.lienzo.client.core.shape.wires.IControlHandleList)6 Point2D (com.ait.lienzo.client.core.types.Point2D)4 IControlHandle (com.ait.lienzo.client.core.shape.wires.IControlHandle)3 WiresMagnet (com.ait.lienzo.client.core.shape.wires.WiresMagnet)3 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)3 IPrimitive (com.ait.lienzo.client.core.shape.IPrimitive)1 Shape (com.ait.lienzo.client.core.shape.Shape)1 ControlHandleList (com.ait.lienzo.client.core.shape.wires.ControlHandleList)1 MagnetManager (com.ait.lienzo.client.core.shape.wires.MagnetManager)1 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)1 Direction (com.ait.lienzo.shared.core.types.Direction)1 NFastDoubleArray (com.ait.tooling.nativetools.client.collection.NFastDoubleArray)1 Test (org.junit.Test)1 MagnetConnection (org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection)1