Search in sources :

Example 46 with Shape

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

the class TestParsingPscustom method testPsCustomMustConsiderParametersCommand.

@Test
public void testPsCustomMustConsiderParametersCommand() {
    parser("\\pscustom[linewidth=10cm]{\\moveto(1,2)\\lineto(3,4)\\lineto(4,4)}");
    final Shape sh = getShapeAt(0);
    assertEquals(10d * Shape.PPC, sh.getThickness(), 0.001);
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) Test(org.junit.jupiter.api.Test)

Example 47 with Shape

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

the class Pencil method bindDnDToDrawFreeHandShape.

/**
 * Binds a DnD interaction to create shape.
 */
private void bindDnDToDrawFreeHandShape() {
    nodeBinder().usingInteraction(() -> new DnD(false, true)).toProduce(i -> {
        final Shape sh = editing.createShapeInstance();
        final Point pt = getAdaptedPoint(i.getSrcLocalPoint());
        sh.getPoints().get(0).setPoint(pt.getX(), pt.getY());
        return new AddShape(sh, canvas.getDrawing());
    }).on(canvas).first((i, c) -> canvas.requestFocus()).then((i, c) -> {
        final Point last = c.getShape().getPtAt(-1);
        final Point endPt = getAdaptedPoint(i.getTgtLocalPoint());
        if (!MathUtils.INST.equalsDouble(last.getX(), endPt.getX(), 0.0001) && !MathUtils.INST.equalsDouble(last.getY(), endPt.getY(), 0.0001)) {
            c.setShape(ShapeFactory.INST.createFreeHandFrom((Freehand) c.getShape(), endPt));
        }
        canvas.setTempView(viewFactory.createView(c.getShape()).orElse(null));
    }).endOrCancel(i -> canvas.setTempView(null)).when(i -> i.getButton() == MouseButton.PRIMARY && editing.getCurrentChoice() == EditionChoice.FREE_HAND).strictStart().bind();
}
Also used : EditingService(net.sf.latexdraw.service.EditingService) Arrays(java.util.Arrays) MouseButton(javafx.scene.input.MouseButton) ControlPointShape(net.sf.latexdraw.model.api.shape.ControlPointShape) BezierCurve(net.sf.latexdraw.model.api.shape.BezierCurve) Freehand(net.sf.latexdraw.model.api.shape.Freehand) Point3D(javafx.geometry.Point3D) BorderPos(net.sf.latexdraw.model.api.shape.BorderPos) InsertPicture(net.sf.latexdraw.command.shape.InsertPicture) Function(java.util.function.Function) Polyline(net.sf.latexdraw.model.api.shape.Polyline) ShapeFactory(net.sf.latexdraw.model.ShapeFactory) Shape(net.sf.latexdraw.model.api.shape.Shape) Inject(net.sf.latexdraw.util.Inject) PointsData(io.github.interacto.jfx.interaction.library.PointsData) MathUtils(net.sf.latexdraw.model.MathUtils) AddShape(net.sf.latexdraw.command.shape.AddShape) Canvas(net.sf.latexdraw.view.jfx.Canvas) ViewFactory(net.sf.latexdraw.view.jfx.ViewFactory) Click(io.github.interacto.jfx.interaction.library.Click) InitTextSetter(net.sf.latexdraw.command.shape.InitTextSetter) MultiClick(io.github.interacto.jfx.interaction.library.MultiClick) ModifiablePointsShape(net.sf.latexdraw.model.api.shape.ModifiablePointsShape) Polygon(net.sf.latexdraw.model.api.shape.Polygon) Press(io.github.interacto.jfx.interaction.library.Press) PositionShape(net.sf.latexdraw.model.api.shape.PositionShape) Point(net.sf.latexdraw.model.api.shape.Point) MagneticGrid(net.sf.latexdraw.view.jfx.MagneticGrid) Objects(java.util.Objects) FileChooser(javafx.stage.FileChooser) SquaredShape(net.sf.latexdraw.model.api.shape.SquaredShape) RectangularShape(net.sf.latexdraw.model.api.shape.RectangularShape) NotNull(org.jetbrains.annotations.NotNull) DnD(io.github.interacto.jfx.interaction.library.DnD) AddShape(net.sf.latexdraw.command.shape.AddShape) ControlPointShape(net.sf.latexdraw.model.api.shape.ControlPointShape) Shape(net.sf.latexdraw.model.api.shape.Shape) AddShape(net.sf.latexdraw.command.shape.AddShape) ModifiablePointsShape(net.sf.latexdraw.model.api.shape.ModifiablePointsShape) PositionShape(net.sf.latexdraw.model.api.shape.PositionShape) SquaredShape(net.sf.latexdraw.model.api.shape.SquaredShape) RectangularShape(net.sf.latexdraw.model.api.shape.RectangularShape) Freehand(net.sf.latexdraw.model.api.shape.Freehand) DnD(io.github.interacto.jfx.interaction.library.DnD) Point(net.sf.latexdraw.model.api.shape.Point)

