Search in sources :

Example 26 with IPoint

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

the class TestIRectangularShape method testMirrorVertical.

@Theory
public void testMirrorVertical(@RectangularData final IRectangularShape shape) {
    final IPoint p1 = ShapeFactory.INST.createPoint(4, 1);
    final IPoint p2 = ShapeFactory.INST.createPoint(1, 3);
    shape.setPosition(p2);
    shape.setWidth(p1.getX() - p2.getX());
    shape.setHeight(p2.getY() - p1.getY());
    shape.mirrorVertical(shape.getGravityCentre().getY());
    assertEqualsDouble(1d, shape.getTopLeftPoint().getX());
    assertEqualsDouble(4d, shape.getTopRightPoint().getX());
    assertEqualsDouble(1d, shape.getTopLeftPoint().getY());
    assertEqualsDouble(3d, shape.getBottomLeftPoint().getY());
    assertEqualsDouble(1d, shape.getPtAt(0).getX());
    assertEqualsDouble(1d, shape.getPtAt(0).getY());
    assertEqualsDouble(4d, shape.getPtAt(2).getX());
    assertEqualsDouble(3d, shape.getPtAt(2).getY());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Example 27 with IPoint

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

the class TestIRectangularShape method testMirrorHorizontal.

@Theory
public void testMirrorHorizontal(@RectangularData final IRectangularShape shape) {
    final IPoint p1 = ShapeFactory.INST.createPoint(4, 1);
    final IPoint p2 = ShapeFactory.INST.createPoint(1, 3);
    shape.setPosition(p2);
    shape.setWidth(p1.getX() - p2.getX());
    shape.setHeight(p2.getY() - p1.getY());
    shape.mirrorHorizontal(shape.getGravityCentre().getX());
    assertEqualsDouble(1d, shape.getTopLeftPoint().getX());
    assertEqualsDouble(4d, shape.getTopRightPoint().getX());
    assertEqualsDouble(1d, shape.getTopLeftPoint().getY());
    assertEqualsDouble(3d, shape.getBottomLeftPoint().getY());
    assertEqualsDouble(1d, shape.getPtAt(0).getX());
    assertEqualsDouble(1d, shape.getPtAt(0).getY());
    assertEqualsDouble(4d, shape.getPtAt(2).getX());
    assertEqualsDouble(3d, shape.getPtAt(2).getY());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Example 28 with IPoint

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

the class TestIShape method testGetGravityCentre.

@Theory
public void testGetGravityCentre(@ShapeData final IShape shape) {
    final IPoint 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 : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Example 29 with IPoint

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

the class TestIShape method testGetFullBottomRightPoint.

@Theory
public void testGetFullBottomRightPoint(@ShapeData final IShape shape) {
    shape.setThickness(10.);
    shape.setHasDbleBord(false);
    shape.setBordersPosition(BorderPos.INTO);
    IPoint pt = shape.getBottomRightPoint();
    double gap = shape.getBorderGap();
    pt.translate(gap, gap);
    assertEquals(pt, shape.getFullBottomRightPoint());
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) Theory(org.junit.experimental.theories.Theory)

Example 30 with IPoint

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

the class TestISquaredShape method testTranslate.

@Theory
public void testTranslate(@SquaredData final ISquaredShape shape, @DoubleData final double tx, @DoubleData final double ty) {
    final IPoint p1 = ShapeFactory.INST.createPoint(3d, 1d);
    final IPoint 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 : 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