use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class ModifyShapePropertyTest method commonCanDoFixture.
@Override
protected void commonCanDoFixture() {
shapes = ShapeFactory.INST.createGroup();
final Grid grid = ShapeFactory.INST.createGrid(ShapeFactory.INST.createPoint());
final Axes axes = ShapeFactory.INST.createAxes(ShapeFactory.INST.createPoint());
final Dot dot = ShapeFactory.INST.createDot(ShapeFactory.INST.createPoint());
final Circle circle = ShapeFactory.INST.createCircle();
final Ellipse ell = ShapeFactory.INST.createEllipse();
final Text txt = ShapeFactory.INST.createText();
final BezierCurve bc = ShapeFactory.INST.createBezierCurve(Collections.emptyList());
final Polyline pl = ShapeFactory.INST.createPolyline(Collections.emptyList());
final Polygon pg = ShapeFactory.INST.createPolygon(Collections.emptyList());
final Triangle tr = ShapeFactory.INST.createTriangle();
final Rhombus rh = ShapeFactory.INST.createRhombus();
final Rectangle r1 = ShapeFactory.INST.createRectangle();
final Plot plot = ShapeFactory.INST.createPlot(ShapeFactory.INST.createPoint(), 0d, 1d, "x", false);
final CircleArc carc = ShapeFactory.INST.createCircleArc();
final Square sq = ShapeFactory.INST.createSquare();
final Freehand fh = ShapeFactory.INST.createFreeHand(Collections.emptyList());
r1.setLineStyle(LineStyle.DASHED);
r1.setBordersPosition(BorderPos.INTO);
r1.setFillingStyle(FillingStyle.PLAIN);
r1.setThickness(2.3);
r1.setHasDbleBord(true);
r1.setLineArc(0.2);
r1.setDbleBordSep(1.3);
r1.setHatchingsAngle(0.33);
r1.setHatchingsSep(9.1);
r1.setHatchingsWidth(12.11);
r1.setShadowAngle(0.1);
r1.setGradMidPt(0.66);
r1.setHatchingsCol(DviPsColors.CYAN);
r1.setLineColour(DviPsColors.NAVYBLUE);
r1.setShadowSize(87.2);
r1.setFillingCol(DviPsColors.CARNATIONPINK);
r1.setShadowCol(DviPsColors.CORNFLOWERBLUE);
r1.setDashSepBlack(1.2);
r1.setDashSepWhite(2.1);
r1.setDotSep(23.1);
r1.setGradAngle(1.3);
r1.setDbleBordCol(DviPsColors.RED);
r1.setGradColEnd(DviPsColors.BITTERSWEET);
r1.setGradColStart(DviPsColors.FORESTGREEN);
r1.setShowPts(true);
final Rectangle r2 = ShapeFactory.INST.createRectangle();
r2.setLineStyle(LineStyle.SOLID);
r2.setBordersPosition(BorderPos.MID);
r2.setFillingStyle(FillingStyle.HLINES);
r2.setThickness(6.3);
r2.setHasShadow(true);
r2.setLineArc(0.33);
r2.setDbleBordSep(2.3);
r2.setHatchingsAngle(-0.53);
r2.setHatchingsSep(1.1);
r2.setHatchingsWidth(2.11);
r2.setShadowAngle(-0.1);
r2.setGradMidPt(0.31);
r2.setHatchingsCol(DviPsColors.APRICOT);
r2.setLineColour(DviPsColors.YELLOW);
r2.setShadowSize(8.1);
r2.setFillingCol(DviPsColors.CERULEAN);
r2.setShadowCol(DviPsColors.DARKORCHID);
r1.setDashSepBlack(11.2);
r1.setDashSepWhite(21.1);
r1.setDotSep(231.1);
r1.setGradAngle(11.3);
r1.setDbleBordCol(DviPsColors.ROYALBLUE);
r1.setGradColEnd(DviPsColors.CADETBLUE);
r1.setGradColStart(DviPsColors.OLIVE);
dot.setDotStyle(DotStyle.DIAMOND);
txt.copy(r1);
ell.copy(r1);
circle.copy(r2);
dot.copy(r2);
bc.copy(r2);
pl.copy(r1);
pg.copy(r2);
tr.copy(r1);
rh.copy(r2);
plot.copy(r1);
carc.copy(r2);
sq.copy(r1);
fh.copy(r2);
sq.setFillingStyle(FillingStyle.GRAD);
shapes.addShape(r1);
shapes.addShape(txt);
shapes.addShape(grid);
shapes.addShape(pl);
shapes.addShape(pg);
shapes.addShape(r2);
shapes.addShape(axes);
shapes.addShape(ell);
shapes.addShape(circle);
shapes.addShape(tr);
shapes.addShape(rh);
shapes.addShape(dot);
shapes.addShape(bc);
shapes.addShape(plot);
shapes.addShape(carc);
shapes.addShape(sq);
shapes.addShape(fh);
}
use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class SVGBezierCurve method pathToBezierCurve.
/**
* Creates a bezier curve and initialises its path from an SVG element.
*/
private static BezierCurve pathToBezierCurve(final SVGElement elt) {
if (!(elt instanceof SVGPathElement)) {
return null;
}
final SVGPathSegList list = ((SVGPathElement) elt).getSegList();
if (list.size() < 2 || !(list.get(0) instanceof SVGPathSegMoveto)) {
return null;
}
final SVGPathSegMoveto m = (SVGPathSegMoveto) list.get(0);
CtrlPointsSeg c;
int i = 1;
final int size = list.size();
// Creating a point to support when the first path element is relative.
Point2D pt = new Point2D.Double();
final List<Point> pts = new ArrayList<>();
final List<Point> ctrlpts = new ArrayList<>();
final boolean closed;
pt = m.getPoint(pt);
pts.add(ShapeFactory.INST.createPoint(pt));
if (list.get(1) instanceof CtrlPointsSeg) {
// We set the control point of the first point.
c = (CtrlPointsSeg) list.get(1);
ctrlpts.add(ShapeFactory.INST.createPoint(c.getCtrl1(pt)));
}
while (i < size && list.get(i) instanceof CtrlPointsSeg) {
c = (CtrlPointsSeg) list.get(i);
final Point2D currPt = c.getPoint(pt);
pts.add(ShapeFactory.INST.createPoint(currPt));
ctrlpts.add(ShapeFactory.INST.createPoint(c.getCtrl2(pt)));
pt = currPt;
i++;
}
if (pts.size() > 2 && pts.get(pts.size() - 1).equals(pts.get(0), 0.00001)) {
// We set the shape as closed
pts.remove(pts.size() - 1);
ctrlpts.remove(ctrlpts.size() - 1);
closed = true;
} else {
// There is something else at the end of the path.
closed = i < size && list.get(i) instanceof SVGPathSegClosePath;
}
final BezierCurve bc = ShapeFactory.INST.createBezierCurve(pts, ctrlpts);
bc.setOpened(!closed);
return bc;
}
use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class TestParsingPSbezier method testParamArrowsArrowsNoneNone.
@Test
public void testParamArrowsArrowsNoneNone() {
parser("\\psbezier[arrows=<->]{-}(1,2)(3,4)(5,6)(7,8)");
final BezierCurve bc = getShapeAt(0);
assertEquals(ArrowStyle.NONE, bc.getArrowStyle(0));
assertEquals(ArrowStyle.NONE, bc.getArrowStyle(1));
}
use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class TestParsingPSbezier method testParse7Coordinates.
@Test
public void testParse7Coordinates() {
parser("\\psbezier(5,10)(1,2)(3,4)(5,6)(7,8)(9,10)(11,12)");
final BezierCurve bc = getShapeAt(0);
assertEquals(3, bc.getNbPoints());
assertEquals(5d * Shape.PPC, bc.getPtAt(0).getX(), 0.0001);
assertEquals(-10d * Shape.PPC, bc.getPtAt(0).getY(), 0.0001);
assertEquals(5d * Shape.PPC, bc.getPtAt(1).getX(), 0.0001);
assertEquals(-6d * Shape.PPC, bc.getPtAt(1).getY(), 0.0001);
assertEquals(11d * Shape.PPC, bc.getPtAt(2).getX(), 0.0001);
assertEquals(-12d * Shape.PPC, bc.getPtAt(2).getY(), 0.0001);
assertEquals(9d * Shape.PPC, bc.getSecondCtrlPtAt(0).getX(), 0.0001);
assertEquals(-18d * Shape.PPC, bc.getSecondCtrlPtAt(0).getY(), 0.0001);
assertEquals(7d * Shape.PPC, bc.getSecondCtrlPtAt(1).getX(), 0.0001);
assertEquals(-8d * Shape.PPC, bc.getSecondCtrlPtAt(1).getY(), 0.0001);
assertEquals(3d * Shape.PPC, bc.getFirstCtrlPtAt(1).getX(), 0.0001);
assertEquals(-4d * Shape.PPC, bc.getFirstCtrlPtAt(1).getY(), 0.0001);
assertEquals(9d * Shape.PPC, bc.getFirstCtrlPtAt(2).getX(), 0.0001);
assertEquals(-10d * Shape.PPC, bc.getFirstCtrlPtAt(2).getY(), 0.0001);
}
use of net.sf.latexdraw.model.api.shape.BezierCurve in project latexdraw by arnobl.
the class TestParsingPSbezier method testSimpleBezierCurveClose.
@Test
public void testSimpleBezierCurveClose() {
parser("\\psbezier[linecolor=black, linewidth=0.04](0.10361466,-0.36860093)(0.76211923,-1.1211777)(7.561873,-1.9049373)(8.503614," + "-1.5686009216308594)(9.445356,-1.2322645)(6.693564,1.4899777)(5.7036147,1.631399)(4.713665,1.7728205)(-0.55489,0.38397577)(0.10361466," + "-0.36860093)");
final BezierCurve bc = getShapeAt(0);
assertFalse(bc.isOpened());
}
Aggregations