use of net.sf.latexdraw.parser.svg.SVGEllipseElement in project latexdraw by arnobl.
the class SVGEllipse method toSVG.
@Override
SVGElement toSVG(@NotNull final SVGDocument doc) {
if (doc.getFirstChild().getDefs() == null) {
return null;
}
final Point tl = shape.getTopLeftPoint();
final Point br = shape.getBottomRightPoint();
final double tlx = tl.getX();
final double tly = tl.getY();
final double brx = br.getX();
final double bry = br.getY();
SVGElement elt;
final SVGElement root = new SVGGElement(doc);
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE + ':' + LNamespace.XML_TYPE, LNamespace.XML_TYPE_ELLIPSE);
root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
final double gap = getPositionGap();
final double width = Math.max(1., (brx - tlx + gap) / 2.);
final double height = Math.max(1., (bry - tly + gap) / 2.);
final double x = (brx + tlx) / 2.;
final double y = (bry + tly) / 2.;
if (shape.hasShadow()) {
elt = new SVGEllipseElement(x, y, width, height, doc);
setSVGShadowAttributes(elt, true);
root.appendChild(elt);
}
if (shape.hasShadow() && !PSTricksConstants.LINE_NONE_STYLE.equals(shape.getLineStyle().getLatexToken())) {
// The background of the borders must be filled is there is a shadow.
elt = new SVGEllipseElement(x, y, width, height, doc);
setSVGBorderBackground(elt, root);
}
elt = new SVGEllipseElement(x, y, width, height, doc);
setSVGAttributes(doc, elt, true);
root.appendChild(elt);
if (shape.hasDbleBord()) {
elt = new SVGEllipseElement(x, y, width, height, doc);
setSVGDoubleBordersAttributes(elt);
root.appendChild(elt);
}
setSVGRotationAttribute(root);
return root;
}
Aggregations