Search in sources :

Example 16 with IRectangle

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

the class TestParsingPsframe method testParse2CoordinatesFloatSigns2.

@Test
public void testParse2CoordinatesFloatSigns2() {
    parser("\\psframe(-+.5,+-5)(+++35.5,--50.5)");
    final IRectangle rec = getShapeAt(0);
    assertEquals(-0.5 * IShape.PPC, rec.getPosition().getX(), 0.001);
    assertEquals(-5d * -IShape.PPC, rec.getPosition().getY(), 0.001);
    assertEquals(36d * IShape.PPC, rec.getWidth(), 0.001);
    assertEquals(55.5 * IShape.PPC, rec.getHeight(), 0.001);
}
Also used : IRectangle(net.sf.latexdraw.models.interfaces.shape.IRectangle) Test(org.junit.Test)

Example 17 with IRectangle

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

the class TestIRectangle method testConstructorsOK2.

@Test
public void testConstructorsOK2() {
    IRectangle rec = ShapeFactory.INST.createRectangle(ShapeFactory.INST.createPoint(5, 6), 11, 12);
    assertEqualsDouble(5., rec.getPosition().getX());
    assertEqualsDouble(18., rec.getPosition().getY());
    assertEqualsDouble(11., rec.getWidth());
    assertEqualsDouble(12., rec.getHeight());
}
Also used : IRectangle(net.sf.latexdraw.models.interfaces.shape.IRectangle) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 18 with IRectangle

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

the class TestIRectangle method testConstructorsOKNbPoints.

@Test
public void testConstructorsOKNbPoints() {
    IRectangle rec = ShapeFactory.INST.createRectangle();
    assertEquals(4, rec.getNbPoints());
}
Also used : IRectangle(net.sf.latexdraw.models.interfaces.shape.IRectangle) Test(org.junit.Test) HelperTest(net.sf.latexdraw.HelperTest)

Example 19 with IRectangle

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

the class PSTLatexdrawListener method exitPsframe.

@Override
public void exitPsframe(final net.sf.latexdraw.parsers.pst.PSTParser.PsframeContext ctx) {
    final IRectangle rec = ShapeFactory.INST.createRectangle();
    final Tuple<IPoint, IPoint> pts = getRectangularPoints(ctx.p1, ctx.p2, ctx.pstctx);
    rec.setLineArc(ctx.pstctx.frameArc);
    // The x-coordinates of pt1 must be lower than pt2 one.
    if (pts.a.getX() > pts.b.getX()) {
        final double tmp = pts.a.getX();
        pts.a.setX(pts.b.getX());
        pts.b.setX(tmp);
    }
    // The y-coordinates of pt1 must be lower than pt2 one.
    if (pts.a.getY() < pts.b.getY()) {
        final double tmp = pts.a.getY();
        pts.a.setY(pts.b.getY());
        pts.b.setY(tmp);
    }
    setRectangularShape(rec, pts.a.getX(), pts.a.getY(), Math.abs(pts.b.getX() - pts.a.getX()), Math.abs(pts.b.getY() - pts.a.getY()), ctx.pstctx, ctx.cmd);
    shapes.peek().addShape(rec);
}
Also used : IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) IRectangle(net.sf.latexdraw.models.interfaces.shape.IRectangle)

Example 20 with IRectangle

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

the class SVGAxes method createFrame.

private void createFrame(final SVGElement elt, final SVGDocument document) {
    final double gridEndx = shape.getGridEndX();
    final double gridEndy = shape.getGridEndY();
    if (gridEndx > 0 || gridEndy > 0) {
        final double positionx = shape.getPosition().getX();
        final double positiony = shape.getPosition().getY();
        final double xMax = positionx + gridEndx * IShape.PPC;
        final double yMax = positiony - gridEndy * IShape.PPC;
        final IPoint pos = ShapeFactory.INST.createPoint(positionx, gridEndy > 0 ? yMax : positiony);
        final IRectangle r = ShapeFactory.INST.createRectangle(pos, Math.abs(pos.getX() - (gridEndx > 0 ? xMax : positionx)), Math.abs(pos.getY() - positiony));
        r.setBordersPosition(BorderPos.MID);
        r.setLineColour(shape.getLineColour());
        r.setLineStyle(shape.getLineStyle());
        r.setThickness(shape.getThickness());
        final SVGElement frame = new SVGRectangle(r).toSVG(document);
        frame.setAttribute(SVGAttributes.SVG_TRANSFORM, "translate(" + MathUtils.INST.format.format(-shape.getPosition().getX()) + ',' + MathUtils.INST.format.format(-shape.getPosition().getY()) + ')');
        elt.appendChild(frame);
    }
}
Also used : SVGElement(net.sf.latexdraw.parsers.svg.SVGElement) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint) IRectangle(net.sf.latexdraw.models.interfaces.shape.IRectangle)

Aggregations

IRectangle (net.sf.latexdraw.models.interfaces.shape.IRectangle)39 Test (org.junit.Test)33 HelperTest (net.sf.latexdraw.HelperTest)5 IGrid (net.sf.latexdraw.models.interfaces.shape.IGrid)5 ICircle (net.sf.latexdraw.models.interfaces.shape.ICircle)2 IDot (net.sf.latexdraw.models.interfaces.shape.IDot)2 IEllipse (net.sf.latexdraw.models.interfaces.shape.IEllipse)2 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)2 IText (net.sf.latexdraw.models.interfaces.shape.IText)2 Theory (org.junit.experimental.theories.Theory)2 Point2D (javafx.geometry.Point2D)1 ILineArcProp (net.sf.latexdraw.models.interfaces.prop.ILineArcProp)1 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 IFreehand (net.sf.latexdraw.models.interfaces.shape.IFreehand)1 IPlot (net.sf.latexdraw.models.interfaces.shape.IPlot)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