Search in sources :

Example 1 with SvgExportSettings

use of org.uberfire.ext.editor.commons.client.file.exports.svg.SvgExportSettings in project kie-wb-common by kiegroup.

the class LienzoCanvasExport method toContext2D.

@Override
public IContext2D toContext2D(final AbstractCanvasHandler canvasHandler, final CanvasExportSettings settings) {
    final LienzoLayer layer = getLayer(canvasHandler);
    final com.ait.lienzo.client.core.shape.Layer lienzoLayer = layer.getLienzoLayer();
    final Viewport viewport = lienzoLayer.getViewport();
    final int[] bounds = boundsProvider.compute(layer, settings);
    final IContext2D svgContext2D = Context2DFactory.create(new SvgExportSettings(bounds[2], bounds[3], lienzoLayer.getContext()));
    // Reset the transform before drawing to the target context.
    final Transform transform = viewport.getTransform();
    viewport.setTransform(new Transform());
    // Draw into the target context.
    lienzoLayer.draw(new Context2D(new DelegateNativeContext2D(svgContext2D, canvasHandler)));
    // Set again the previous transform.
    viewport.setTransform(transform);
    // Draw again the native canvas context2d (this is necessary otherwise the canvas becomes empty)
    lienzoLayer.draw();
    return svgContext2D;
}
Also used : LienzoLayer(org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoLayer) Context2D(com.ait.lienzo.client.core.Context2D) IContext2D(org.uberfire.ext.editor.commons.client.file.exports.svg.IContext2D) SvgExportSettings(org.uberfire.ext.editor.commons.client.file.exports.svg.SvgExportSettings) Viewport(com.ait.lienzo.client.core.shape.Viewport) IContext2D(org.uberfire.ext.editor.commons.client.file.exports.svg.IContext2D) Transform(com.ait.lienzo.client.core.types.Transform)

Aggregations

Context2D (com.ait.lienzo.client.core.Context2D)1 Viewport (com.ait.lienzo.client.core.shape.Viewport)1 Transform (com.ait.lienzo.client.core.types.Transform)1 LienzoLayer (org.kie.workbench.common.stunner.client.lienzo.canvas.LienzoLayer)1 IContext2D (org.uberfire.ext.editor.commons.client.file.exports.svg.IContext2D)1 SvgExportSettings (org.uberfire.ext.editor.commons.client.file.exports.svg.SvgExportSettings)1