Search in sources :

Example 1 with IControlHandleList

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

the class WiresConnectorControlImpl method onMoveStart.

@Override
public void onMoveStart(final double x, final double y) {
    final IControlHandleList handles = m_connector.getPointHandles();
    m_startPoints = new NFastDoubleArray();
    for (int i = 0; i < handles.size(); i++) {
        final IControlHandle h = handles.getHandle(i);
        final IPrimitive<?> prim = h.getControl();
        m_startPoints.push(prim.getX());
        m_startPoints.push(prim.getY());
    }
}
Also used : NFastDoubleArray(com.ait.tooling.nativetools.client.collection.NFastDoubleArray) IControlHandle(com.ait.lienzo.client.core.shape.wires.IControlHandle) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList)

Example 2 with IControlHandleList

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

the class WiresConnectorControlImpl method reset.

/*
     ***************** CONTROL POINTS **********************************
     */
@Override
public void reset() {
    if (null != m_startPoints) {
        final IControlHandleList handles = m_connector.getPointHandles();
        final Point2DArray points = m_connector.getLine().getPoint2DArray();
        for (int i = 0, j = 0; i < handles.size(); i++, j += 2) {
            final double px = m_startPoints.get(j);
            final double py = m_startPoints.get(j + 1);
            final IControlHandle h = handles.getHandle(i);
            final IPrimitive<?> prim = h.getControl();
            prim.setX(px);
            prim.setY(py);
            final Point2D point = points.get(i);
            point.setX(px);
            point.setY(py);
        }
    }
    m_connector.getLine().refresh();
    m_wiresManager.getLayer().getLayer().batch();
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) Point2D(com.ait.lienzo.client.core.types.Point2D) IControlHandle(com.ait.lienzo.client.core.shape.wires.IControlHandle) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList)

Example 3 with IControlHandleList

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

the class WiresMagnetsControlImpl method shapeMoved.

private void shapeMoved(final double x, final double y) {
    if (null != getMagnets()) {
        final IControlHandleList controlHandles = getMagnets().getMagnets();
        for (int i = 0; i < controlHandles.size(); i++) {
            final WiresMagnet m = (WiresMagnet) controlHandles.getHandle(i);
            m.shapeMoved(x, y);
        }
    }
}
Also used : WiresMagnet(com.ait.lienzo.client.core.shape.wires.WiresMagnet) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList)

Example 4 with IControlHandleList

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

the class WiresConnectorControlImpl method move.

/**
 * See class javadocs to explain why we have these booleans
 */
@Override
public void move(final double dx, final double dy, final boolean midPointsOnly, final boolean moveLinePoints) {
    final IControlHandleList handles = m_connector.getPointHandles();
    int start = 0;
    int end = handles.size();
    if (midPointsOnly) {
        if (m_connector.getHeadConnection().getMagnet() != null) {
            start++;
        }
        if (m_connector.getTailConnection().getMagnet() != null) {
            end--;
        }
    }
    final Point2DArray points = m_connector.getLine().getPoint2DArray();
    for (int i = start, j = (start == 0) ? start : 2; i < end; i++, j += 2) {
        if (moveLinePoints) {
            final Point2D p = points.get(i);
            p.setX(m_startPoints.get(j) + dx);
            p.setY(m_startPoints.get(j + 1) + dy);
        }
        final IControlHandle h = handles.getHandle(i);
        final IPrimitive<?> prim = h.getControl();
        prim.setX(m_startPoints.get(j) + dx);
        prim.setY(m_startPoints.get(j + 1) + dy);
    }
    if (moveLinePoints) {
        m_connector.getLine().refresh();
    }
    m_wiresManager.getLayer().getLayer().batch();
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) Point2D(com.ait.lienzo.client.core.types.Point2D) IControlHandle(com.ait.lienzo.client.core.shape.wires.IControlHandle) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList)

Example 5 with IControlHandleList

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

the class DecisionServiceSVGShapeViewTest method testShapeControlResizeHandles.

