use of net.sf.latexdraw.model.api.shape.Polygon in project latexdraw by arnobl.
the class TestPolygon method testConstructor.
@Test
public void testConstructor() {
final Point pt1 = ShapeFactory.INST.createPoint(1, 1);
final Point pt2 = ShapeFactory.INST.createPoint(2, 2);
final Polygon pol = ShapeFactory.INST.createPolygon(Arrays.asList(pt1, pt2));
assertEquals(pt1, pol.getPtAt(0));
assertEquals(pt2, pol.getPtAt(-1));
}
use of net.sf.latexdraw.model.api.shape.Polygon in project latexdraw by arnobl.
the class TestPSTShape method testLoadRotationAngleParams.
@Override
@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#getDiversifiedShapes")
public void testLoadRotationAngleParams(final Shape sh) {
assumeFalse(sh instanceof Polygon || sh instanceof BezierCurve);
final Shape s2 = produceOutputShapeFrom(sh);
CompareShapeMatcher.INST.assertEqualShapeRotationAngle(sh, s2);
}
use of net.sf.latexdraw.model.api.shape.Polygon in project latexdraw by arnobl.
the class ShapeFactoryImpl method createPolygonFrom.
@Override
@NotNull
public Polygon createPolygonFrom(final Polygon sh, final Point pointToAdd) {
if (sh == null || !MathUtils.INST.isValidPt(pointToAdd)) {
throw new IllegalArgumentException();
}
final List<Point> pts = new ArrayList<>(sh.getPoints());
pts.add(pointToAdd);
final Polygon copy = createPolygon(pts);
copy.copy(sh);
return copy;
}
use of net.sf.latexdraw.model.api.shape.Polygon in project latexdraw by arnobl.
the class TestCanvasCreation method testDrawPolygon.
@Test
public void testDrawPolygon() {
final Point2D pos = point(canvas).query();
Cmds.of(CmdFXVoid.of(() -> editing.setCurrentChoice(EditionChoice.POLYGON)), () -> moveTo(pos).clickOn(MouseButton.PRIMARY).moveBy(-20d, -100d).clickOn(MouseButton.PRIMARY).moveBy(-100d, 50d).clickOn(MouseButton.SECONDARY)).execute();
assertEquals(1, drawing.size());
assertTrue(drawing.getShapeAt(0).orElseThrow() instanceof Polygon);
final Polygon sh = (Polygon) drawing.getShapeAt(0).orElseThrow();
assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getX(), sh.getPtAt(0).getX(), 1d);
assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getY(), sh.getPtAt(0).getY(), 1d);
assertEquals(3, sh.getNbPoints());
}
use of net.sf.latexdraw.model.api.shape.Polygon in project latexdraw by arnobl.
the class PlotViewComputation method updatePolygon.
default Polygon updatePolygon(final Plot shape, final double posX, final double posY, final double minX, final double maxX, final double step) {
final Polygon pg = ShapeFactory.INST.createPolygon(fillPoints(shape, posX, posY, minX, maxX, step));
pg.copy(shape);
return pg;
}
Aggregations