Search in sources :

Example 46 with Point

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

the class TestPicture method testGetTopRightPoint.

@Test
public void testGetTopRightPoint() {
    final Point pt = shape.getTopRightPoint();
    assertEquals(shape.getPosition().getX() + shape.getImage().getWidth(), pt.getX(), 0.001);
    assertEquals(shape.getPosition().getY(), pt.getY(), 0.001);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.jupiter.api.Test)

Example 47 with Point

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

the class TestPicture method testMirroV.

@Test
public void testMirroV() {
    shape.setPosition(10d, 20d);
    final Point gc = shape.getGravityCentre();
    shape.mirrorVertical(5d);
    assertEquals(gc.verticalSymmetry(5d), shape.getGravityCentre());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.jupiter.api.Test)

Example 48 with Point

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

the class TestPoint method testSubstractKO.

@Test
public void testSubstractKO() {
    pt.setPoint(10d, 11d);
    final Point p = pt.substract(null);
    assertThat(p.getX()).isEqualTo(10d, within(0.00001d));
    assertThat(p.getY()).isEqualTo(11d, within(0.00001d));
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 49 with Point

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

the class TestPoint method testHorizontalSymmetrySame.

@Test
public void testHorizontalSymmetrySame() {
    pt.setPoint(10d, 20d);
    final Point sym = pt.horizontalSymmetry(10d);
    assertEqualsDouble(pt.getY(), sym.getY());
    assertEqualsDouble(10d, sym.getX());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 50 with Point

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

the class TestControlPointShapeBase method setRotationAngle.

@Theory
public void setRotationAngle(@CtrlShapeData final ControlPointShape sh) {
    sh.translate(100d, 120d);
    final Point pt = sh.getGravityCentre();
    final double angle = Math.PI / 2d;
    List<Point> ctrlPts1 = cloneList(sh.getFirstCtrlPts(), p -> ShapeFactory.INST.createPoint(p));
    List<Point> ctrlPts2 = cloneList(sh.getSecondCtrlPts(), p -> ShapeFactory.INST.createPoint(p));
    sh.setRotationAngle(angle);
    ctrlPts1 = ctrlPts1.stream().map(p -> p.rotatePoint(pt, angle)).collect(Collectors.toList());
    ctrlPts2 = ctrlPts2.stream().map(p -> p.rotatePoint(pt, angle)).collect(Collectors.toList());
    assertEquals(ctrlPts1, sh.getFirstCtrlPts());
    assertEquals(ctrlPts2, sh.getSecondCtrlPts());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Theory(org.junit.experimental.theories.Theory)

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