use of org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.svg.export.GraphicsSVG in project tdi-studio-se by Talend.
the class SVGImageExporter method export.
public static void export(GraphicalViewer viewer, OutputStream outputStream, List businessItems) {
/*
* 1. First get the figure whose visuals we want to save as image. So we would like to save the rooteditpart
* which actually hosts all the printable layers.
*
* NOTE: ScalableRootEditPart manages layers and is registered graphicalviewer's editpartregistry with the key
* LayerManager.ID ... well that is because ScalableRootEditPart manages all layers that are hosted on a
* FigureCanvas. Many layers exist for doing different things
*/
SimpleRootEditPart rootEditPart = (SimpleRootEditPart) viewer.getEditPartRegistry().get(LayerManager.ID);
// rootEditPart.
IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
// getFigure();
Rectangle bounds = rootFigure.getBounds();
GraphicsSVG graphics = GraphicsSVG.getInstance(bounds.getTranslated(bounds.getLocation().negate()));
TalendSVGIDGenerator generator = new TalendSVGIDGenerator(businessItems);
graphics.getSVGGraphics2D().getGeneratorContext().setIDGenerator(generator);
graphics.translate(bounds.getLocation().negate());
rootFigure.paint(graphics);
try {
graphics.getSVGGraphics2D().stream(new BufferedWriter(new OutputStreamWriter(outputStream)));
} catch (SVGGraphics2DIOException e) {
ExceptionHandler.process(e);
}
}
Aggregations