Search in sources :

Example 1 with Freehand

use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.

the class FreehandImpl method duplicate.

@Override
@NotNull
public Freehand duplicate() {
    final Freehand dup = ShapeFactory.INST.createFreeHand(points.stream().map(pt -> ShapeFactory.INST.createPoint(pt.getX(), pt.getY())).collect(Collectors.toList()));
    dup.copy(this);
    return dup;
}
Also used : Freehand(net.sf.latexdraw.model.api.shape.Freehand) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Freehand

use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.

the class TestParsingPscustom method testPsCustomMovetoCurveto.

@Test
public void testPsCustomMovetoCurveto() {
    parser("\\pscustom[linewidth=10cm]{\\moveto(1,2)\\curveto(3.1,4.1)(3.2,4.3)(3,4)}");
    final Freehand fh = getShapeAt(0);
    assertEquals(2, fh.getNbPoints());
    assertEquals(1d * Shape.PPC, fh.getPtAt(0).getX(), 0.001);
    assertEquals(-2d * Shape.PPC, fh.getPtAt(0).getY(), 0.001);
    assertEquals(3d * Shape.PPC, fh.getPtAt(1).getX(), 0.001);
    assertEquals(-4d * Shape.PPC, fh.getPtAt(1).getY(), 0.001);
    assertEquals(FreeHandStyle.CURVES, fh.getType());
}
Also used : Freehand(net.sf.latexdraw.model.api.shape.Freehand) Test(org.junit.jupiter.api.Test)

Example 3 with Freehand

use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.

the class TestFreehand method testDuplicate.

@Test
public void testDuplicate() {
    shape.setOpened(!shape.isOpened());
    shape.setInterval(shape.getInterval() * 2);
    shape.setType(FreeHandStyle.LINES);
    final Freehand dup = shape.duplicate();
    assertEquals(shape.isOpened(), dup.isOpened());
    assertEquals(shape.getInterval(), dup.getInterval());
    assertEquals(FreeHandStyle.LINES, dup.getType());
}
Also used : Freehand(net.sf.latexdraw.model.api.shape.Freehand) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 4 with Freehand

use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.

the class PolymorphFreeHandTest method testFreeHandInterval.

@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#createDiversifiedFreeHand")
default void testFreeHandInterval(final Freehand sh) {
    final Freehand s2 = produceOutputShapeFrom(sh);
    assertEquals(sh.getInterval(), s2.getInterval());
}
Also used : Freehand(net.sf.latexdraw.model.api.shape.Freehand) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with Freehand

use of net.sf.latexdraw.model.api.shape.Freehand in project latexdraw by arnobl.

the class TestPSTFreeHand method testFreeHandInterval.

@Override
@ParameterizedTest
@MethodSource("net.sf.latexdraw.data.ShapeSupplier#createDiversifiedFreeHand")
@Disabled
public void testFreeHandInterval(final Freehand sh) {
    // PST import cannot determine the interval.
    final Freehand s2 = produceOutputShapeFrom(sh);
    assertEquals(sh.getNbPoints(), s2.getNbPoints());
}
Also used : Freehand(net.sf.latexdraw.model.api.shape.Freehand) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

Freehand (net.sf.latexdraw.model.api.shape.Freehand)16 Test (org.junit.jupiter.api.Test)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 Shape (net.sf.latexdraw.model.api.shape.Shape)3 BezierCurve (net.sf.latexdraw.model.api.shape.BezierCurve)2 Point (net.sf.latexdraw.model.api.shape.Point)2 Polygon (net.sf.latexdraw.model.api.shape.Polygon)2 Polyline (net.sf.latexdraw.model.api.shape.Polyline)2 NotNull (org.jetbrains.annotations.NotNull)2 Test (org.junit.Test)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 Click (io.github.interacto.jfx.interaction.library.Click)1 DnD (io.github.interacto.jfx.interaction.library.DnD)1 MultiClick (io.github.interacto.jfx.interaction.library.MultiClick)1 PointsData (io.github.interacto.jfx.interaction.library.PointsData)1 Press (io.github.interacto.jfx.interaction.library.Press)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Objects (java.util.Objects)1 Function (java.util.function.Function)1