Search in sources :

Example 41 with Point

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

the class TestShape method testGetGravityCentre.

@Theory
public void testGetGravityCentre(@ShapeData final Shape shape) {
    final Point gc = shape.getGravityCentre();
    assertTrue(MathUtils.INST.isValidPt(gc));
    assertEquals((shape.getTopLeftPoint().getX() + shape.getTopRightPoint().getX()) / 2., gc.getX(), 0.0001);
    assertEquals((shape.getTopLeftPoint().getY() + shape.getBottomLeftPoint().getY()) / 2., gc.getY(), 0.0001);
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Theory(org.junit.experimental.theories.Theory)

Example 42 with Point

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

the class TestSquaredShapeBase method testMirrorHorizontal.

@Theory
public void testMirrorHorizontal(@SquaredData final SquaredShape shape) {
    final Point p1 = ShapeFactory.INST.createPoint(3, 1);
    final Point p2 = ShapeFactory.INST.createPoint(1, 3);
    shape.setPosition(p2);
    shape.setWidth(p1.getX() - p2.getX());
    shape.mirrorHorizontal(shape.getGravityCentre().getX());
    assertEqualsDouble(3., shape.getPtAt(0).getX());
    assertEqualsDouble(1., shape.getPtAt(1).getX());
    assertEqualsDouble(1., shape.getPtAt(2).getX());
    assertEqualsDouble(3., shape.getPtAt(-1).getX());
    assertEqualsDouble(1., shape.getPtAt(0).getY());
    assertEqualsDouble(1., shape.getPtAt(1).getY());
    assertEqualsDouble(3., shape.getPtAt(2).getY());
    assertEqualsDouble(3., shape.getPtAt(-1).getY());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Theory(org.junit.experimental.theories.Theory)

Example 43 with Point

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

the class TestSquaredShapeBase method testTranslate.

@Theory
public void testTranslate(@SquaredData final SquaredShape shape, @DoubleData final double tx, @DoubleData final double ty) {
    final Point p1 = ShapeFactory.INST.createPoint(3d, 1d);
    final Point p2 = ShapeFactory.INST.createPoint(1d, 3d);
    shape.setPosition(p2);
    shape.setWidth(p1.getX() - p2.getX());
    shape.translate(tx, ty);
    assertEqualsDouble(p2.getX() + tx, shape.getPtAt(0).getX());
    assertEqualsDouble(p1.getX() + tx, shape.getPtAt(1).getX());
    assertEqualsDouble(p1.getX() + tx, shape.getPtAt(2).getX());
    assertEqualsDouble(p2.getX() + tx, shape.getPtAt(-1).getX());
    assertEqualsDouble(p1.getY() + ty, shape.getPtAt(0).getY());
    assertEqualsDouble(p1.getY() + ty, shape.getPtAt(1).getY());
    assertEqualsDouble(p2.getY() + ty, shape.getPtAt(2).getY());
    assertEqualsDouble(p2.getY() + ty, shape.getPtAt(-1).getY());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Theory(org.junit.experimental.theories.Theory)

Example 44 with Point

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

the class TestPicture method testGetBottomLeftPoint.

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

Example 45 with Point

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

the class TestPicture method testMirroH.

@Test
public void testMirroH() {
    shape.setPosition(10d, 20d);
    final Point gc = shape.getGravityCentre();
    shape.mirrorHorizontal(5d);
    assertEquals(gc.horizontalSymmetry(5d), shape.getGravityCentre());
}
Also used : Point(net.sf.latexdraw.model.api.shape.Point) Test(org.junit.jupiter.api.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