Search in sources :

Example 16 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIPoint method testVerticalSymmetrySame.

@Test
public void testVerticalSymmetrySame() {
    pt.setPoint(10d, 20d);
    final IPoint sym = pt.verticalSymmetry(20d);
    assertEqualsDouble(pt.getX(), sym.getX());
    assertEqualsDouble(20d, sym.getY());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 17 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIPoint method testHorizontalSymmetrySame.

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

Example 18 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIPolygon method testConstructor.

@Test
public void testConstructor() {
    IPoint pt1 = ShapeFactory.INST.createPoint(1, 1);
    IPoint pt2 = ShapeFactory.INST.createPoint(2, 2);
    IPolygon pol = ShapeFactory.INST.createPolygon(Arrays.asList(pt1, pt2));
    assertEquals(pt1, pol.getPtAt(0));
    assertEquals(pt2, pol.getPtAt(-1));
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) IPolygon(net.sf.latexdraw.models.interfaces.shape.IPolygon) Test(org.junit.Test)

Example 19 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIControlPointShape method testDuplicateDoNotShareCtrlPoints.

@Theory
public void testDuplicateDoNotShareCtrlPoints(@CtrlShapeData final IControlPointShape shape) {
    final List<IPoint> ctrlPts = cloneList(shape.getFirstCtrlPts(), pt -> ShapeFactory.INST.createPoint(pt));
    final IShape sh = shape.duplicate();
    sh.translate(11d, 12d);
    assertEquals(ctrlPts, shape.getFirstCtrlPts());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) IShape(net.sf.latexdraw.models.interfaces.shape.IShape) Theory(org.junit.experimental.theories.Theory)

Example 20 with IPoint

use of net.sf.latexdraw.models.interfaces.shape.IPoint in project latexdraw by arnobl.

the class TestIControlPointShape method setRotationAngle.

@Theory
public void setRotationAngle(@CtrlShapeData final IControlPointShape sh) {
    sh.translate(100d, 120d);
    final IPoint pt = sh.getGravityCentre();
    final double angle = Math.PI / 2d;
    List<IPoint> ctrlPts1 = cloneList(sh.getFirstCtrlPts(), p -> ShapeFactory.INST.createPoint(p));
    List<IPoint> 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 : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Aggregations

IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)191 Test (org.junit.Test)45 HelperTest (net.sf.latexdraw.HelperTest)25 Theory (org.junit.experimental.theories.Theory)21 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)15 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)11 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)11 ShapeFactory (net.sf.latexdraw.models.ShapeFactory)10 ILine (net.sf.latexdraw.models.interfaces.shape.ILine)10 IBezierCurve (net.sf.latexdraw.models.interfaces.shape.IBezierCurve)9 IGroup (net.sf.latexdraw.models.interfaces.shape.IGroup)9 ArrayList (java.util.ArrayList)8 MathUtils (net.sf.latexdraw.models.MathUtils)8 Collections (java.util.Collections)7 IPolygon (net.sf.latexdraw.models.interfaces.shape.IPolygon)7 Arrays (java.util.Arrays)6 Cursor (javafx.scene.Cursor)6 BorderPos (net.sf.latexdraw.models.interfaces.shape.BorderPos)6 IModifiablePointsShape (net.sf.latexdraw.models.interfaces.shape.IModifiablePointsShape)6 Inject (net.sf.latexdraw.util.Inject)6