Example 48 with Shape

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

the class TestGroup method init4setFill.

private void init4setFill() {
    final Axes sh2 = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
    final Shape sh1 = ShapeFactory.INST.createRectangle();
    final Shape sh1b = ShapeFactory.INST.createRectangle();
    shape.getShapes().add(sh2);
    shape.getShapes().add(sh1);
    shape.getShapes().add(sh1b);
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) Axes(net.sf.latexdraw.model.api.shape.Axes)

Example 49 with Shape

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

the class TestGroup method init4getAxes.

private Axes init4getAxes() {
    final Shape sh1 = ShapeFactory.INST.createRectangle();
    final Axes sh2 = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
    final Axes sh3 = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
    shape.getShapes().add(sh1);
    shape.getShapes().add(sh2);
    shape.getShapes().add(sh3);
    return sh2;
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) Axes(net.sf.latexdraw.model.api.shape.Axes)

Example 50 with Shape

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

the class TestGroup method init4setAxes.

private void init4setAxes() {
    final Shape sh1 = ShapeFactory.INST.createRectangle();
    final Axes sh2 = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
    final Shape sh1b = ShapeFactory.INST.createRectangle();
    final Axes sh3 = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
    shape.getShapes().add(sh1);
    shape.getShapes().add(sh2);
    shape.getShapes().add(sh1b);
    shape.getShapes().add(sh3);
}
Also used : Shape(net.sf.latexdraw.model.api.shape.Shape) Axes(net.sf.latexdraw.model.api.shape.Axes)

Aggregations

Shape (net.sf.latexdraw.model.api.shape.Shape)75 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)43 MethodSource (org.junit.jupiter.params.provider.MethodSource)41 Test (org.junit.Test)12 Point (net.sf.latexdraw.model.api.shape.Point)8 PositionShape (net.sf.latexdraw.model.api.shape.PositionShape)7 HelperTest (net.sf.latexdraw.HelperTest)6 ShapeFactory (net.sf.latexdraw.model.ShapeFactory)6 Circle (net.sf.latexdraw.model.api.shape.Circle)6 RectangularShape (net.sf.latexdraw.model.api.shape.RectangularShape)6 NotNull (org.jetbrains.annotations.NotNull)6 Click (io.github.interacto.jfx.interaction.library.Click)5 ArrayList (java.util.ArrayList)5 Objects (java.util.Objects)5 MathUtils (net.sf.latexdraw.model.MathUtils)5 Rectangle (net.sf.latexdraw.model.api.shape.Rectangle)5 Inject (net.sf.latexdraw.util.Inject)5 CommandsRegistry (io.github.interacto.command.CommandsRegistry)3 Redo (io.github.interacto.command.library.Redo)3 Undo (io.github.interacto.command.library.Undo)3