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(1, br.getX()-tl.getX()+gap);
final double height = Math.max(1., br.getY()-tl.getY()+gap);
final double x = tl.getX()-gap/2.;
final double y = tl.getY()-gap/2.;
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_RECT);
root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
if(shape.hasShadow()) {
elt = new SVGRectElement(x, y, width, height, document);
setSVGShadowAttributes(elt, true);
root.appendChild(elt);
setSVGRoundCorner(elt);
}
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, height, document);
setSVGBorderBackground(elt, root);
setSVGRoundCorner(elt);
}
elt = new SVGRectElement(x, y, width, height, document);
root.appendChild(elt);
setSVGAttributes(document, elt, true);
setSVGRoundCorner(elt);
if(shape.hasDbleBord()) {
elt = new SVGRectElement(x, y, width, height, document);
setSVGDoubleBordersAttributes(elt);
setSVGRoundCorner(elt);
root.appendChild(elt);
}
setSVGRotationAttribute(root);
return root;