@Override
public SVGElement toSVG(final SVGDocument doc) {
if(doc==null)
return null;
final Graphics2D2SVG graphics = new Graphics2D2SVG(doc);
final SVGElement root;
final boolean viewCreated;
// Instead of creating a view, its is gathered from the Java view of the application.
IViewShape view = MappingRegistry.REGISTRY.getTargetFromSource(shape, IViewDot.class);
if(view==null) {
view = View2DTK.getFactory().createView(shape);
viewCreated = true;
}
else viewCreated = false;
view.paint(graphics, null);
root = graphics.getElement();
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_TYPE, LNamespace.XML_TYPE_DOT);
root.setAttribute(SVGAttributes.SVG_ID, getSVGID());
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_SIZE, String.valueOf(shape.getDiametre()));
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_DOT_SHAPE, shape.getDotStyle().getPSTToken());
root.setAttribute(LNamespace.LATEXDRAW_NAMESPACE+':'+LNamespace.XML_POSITION, shape.getPosition().getX() + " " + shape.getPosition().getY()); //$NON-NLS-1$
graphics.dispose();
if(viewCreated)
view.flush();
return root;