Search in sources :

Example 6 with SVGRectElement

use of net.sf.latexdraw.parsers.svg.SVGRectElement in project latexdraw by arnobl.

the class SVGSquare method toSVG.

@Override
public SVGElement toSVG(final SVGDocument document) {
    if (document == null || document.getFirstChild().getDefs() == null) {
        throw new IllegalArgumentException();
    }
    final double gap = getPositionGap();
    final IPoint tl = shape.getTopLeftPoint();
    final IPoint br = shape.getBottomRightPoint();
    SVGElement elt;
    final SVGElement root = new SVGGElement(document);
    final double width = Math.max(1d, br.getX() - tl.getX() + gap);
    final double x = tl.getX() - gap / 2d;
    final double y = tl.getY() - gap / 2d;
    root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_SQUARE);
    root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
    setShadowSVGRect(root, x, y, width, width, document);
    if (shape.hasShadow() && !shape.getLineStyle().getLatexToken().equals(PSTricksConstants.LINE_NONE_STYLE)) {
        // The background of the borders must be filled is there is a shadow.
        elt = new SVGRectElement(x, y, width, width, document);
        setSVGBorderBackground(elt, root);
        setSVGRoundCorner(elt);
    }
    elt = new SVGRectElement(x, y, width, width, document);
    root.appendChild(elt);
    setSVGAttributes(document, elt, true);
    setSVGRoundCorner(elt);
    setDbleBordSVGRect(root, x, y, width, width, document);
    setSVGRotationAttribute(root);
    return root;
}
Also used : SVGGElement(net.sf.latexdraw.parsers.svg.SVGGElement) SVGRectElement(net.sf.latexdraw.parsers.svg.SVGRectElement) SVGElement(net.sf.latexdraw.parsers.svg.SVGElement) IPoint(net.sf.latexdraw.models.interfaces.shape.IPoint)

Aggregations

SVGRectElement (net.sf.latexdraw.parsers.svg.SVGRectElement)6 IPoint (net.sf.latexdraw.models.interfaces.shape.IPoint)3 SVGElement (net.sf.latexdraw.parsers.svg.SVGElement)3 SVGGElement (net.sf.latexdraw.parsers.svg.SVGGElement)3 SVGDefsElement (net.sf.latexdraw.parsers.svg.SVGDefsElement)1 SVGPathElement (net.sf.latexdraw.parsers.svg.SVGPathElement)1 SVGPatternElement (net.sf.latexdraw.parsers.svg.SVGPatternElement)1