Search in sources :

Example 1 with SVGPolyLineElement

use of net.sf.latexdraw.parser.svg.SVGPolyLineElement 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;
}
Also used : SVGPolyLineElement(net.sf.latexdraw.parser.svg.SVGPolyLineElement) SVGGElement(net.sf.latexdraw.parser.svg.SVGGElement) SVGElement(net.sf.latexdraw.parser.svg.SVGElement) SVGDefsElement(net.sf.latexdraw.parser.svg.SVGDefsElement) Point(net.sf.latexdraw.model.api.shape.Point)

Aggregations

Point (net.sf.latexdraw.model.api.shape.Point)1 SVGDefsElement (net.sf.latexdraw.parser.svg.SVGDefsElement)1 SVGElement (net.sf.latexdraw.parser.svg.SVGElement)1 SVGGElement (net.sf.latexdraw.parser.svg.SVGGElement)1 SVGPolyLineElement (net.sf.latexdraw.parser.svg.SVGPolyLineElement)1