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);
}
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());
}
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());
}
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);
}
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());
}
Aggregations