use of com.ait.lienzo.client.core.types.Point2DArray in project kie-wb-common by kiegroup.
the class PolygonView method create.
// TODO: If cornerRadius > 0 -> bug.
private static MultiPath create(final MultiPath result, final int sides, final double radius, final double cornerRadius) {
final double ix = radius;
final double iy = radius;
if ((sides > 2) && (radius > 0)) {
result.M(ix, iy - radius);
if (cornerRadius <= 0) {
for (int n = 1; n < sides; n++) {
final double theta = (n * 2 * Math.PI / sides);
result.L(ix + (radius * Math.sin(theta)), iy + (-1 * radius * Math.cos(theta)));
}
result.Z();
} else {
final Point2DArray list = new Point2DArray(ix, iy - radius);
for (int n = 1; n < sides; n++) {
final double theta = (n * 2 * Math.PI / sides);
list.push(ix + (radius * Math.sin(theta)), iy + (-1 * radius * Math.cos(theta)));
}
Geometry.drawArcJoinedLines(result.getPathPartList(), list.push(ix, iy - radius), cornerRadius);
}
}
return result;
}
use of com.ait.lienzo.client.core.types.Point2DArray in project kie-wb-common by kiegroup.
the class WiresConnectorViewTest method testGetControlPoints.
@Test
@SuppressWarnings("unchecked")
public void testGetControlPoints() {
Point2DArray linePoints = new Point2DArray(new Point2D(0, 0), new Point2D(0.1, 0.2), new Point2D(0.3, 0.4), new Point2D(0.5, 0.6), new Point2D(1, 2));
when(line.getPoint2DArray()).thenReturn(linePoints);
ControlPoint[] controlPoints = tested.getManageableControlPoints();
assertNotNull(controlPoints);
assertEquals(3, controlPoints.length);
ControlPoint controlPoint0 = controlPoints[0];
assertNotNull(controlPoint0);
assertNotNull(controlPoint0.getLocation());
assertEquals(0.1d, controlPoint0.getLocation().getX(), 0d);
assertEquals(0.2d, controlPoint0.getLocation().getY(), 0d);
ControlPoint controlPoint1 = controlPoints[1];
assertNotNull(controlPoint1);
assertNotNull(controlPoint1.getLocation());
assertEquals(0.3d, controlPoint1.getLocation().getX(), 0d);
assertEquals(0.4d, controlPoint1.getLocation().getY(), 0d);
ControlPoint controlPoint2 = controlPoints[2];
assertNotNull(controlPoint2);
assertNotNull(controlPoint2.getLocation());
assertEquals(0.5d, controlPoint2.getLocation().getX(), 0d);
assertEquals(0.6d, controlPoint2.getLocation().getY(), 0d);
}
use of com.ait.lienzo.client.core.types.Point2DArray in project kie-wb-common by kiegroup.
the class WiresConnectorViewTest method testUpdateControlPoint.
@Test
@SuppressWarnings("unchecked")
public void testUpdateControlPoint() {
Point2D p = new Point2D(0.1, 0.2);
Point2DArray cps = new Point2DArray(new Point2D(0, 0), p, new Point2D(1, 2));
when(line.getPoint2DArray()).thenReturn(cps);
IControlHandleList pointHandles = mock(IControlHandleList.class);
when(pointHandles.isEmpty()).thenReturn(false);
when(pointHandles.size()).thenReturn(1);
tested.setPointHandles(pointHandles);
tested.updateControlPoints(new ControlPoint[] { ControlPoint.build(0.5, 0.5) });
assertEquals(0.5, p.getX(), 0d);
assertEquals(0.5, p.getY(), 0d);
}
Aggregations