Search in sources :

Example 11 with IRhombus

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);
}
Also used : IRhombus(net.sf.latexdraw.models.interfaces.shape.IRhombus) Test(org.junit.Test)

Example 12 with IRhombus

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());
}
Also used : IRhombus(net.sf.latexdraw.models.interfaces.shape.IRhombus) HelperTest(net.sf.latexdraw.HelperTest) Test(org.junit.Test)

Example 13 with IRhombus

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);
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) IRhombus(net.sf.latexdraw.models.interfaces.shape.IRhombus)

Example 14 with IRhombus

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);
}
Also used : IRhombus(net.sf.latexdraw.models.interfaces.shape.IRhombus) Test(org.junit.Test)

Example 15 with IRhombus

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);
}
Also used : IRhombus(net.sf.latexdraw.models.interfaces.shape.IRhombus) Test(org.junit.Test)

Aggregations

IRhombus (net.sf.latexdraw.models.interfaces.shape.IRhombus)19 Test (org.junit.Test)17 HelperTest (net.sf.latexdraw.HelperTest)3 ICircle (net.sf.latexdraw.models.interfaces.shape.ICircle)2 IRectangle (net.sf.latexdraw.models.interfaces.shape.IRectangle)2 IAxes (net.sf.latexdraw.models.interfaces.shape.IAxes)1 IBezierCurve (net.sf.latexdraw.models.interfaces.shape.IBezierCurve)1 ICircleArc (net.sf.latexdraw.models.interfaces.shape.ICircleArc)1 IDot (net.sf.latexdraw.models.interfaces.shape.IDot)1 IEllipse (net.sf.latexdraw.models.interfaces.shape.IEllipse)1 IFreehand (net.sf.latexdraw.models.interfaces.shape.IFreehand)1 IGrid (net.sf.latexdraw.models.interfaces.shape.IGrid)1 IPlot (net.sf.latexdraw.models.interfaces.shape.IPlot)1 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)1 IPolygon (net.sf.latexdraw.models.interfaces.shape.IPolygon)1 IPolyline (net.sf.latexdraw.models.interfaces.shape.IPolyline)1 IPositionShape (net.sf.latexdraw.models.interfaces.shape.IPositionShape)1 IRectangularShape (net.sf.latexdraw.models.interfaces.shape.IRectangularShape)1 IShape (net.sf.latexdraw.models.interfaces.shape.IShape)1 ISquare (net.sf.latexdraw.models.interfaces.shape.ISquare)1