Search in sources :

Example 21 with Point

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

the class TestBorder method testScaleSRectangle.

@Test
public void testScaleSRectangle() {
    Cmds.of(addRec, selectAllShapes).execute();
    final double width = addedRec.getWidth();
    final double height = addedRec.getHeight();
    final Point bl = addedRec.getBottomLeftPoint();
    final CmdFXVoid trCmd = () -> bl.translate(0d, 50d);
    Cmds.of(trCmd, () -> drag(border.scaleHandlers.get(6)).dropBy(30d, 50d)).execute();
    assertEquals(width, addedRec.getWidth(), 0.001);
    assertEquals(height + 50d, addedRec.getHeight(), 3d);
    assertEquals(bl.getX(), addedRec.getBottomLeftPoint().getX(), 3d);
    assertEquals(bl.getY(), addedRec.getBottomLeftPoint().getY(), 3d);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Example 22 with Point

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

the class TestBorder method testScaleNERectangle.

@Test
public void testScaleNERectangle() {
    Cmds.of(addRec, selectAllShapes).execute();
    final double width = addedRec.getWidth();
    final double height = addedRec.getHeight();
    final Point tr = addedRec.getTopRightPoint();
    final CmdFXVoid trCmd = () -> tr.translate(50d, -40d);
    Cmds.of(trCmd, () -> drag(border.scaleHandlers.get(2)).dropBy(50d, -40d)).execute();
    assertEquals(width + 50d, addedRec.getWidth(), 3d);
    assertEquals(height + 40d, addedRec.getHeight(), 3d);
    assertEquals(tr.getX(), addedRec.getTopRightPoint().getX(), 3d);
    assertEquals(tr.getY(), addedRec.getTopRightPoint().getY(), 3d);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Example 23 with Point

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

the class TestBorder method testMovePtHandlerMovePt.

@Test
public void testMovePtHandlerMovePt() {
    Cmds.of(addLines, selectAllShapes).execute();
    final Point point = ShapeFactory.INST.createPoint(addedPolyline.getPtAt(1));
    point.translate(100d, 20d);
    Cmds.of(() -> drag(border.mvPtHandlers.get(1)).dropBy(100d, 20d)).execute();
    assertEquals(point.getX(), addedPolyline.getPtAt(1).getX(), 1d);
    assertEquals(point.getY(), addedPolyline.getPtAt(1).getY(), 1d);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Example 24 with Point

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

the class TestBorder method testScaleWRectangle.

@Test
public void testScaleWRectangle() {
    Cmds.of(addRec, selectAllShapes).execute();
    final double width = addedRec.getWidth();
    final double height = addedRec.getHeight();
    final Point tl = addedRec.getTopLeftPoint();
    final CmdFXVoid tr = () -> tl.translate(50d, 0d);
    Cmds.of(tr, () -> drag(border.scaleHandlers.get(3)).dropBy(50d, 10d)).execute();
    assertEquals(height, addedRec.getHeight(), 0.001);
    assertEquals(width - 50d, addedRec.getWidth(), 3d);
    assertEquals(tl.getX(), addedRec.getTopLeftPoint().getX(), 2d);
    assertEquals(tl.getY(), addedRec.getTopLeftPoint().getY(), 2d);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Example 25 with Point

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

the class TestBorder method testScaleSERectangle.

@Test
public void testScaleSERectangle() {
    Cmds.of(addRec, selectAllShapes).execute();
    final double width = addedRec.getWidth();
    final double height = addedRec.getHeight();
    final Point br = addedRec.getBottomRightPoint();
    final CmdFXVoid trCmd = () -> br.translate(-55d, 45d);
    Cmds.of(trCmd, () -> drag(border.scaleHandlers.get(7)).dropBy(-55d, 45d)).execute();
    assertEquals(width - 55d, addedRec.getWidth(), 3d);
    assertEquals(height + 45d, addedRec.getHeight(), 3d);
    assertEquals(br.getX(), addedRec.getBottomRightPoint().getX(), 3d);
    assertEquals(br.getY(), addedRec.getBottomRightPoint().getY(), 3d);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test)

Aggregations

Point (net.sf.latexdraw.model.api.shape.Point)139 Test (org.junit.Test)52 HelperTest (net.sf.latexdraw.HelperTest)27 Theory (org.junit.experimental.theories.Theory)23 NotNull (org.jetbrains.annotations.NotNull)19 Line (net.sf.latexdraw.model.api.shape.Line)10 Shape (net.sf.latexdraw.model.api.shape.Shape)9 SVGElement (net.sf.latexdraw.parser.svg.SVGElement)9 SVGGElement (net.sf.latexdraw.parser.svg.SVGGElement)9 Test (org.junit.jupiter.api.Test)8 ArrayList (java.util.ArrayList)7 Polyline (net.sf.latexdraw.model.api.shape.Polyline)5 Color (javafx.scene.paint.Color)4 MathUtils (net.sf.latexdraw.model.MathUtils)4 ShapeFactory (net.sf.latexdraw.model.ShapeFactory)4 BezierCurve (net.sf.latexdraw.model.api.shape.BezierCurve)4 Canvas (net.sf.latexdraw.view.jfx.Canvas)4 Point2D (java.awt.geom.Point2D)3 List (java.util.List)3 ShapeData (net.sf.latexdraw.data.ShapeData)3