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