Search in sources :

Example 11 with Freehand

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

the class ModifyShapePropertyTest method commonCanDoFixture.

@Override
protected void commonCanDoFixture() {
    shapes = ShapeFactory.INST.createGroup();
    final Grid grid = ShapeFactory.INST.createGrid(ShapeFactory.INST.createPoint());
    final Axes axes = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
    final Dot dot = ShapeFactory.INST.createDot(ShapeFactory.INST.createPoint());
    final Circle circle = ShapeFactory.INST.createCircle();
    final Ellipse ell = ShapeFactory.INST.createEllipse();
    final Text txt = ShapeFactory.INST.createText();
    final BezierCurve bc = ShapeFactory.INST.createBezierCurve(Collections.emptyList());
    final Polyline pl = ShapeFactory.INST.createPolyline(Collections.emptyList());
    final Polygon pg = ShapeFactory.INST.createPolygon(Collections.emptyList());
    final Triangle tr = ShapeFactory.INST.createTriangle();
    final Rhombus rh = ShapeFactory.INST.createRhombus();
    final Rectangle r1 = ShapeFactory.INST.createRectangle();
    final Plot plot = ShapeFactory.INST.createPlot(ShapeFactory.INST.createPoint(), 0d, 1d, "x", false);
    final CircleArc carc = ShapeFactory.INST.createCircleArc();
    final Square sq = ShapeFactory.INST.createSquare();
    final Freehand fh = ShapeFactory.INST.createFreeHand(Collections.emptyList());
    r1.setLineStyle(LineStyle.DASHED);
    r1.setBordersPosition(BorderPos.INTO);
    r1.setFillingStyle(FillingStyle.PLAIN);
    r1.setThickness(2.3);
    r1.setHasDbleBord(true);
    r1.setLineArc(0.2);
    r1.setDbleBordSep(1.3);
    r1.setHatchingsAngle(0.33);
    r1.setHatchingsSep(9.1);
    r1.setHatchingsWidth(12.11);
    r1.setShadowAngle(0.1);
    r1.setGradMidPt(0.66);
    r1.setHatchingsCol(DviPsColors.CYAN);
    r1.setLineColour(DviPsColors.NAVYBLUE);
    r1.setShadowSize(87.2);
    r1.setFillingCol(DviPsColors.CARNATIONPINK);
    r1.setShadowCol(DviPsColors.CORNFLOWERBLUE);
    r1.setDashSepBlack(1.2);
    r1.setDashSepWhite(2.1);
    r1.setDotSep(23.1);
    r1.setGradAngle(1.3);
    r1.setDbleBordCol(DviPsColors.RED);
    r1.setGradColEnd(DviPsColors.BITTERSWEET);
    r1.setGradColStart(DviPsColors.FORESTGREEN);
    r1.setShowPts(true);
    final Rectangle r2 = ShapeFactory.INST.createRectangle();
    r2.setLineStyle(LineStyle.SOLID);
    r2.setBordersPosition(BorderPos.MID);
    r2.setFillingStyle(FillingStyle.HLINES);
    r2.setThickness(6.3);
    r2.setHasShadow(true);
    r2.setLineArc(0.33);
    r2.setDbleBordSep(2.3);
    r2.setHatchingsAngle(-0.53);
    r2.setHatchingsSep(1.1);
    r2.setHatchingsWidth(2.11);
    r2.setShadowAngle(-0.1);
    r2.setGradMidPt(0.31);
    r2.setHatchingsCol(DviPsColors.APRICOT);
    r2.setLineColour(DviPsColors.YELLOW);
    r2.setShadowSize(8.1);
    r2.setFillingCol(DviPsColors.CERULEAN);
    r2.setShadowCol(DviPsColors.DARKORCHID);
    r1.setDashSepBlack(11.2);
    r1.setDashSepWhite(21.1);
    r1.setDotSep(231.1);
    r1.setGradAngle(11.3);
    r1.setDbleBordCol(DviPsColors.ROYALBLUE);
    r1.setGradColEnd(DviPsColors.CADETBLUE);
    r1.setGradColStart(DviPsColors.OLIVE);
    dot.setDotStyle(DotStyle.DIAMOND);
    txt.copy(r1);
    ell.copy(r1);
    circle.copy(r2);
    dot.copy(r2);
    bc.copy(r2);
    pl.copy(r1);
    pg.copy(r2);
    tr.copy(r1);
    rh.copy(r2);
    plot.copy(r1);
    carc.copy(r2);
    sq.copy(r1);
    fh.copy(r2);
    sq.setFillingStyle(FillingStyle.GRAD);
    shapes.addShape(r1);
    shapes.addShape(txt);
    shapes.addShape(grid);
    shapes.addShape(pl);
    shapes.addShape(pg);
    shapes.addShape(r2);
    shapes.addShape(axes);
    shapes.addShape(ell);
    shapes.addShape(circle);
    shapes.addShape(tr);
    shapes.addShape(rh);
    shapes.addShape(dot);
    shapes.addShape(bc);
    shapes.addShape(plot);
    shapes.addShape(carc);
    shapes.addShape(sq);
    shapes.addShape(fh);
}
Also used : Circle(net.sf.latexdraw.model.api.shape.Circle) Ellipse(net.sf.latexdraw.model.api.shape.Ellipse) Grid(net.sf.latexdraw.model.api.shape.Grid) Plot(net.sf.latexdraw.model.api.shape.Plot) Dot(net.sf.latexdraw.model.api.shape.Dot) Triangle(net.sf.latexdraw.model.api.shape.Triangle) Rectangle(net.sf.latexdraw.model.api.shape.Rectangle) Freehand(net.sf.latexdraw.model.api.shape.Freehand) Text(net.sf.latexdraw.model.api.shape.Text) Rhombus(net.sf.latexdraw.model.api.shape.Rhombus) Square(net.sf.latexdraw.model.api.shape.Square) Polyline(net.sf.latexdraw.model.api.shape.Polyline) CircleArc(net.sf.latexdraw.model.api.shape.CircleArc) Axes(net.sf.latexdraw.model.api.shape.Axes) BezierCurve(net.sf.latexdraw.model.api.shape.BezierCurve) Polygon(net.sf.latexdraw.model.api.shape.Polygon)

