use of net.sf.latexdraw.models.interfaces.shape.IRhombus in project latexdraw by arnobl.
the class TestParsingPsdiamond method testParse2CoordinatesTwoFirstMissing.
@Test
public void testParse2CoordinatesTwoFirstMissing() {
parser("\\psdiamond(,)(35,50)");
IRhombus rh = getShapeAt(0);
assertEquals(IShape.PPC - 35 * IShape.PPC, rh.getPosition().getX(), 0.001);
assertEquals(-IShape.PPC + 50d * IShape.PPC, rh.getPosition().getY(), 0.001);
assertEquals(35d * IShape.PPC * 2d, rh.getWidth(), 0.001);
assertEquals(50d * IShape.PPC * 2d, rh.getHeight(), 0.001);
}
use of net.sf.latexdraw.models.interfaces.shape.IRhombus in project latexdraw by arnobl.
the class TestIRhombus method testConstructor2.
@Test
public void testConstructor2() {
final IRhombus rho = ShapeFactory.INST.createRhombus(ShapeFactory.INST.createPoint(5, 15), 20, 40);
assertEqualsDouble(4d, rho.getNbPoints());
assertEqualsDouble(20d, rho.getWidth());
assertEqualsDouble(40d, rho.getHeight());
assertEqualsDouble(-5d, rho.getPosition().getX());
assertEqualsDouble(35d, rho.getPosition().getY());
}
use of net.sf.latexdraw.models.interfaces.shape.IRhombus in project latexdraw by arnobl.
the class PSTLatexdrawListener method exitPsdiamond.
@Override
public void exitPsdiamond(final net.sf.latexdraw.parsers.pst.PSTParser.PsdiamondContext ctx) {
final IRhombus rhombus = ShapeFactory.INST.createRhombus();
final Tuple<IPoint, IPoint> pts = getRectangularPoints(ctx.p1, ctx.p2, ctx.pstctx);
setRectangularShape(rhombus, pts.a.getX() - pts.b.getX(), pts.a.getY() - pts.b.getY(), Math.abs(pts.b.getX() * 2d), Math.abs(pts.b.getY() * 2d), ctx.pstctx, ctx.cmd);
if (!MathUtils.INST.equalsDouble(ctx.pstctx.gangle, 0d)) {
rhombus.setRotationAngle(rhombus.getRotationAngle() - Math.toRadians(ctx.pstctx.gangle));
}
shapes.peek().addShape(rhombus);
}
use of net.sf.latexdraw.models.interfaces.shape.IRhombus in project latexdraw by arnobl.
the class TestParsingPsdiamond method testParse2CoordinatesTwoLastMissing.
@Test
public void testParse2CoordinatesTwoLastMissing() {
parser("\\psdiamond(0,0)(,)");
IRhombus rh = getShapeAt(0);
assertEquals(-IShape.PPC, rh.getPosition().getX(), 0.001);
assertEquals(IShape.PPC, rh.getPosition().getY(), 0.001);
assertEquals(IShape.PPC * 2d, rh.getWidth(), 0.001);
assertEquals(IShape.PPC * 2d, rh.getHeight(), 0.001);
}
use of net.sf.latexdraw.models.interfaces.shape.IRhombus in project latexdraw by arnobl.
the class TestParsingPsdiamond method testCoordinatesInch.
@Test
public void testCoordinatesInch() {
parser("\\psdiamond(0,0)(35in,20in)");
IRhombus rh = getShapeAt(0);
assertEquals(-35d * IShape.PPC / 2.54, rh.getPosition().getX(), 0.001);
assertEquals(-20d * IShape.PPC / 2.54 * -1d, rh.getPosition().getY(), 0.001);
assertEquals(35d * IShape.PPC / 2.54 * 2d, rh.getWidth(), 0.001);
assertEquals(20d * IShape.PPC / 2.54 * 2d, rh.getHeight(), 0.001);
}
Aggregations