@Test
public void testShapeControlResizeHandles() {
    final IControlHandleFactory controlHandleFactory = view.getPath().getControlHandleFactory();
    final IControlHandleList controlHandles = controlHandleFactory.getControlHandles(Collections.singletonList(RESIZE)).get(RESIZE);
    assertThat(controlHandles.size()).isGreaterThan(0);
    assertThat(controlHandles).areExactly(1, new Condition<>(ch -> ch instanceof MoveDividerControlHandle, "Is a MoveDividerControlHandle"));
}
Also used : NodeDragStartEvent(com.ait.lienzo.client.core.event.NodeDragStartEvent) WiresResizeStepEvent(com.ait.lienzo.client.core.shape.wires.event.WiresResizeStepEvent) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) NodeDragEndEvent(com.ait.lienzo.client.core.event.NodeDragEndEvent) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) Shape(com.ait.lienzo.client.core.shape.Shape) Attribute(com.ait.lienzo.client.core.Attribute) DragEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent) DragBounds(com.ait.lienzo.client.core.types.DragBounds) SVGPrimitiveShape(org.kie.workbench.common.stunner.svg.client.shape.view.SVGPrimitiveShape) Attributes(com.ait.lienzo.client.core.shape.Attributes) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) DragHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) HandlerManager(com.google.gwt.event.shared.HandlerManager) StreamSupport(java.util.stream.StreamSupport) RESIZE(com.ait.lienzo.client.core.shape.wires.IControlHandle.ControlHandleStandardType.RESIZE) Node(com.ait.lienzo.client.core.shape.Node) Before(org.junit.Before) MoveDividerDragHandler(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerDragHandler) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) DragContext(com.ait.lienzo.client.widget.DragContext) IPrimitive(com.ait.lienzo.client.core.shape.IPrimitive) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Condition(org.assertj.core.api.Condition) Collections(java.util.Collections) MoveDividerControlHandle(org.kie.workbench.common.dmn.client.shape.view.decisionservice.DecisionServiceSVGShapeView.MoveDividerControlHandle) IControlHandleList(com.ait.lienzo.client.core.shape.wires.IControlHandleList) IControlHandleFactory(com.ait.lienzo.client.core.shape.wires.IControlHandleFactory) Test(org.junit.Test)

Aggregations

IControlHandleList (com.ait.lienzo.client.core.shape.wires.IControlHandleList)10 Point2D (com.ait.lienzo.client.core.types.Point2D)5 Test (org.junit.Test)5 IPrimitive (com.ait.lienzo.client.core.shape.IPrimitive)4 Shape (com.ait.lienzo.client.core.shape.Shape)4 Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)4 Attribute (com.ait.lienzo.client.core.Attribute)3 NodeDragEndEvent (com.ait.lienzo.client.core.event.NodeDragEndEvent)3 NodeDragMoveEvent (com.ait.lienzo.client.core.event.NodeDragMoveEvent)3 NodeDragStartEvent (com.ait.lienzo.client.core.event.NodeDragStartEvent)3 Attributes (com.ait.lienzo.client.core.shape.Attributes)3 Node (com.ait.lienzo.client.core.shape.Node)3 IControlHandle (com.ait.lienzo.client.core.shape.wires.IControlHandle)3 RESIZE (com.ait.lienzo.client.core.shape.wires.IControlHandle.ControlHandleStandardType.RESIZE)3 IControlHandleFactory (com.ait.lienzo.client.core.shape.wires.IControlHandleFactory)3 WiresMagnet (com.ait.lienzo.client.core.shape.wires.WiresMagnet)3 WiresResizeStepEvent (com.ait.lienzo.client.core.shape.wires.event.WiresResizeStepEvent)3 DragBounds (com.ait.lienzo.client.core.types.DragBounds)3 DragContext (com.ait.lienzo.client.widget.DragContext)3 LienzoMockitoTestRunner (com.ait.lienzo.test.LienzoMockitoTestRunner)3