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