use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.
the class TestPSTShape method testFreeHandPointsCurves.
@Test
public void testFreeHandPointsCurves() {
final Freehand fh = ShapeFactory.INST.createFreeHand(Arrays.asList(ShapeFactory.INST.createPoint(50d, 70d), ShapeFactory.INST.createPoint(100d, 90d), ShapeFactory.INST.createPoint(110d, 100d), ShapeFactory.INST.createPoint(150d, 180d)));
fh.setInterval(1);
fh.setType(FreeHandStyle.CURVES);
final Shape s2 = produceOutputShapeFrom(fh);
assertThat(s2.getPoints()).isEqualTo(Arrays.asList(ShapeFactory.INST.createPoint(50d, 70d), ShapeFactory.INST.createPoint(75d, 80d), ShapeFactory.INST.createPoint(105d, 95d), ShapeFactory.INST.createPoint(130d, 140d)));
}
use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.
the class ShapeFactoryImpl method createFreeHandFrom.
@Override
@NotNull
public Freehand createFreeHandFrom(final Freehand 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 Freehand copy = createFreeHand(pts);
copy.copy(sh);
return copy;
}
use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.
the class TestCanvasCreation method testDrawFreeHand.
@Test
public void testDrawFreeHand() {
final Point2D pos = point(canvas).query();
Cmds.of(CmdFXVoid.of(() -> editing.setCurrentChoice(EditionChoice.FREE_HAND)), CmdFXVoid.of(() -> editing.getGroupParams().setInterval(1)), () -> drag(pos, MouseButton.PRIMARY).dropBy(100d, 200d)).execute();
assertEquals(1, drawing.size());
assertTrue(drawing.getShapeAt(0).orElseThrow() instanceof Freehand);
assertEquals(100d, drawing.getShapeAt(0).orElseThrow().getWidth(), 1d);
assertEquals(200d, drawing.getShapeAt(0).orElseThrow().getHeight(), 1d);
assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getX(), drawing.getShapeAt(0).orElseThrow().getTopLeftPoint().getX(), 1d);
assertEquals(-Canvas.getMargins() + canvas.screenToLocal(pos).getY(), drawing.getShapeAt(0).orElseThrow().getTopLeftPoint().getY(), 1d);
}
use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.
the class PolymorphFreeHandTest method testFreeHandType.
@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#createDiversifiedFreeHand")
default void testFreeHandType(final Freehand sh) {
final Freehand s2 = produceOutputShapeFrom(sh);
assertEquals(sh.getType(), s2.getType());
}
use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.
the class TestPSTShape method testFreeHandPointsLines.
@Test
public void testFreeHandPointsLines() {
final Freehand fh = ShapeFactory.INST.createFreeHand(Arrays.asList(ShapeFactory.INST.createPoint(50d, 70d), ShapeFactory.INST.createPoint(100d, 90d), ShapeFactory.INST.createPoint(132d, 112d), ShapeFactory.INST.createPoint(150d, 180d)));
fh.setInterval(1);
fh.setType(FreeHandStyle.LINES);
final Shape s2 = produceOutputShapeFrom(fh);
assertThat(s2.getPoints()).isEqualTo(produceOutputShapeFrom(s2).getPoints());
}
Aggregations