Search in sources :

Example 51 with Point2DArray

use of com.ait.lienzo.client.core.types.Point2DArray in project lienzo-core by ahome-it.

the class Triangle method parse.

private boolean parse(final Attributes attr) {
    final Point2DArray list = attr.getPoints().noAdjacentPoints();
    if ((null != list) && (list.size() > 2)) {
        final Point2D p0 = list.get(0);
        m_list.M(p0);
        final double corner = getCornerRadius();
        if (corner <= 0) {
            m_list.L(list.get(1));
            m_list.L(list.get(2));
            m_list.Z();
        } else {
            Geometry.drawArcJoinedLines(m_list, list.push(p0), corner);
        }
        return true;
    }
    return false;
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) Point2D(com.ait.lienzo.client.core.types.Point2D)

Example 52 with Point2DArray

use of com.ait.lienzo.client.core.types.Point2DArray in project lienzo-core by ahome-it.

the class AbstractMultiPathPartShape method prepare.

@Override
protected boolean prepare(final Context2D context, final Attributes attr, final double alpha) {
    final double radius = getCornerRadius();
    if (radius != 0) {
        m_cornerPoints = new NFastArrayList<>();
        for (int i = 0; i < m_points.size(); i++) {
            final PathPartList baseList = m_points.get(i);
            final Point2DArray basePoints = baseList.getPoints();
            final PathPartList cornerList = new PathPartList();
            Geometry.drawArcJoinedLines(cornerList, baseList, basePoints, radius);
            m_cornerPoints.add(cornerList);
        }
    }
    if (false == validSizeConstraints()) {
        throw new IllegalArgumentException("Constraints are either smaller or larger than size.");
    }
    return true;
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) PathPartList(com.ait.lienzo.client.core.types.PathPartList)

Example 53 with Point2DArray

use of com.ait.lienzo.client.core.types.Point2DArray in project kie-wb-common by kiegroup.

the class LogSelectedEdgeDevCommand method logEdge.

private void logEdge(final Edge<? extends View<?>, Node> edge) {
    StunnerLogger.log(edge);
    if (edge.getContent() instanceof HasControlPoints) {
        final ControlPoint[] controlPoints = ((HasControlPoints) edge.getContent()).getControlPoints();
        String s = "*** CPS = ";
        if (null != controlPoints) {
            for (ControlPoint cp : controlPoints) {
                s += " [" + format(cp.getLocation()) + "] ";
            }
            s += " *** ";
        } else {
            s += " [Empty] ";
        }
        log(s);
        String s1 = "*** CPS[Lienzo] = ";
        final Shape shape = getCanvasHandler().getCanvas().getShape(edge.getUUID());
        final WiresConnectorView connectorView = (WiresConnectorView) shape.getShapeView();
        final Point2DArray controlPoints1 = connectorView.getControlPoints();
        if (null != controlPoints1) {
            for (com.ait.lienzo.client.core.types.Point2D point2D : controlPoints1) {
                s1 += " [" + point2D.getX() + "," + point2D.getY() + "] ";
            }
            s1 += " *** ";
        } else {
            s1 += " [Empty] ";
        }
        log(s1);
    }
}
Also used : HasControlPoints(org.kie.workbench.common.stunner.core.graph.content.HasControlPoints) Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) WiresConnectorView(org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresConnectorView) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint)

Example 54 with Point2DArray

use of com.ait.lienzo.client.core.types.Point2DArray in project kie-wb-common by kiegroup.

the class DirectionalLineTest method testSkipParse.

@Test
public void testSkipParse() throws Exception {
    final Attributes attr = mock(Attributes.class);
    final Point2DArray points = new Point2DArray();
    when(attr.getControlPoints()).thenReturn(points);
    final boolean parsed = tested.parse(attr);
    assertFalse(parsed);
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) Attributes(com.ait.lienzo.client.core.shape.Attributes) Test(org.junit.Test)

Example 55 with Point2DArray

use of com.ait.lienzo.client.core.types.Point2DArray in project kie-wb-common by kiegroup.

the class WiresConnectorViewExtTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    HEAD_DECORATOR = new MultiPathDecorator(new MultiPath().rect(0, 0, 10, 10));
    TAIL_DECORATOR = new MultiPathDecorator(new MultiPath().rect(0, 0, 10, 10));
    POINTS = new Point2DArray(new Point2D(0, 10), new Point2D(10, 10), new Point2D(20, 20), new Point2D(30, 30), new Point2D(40, 40));
    line = new PolyLine(POINTS);
    layer = spy(new Layer());
    doAnswer(invocation -> {
        ((Consumer) invocation.getArguments()[0]).accept(labelText);
        return label;
    }).when(label).configure(any(Consumer.class));
    tested = spy(new WiresConnectorViewExt(ShapeViewSupportedEvents.DESKTOP_CONNECTOR_EVENT_TYPES, line, HEAD_DECORATOR, TAIL_DECORATOR) {

        @Override
        protected Optional<WiresConnectorLabel> createLabel(String title) {
            return Optional.of(WiresConnectorViewExtTest.this.label);
        }
    });
    tested.setControl(connectorControl);
    layer.add(tested.getGroup());
}
Also used : Point2DArray(com.ait.lienzo.client.core.types.Point2DArray) MultiPath(com.ait.lienzo.client.core.shape.MultiPath) WiresConnectorLabel(com.ait.lienzo.client.core.shape.wires.util.WiresConnectorLabel) Consumer(com.ait.tooling.common.api.java.util.function.Consumer) Point2D(com.ait.lienzo.client.core.types.Point2D) MultiPathDecorator(com.ait.lienzo.client.core.shape.MultiPathDecorator) PolyLine(com.ait.lienzo.client.core.shape.PolyLine) Layer(com.ait.lienzo.client.core.shape.Layer) Before(org.junit.Before)

Aggregations

Point2DArray (com.ait.lienzo.client.core.types.Point2DArray)58 Point2D (com.ait.lienzo.client.core.types.Point2D)44 Test (org.junit.Test)11 BoundingBox (com.ait.lienzo.client.core.types.BoundingBox)7 HashSet (java.util.HashSet)6 ControlPoint (org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint)6 Set (java.util.Set)5 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)4 IControlHandleList (com.ait.lienzo.client.core.shape.wires.IControlHandleList)4 Direction (com.ait.lienzo.shared.core.types.Direction)4 Attributes (com.ait.lienzo.client.core.shape.Attributes)3 IControlHandle (com.ait.lienzo.client.core.shape.wires.IControlHandle)3 WiresMagnet (com.ait.lienzo.client.core.shape.wires.WiresMagnet)3 PathPartList (com.ait.lienzo.client.core.types.PathPartList)3 Group (com.ait.lienzo.client.core.shape.Group)2 WiresConnection (com.ait.lienzo.client.core.shape.wires.WiresConnection)2 WiresConnector (com.ait.lienzo.client.core.shape.wires.WiresConnector)2 DashArray (com.ait.lienzo.client.core.types.DashArray)2 Transform (com.ait.lienzo.client.core.types.Transform)2 NFastArrayList (com.ait.tooling.nativetools.client.collection.NFastArrayList)2