use of net.sf.latexdraw.parser.svg.SVGGElement in project latexdraw by arnobl.
the class SVGDot method toSVG.
@Override
SVGElement toSVG(@NotNull final SVGDocument doc) {
final SVGElement root = new SVGGElement(doc);
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_DOT);
root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_SIZE, String.valueOf(shape.getDiametre()));
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_DOT_SHAPE, shape.getDotStyle().getPSTToken());
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_POSITION, shape.getPosition().getX() + " " + shape.getPosition().getY());
viewFactory.createView(shape).ifPresent(vdot -> JFXToSVG.INSTANCE.shapesToElements(vdot.getChildren(), doc).forEach(elt -> root.appendChild(elt)));
setSVGRotationAttribute(root);
return root;
}
use of net.sf.latexdraw.parser.svg.SVGGElement in project latexdraw by arnobl.
the class SVGPolylines method toSVG.
@Override
SVGElement toSVG(@NotNull final SVGDocument doc) {
final SVGElement root = new SVGGElement(doc);
final SVGDefsElement defs = doc.getFirstChild().getDefs();
final StringBuilder points = new StringBuilder();
final List<Point> pts = shape.getPoints();
SVGPolyLineElement elt;
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_JOINED_LINES);
root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
for (final Point pt : pts) {
points.append(pt.getX()).append(',').append(pt.getY()).append(' ');
}
final String pointsStr = points.toString();
if (shape.hasShadow()) {
final SVGPolyLineElement shad = new SVGPolyLineElement(doc);
shad.setPoints(pointsStr);
setSVGShadowAttributes(shad, false);
root.appendChild(shad);
parameteriseSVGArrow(shape, shad, 0, true, doc, defs);
parameteriseSVGArrow(shape, shad, 1, true, doc, defs);
}
if (shape.hasShadow() && !PSTricksConstants.LINE_NONE_STYLE.equals(shape.getLineStyle().getLatexToken()) && shape.isFilled()) {
// The background of the borders must be filled is there is a shadow.
elt = new SVGPolyLineElement(doc);
elt.setPoints(pointsStr);
setSVGBorderBackground(elt, root);
}
elt = new SVGPolyLineElement(doc);
elt.setPoints(pointsStr);
root.appendChild(elt);
if (shape.hasDbleBord()) {
final SVGPolyLineElement dblBord = new SVGPolyLineElement(doc);
dblBord.setPoints(pointsStr);
setSVGDoubleBordersAttributes(dblBord);
root.appendChild(dblBord);
}
setSVGAttributes(doc, elt, false);
elt.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_ROTATION, String.valueOf(shape.getRotationAngle()));
parameteriseSVGArrow(shape, elt, 0, false, doc, defs);
parameteriseSVGArrow(shape, elt, shape.getNbArrows() - 1, false, doc, defs);
return root;
}
Aggregations