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