Example 12 with Freehand

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

the class TestParsingPscustom method testPsCustomFreeHandClose.

@Test
public void testPsCustomFreeHandClose() {
    parser("\\pscustom{\\moveto(0.0,2.64)\\lineto(0.19,2.82)\\curveto(0.285,2.91)(1.49,3.16)(2.6,3.32)" + "\\curveto(3.71,3.48)(5.625,3.205)(6.43,2.77)\\curveto(7.235,2.335)(8.07,1.135)(8.1,0.37)" + "\\curveto(8.13,-0.395)(7.64,-1.63)(7.12,-2.1)\\curveto(6.6,-2.57)(5.45,-3.18)(4.82,-3.32)\\closepath}");
    assertEquals(1, parsedShapes.size());
    final Freehand fh = getShapeAt(0);
    assertEquals(7, fh.getNbPoints());
    assertEquals(0d, fh.getPtAt(0).getX(), 0.001);
    assertEquals(-2.64 * Shape.PPC, fh.getPtAt(0).getY(), 0.001);
    assertEquals(0.19 * Shape.PPC, fh.getPtAt(1).getX(), 0.001);
    assertEquals(-2.82 * Shape.PPC, fh.getPtAt(1).getY(), 0.001);
    assertEquals(2.6 * Shape.PPC, fh.getPtAt(2).getX(), 0.001);
    assertEquals(-3.32 * Shape.PPC, fh.getPtAt(2).getY(), 0.001);
    assertEquals(6.43 * Shape.PPC, fh.getPtAt(3).getX(), 0.001);
    assertEquals(-2.77 * Shape.PPC, fh.getPtAt(3).getY(), 0.001);
    assertEquals(8.1 * Shape.PPC, fh.getPtAt(4).getX(), 0.001);
    assertEquals(-0.37 * Shape.PPC, fh.getPtAt(4).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 13 with Freehand

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

the class TestParsingPscustom method testPsCustomMovetoLineto.

@Test
public void testPsCustomMovetoLineto() {
    parser("\\pscustom[linewidth=10cm]{\\moveto(1,2)\\lineto(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.LINES, fh.getType());
}
Also used : Freehand(net.sf.latexdraw.model.api.shape.Freehand) Test(org.junit.jupiter.api.Test)

Example 14 with Freehand

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

the class TestParsingPscustom method testPsCustomFreeHandOpen.

@Test
public void testPsCustomFreeHandOpen() {
    parser("\\pscustom{\\moveto(0.0,2.64)\\lineto(0.19,2.82)\\curveto(0.285,2.91)(1.49,3.16)(2.6,3.32)" + "\\curveto(3.71,3.48)(5.625,3.205)(6.43,2.77)\\curveto(7.235,2.335)(8.07,1.135)(8.1,0.37)" + "\\curveto(8.13,-0.395)(7.64,-1.63)(7.12,-2.1)\\curveto(6.6,-2.57)(5.45,-3.18)(4.82,-3.32)}");
    assertEquals(1, parsedShapes.size());
    final Freehand fh = getShapeAt(0);
    assertEquals(7, fh.getNbPoints());
    assertEquals(0d, fh.getPtAt(0).getX(), 0.001);
    assertEquals(-2.64 * Shape.PPC, fh.getPtAt(0).getY(), 0.001);
    assertEquals(0.19 * Shape.PPC, fh.getPtAt(1).getX(), 0.001);
    assertEquals(-2.82 * Shape.PPC, fh.getPtAt(1).getY(), 0.001);
    assertEquals(2.6 * Shape.PPC, fh.getPtAt(2).getX(), 0.001);
    assertEquals(-3.32 * Shape.PPC, fh.getPtAt(2).getY(), 0.001);
    assertEquals(6.43 * Shape.PPC, fh.getPtAt(3).getX(), 0.001);
    assertEquals(-2.77 * Shape.PPC, fh.getPtAt(3).getY(), 0.001);
    assertEquals(8.1 * Shape.PPC, fh.getPtAt(4).getX(), 0.001);
    assertEquals(-0.37 * Shape.PPC, fh.getPtAt(4).getY(), 0.001);
    assertTrue(fh.isOpened());
    assertEquals(FreeHandStyle.CURVES, fh.getType());
}
Also used : Freehand(net.sf.latexdraw.model.api.shape.Freehand) Test(org.junit.jupiter.api.Test)

Example 15 with Freehand

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

the class TestParsingPscustom method testPsCustomMovetoCurvetoLineTo.

@Test
public void testPsCustomMovetoCurvetoLineTo() {
    parser("\\pscustom{\\moveto(1,2)\\curveto(3.1,4.1)(3.2,4.3)(3,4)\\lineto(5,6)}");
    assertEquals(1, parsedShapes.size());
    final Freehand fh = getShapeAt(0);
    assertEquals(3, 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(5d * Shape.PPC, fh.getPtAt(2).getX(), 0.001);
    assertEquals(-6d * Shape.PPC, fh.getPtAt(2).getY(), 0.001);
    assertEquals(FreeHandStyle.LINES, fh.getType());
}
Also used : Freehand(net.sf.latexdraw.model.api.shape.Freehand) Test(org.junit.jupiter.api.Test)

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