drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java
public void createImage(OutputStream stream, int format) {
        SWTGraphics g = null;
        GC gc = null;
        Image image = null;
        LayerManager layerManager = (LayerManager)
            getGraphicalViewer().getEditPartRegistry().get(LayerManager.ID);
        IFigure figure = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS);
        Rectangle r = figure.getBounds();
        try {
            image = new Image(Display.getDefault(), r.width, r.height);
            gc = new GC(image);
            g = new SWTGraphics(gc);
            g.translate(r.x * -1, r.y * -1);
            figure.paint(g);
            ImageLoader imageLoader = new ImageLoader();
            imageLoader.data = new ImageData[] { image.getImageData() };
            imageLoader.save(stream, format);
        } catch (Throwable t) {
            DroolsEclipsePlugin.log(t);
        } finally {
            if (g != null) {
                g.dispose();
            }
            if (gc != null) {
                gc.dispose();
            }
            if (image != null) {
                image.dispose();
            }
        }
    }
public void createImage(OutputStream stream, int format) {
        SWTGraphics g = null;
        GC gc = null;
        Image image = null;
        LayerManager layerManager = (LayerManager)
            getGraphicalViewer().getEditPartRegistry().get(LayerManager.ID);
        IFigure figure = layerManager.getLayer(LayerConstants.PRINTABLE_LAYERS);
        Rectangle r = figure.getBounds();
        try {
            image = new Image(Display.getDefault(), r.width, r.height);
            gc = new GC(image);
            g = new SWTGraphics(gc);
            g.translate(r.x * -1, r.y * -1);
            figure.paint(g);
            ImageLoader imageLoader = new ImageLoader();
            imageLoader.data = new ImageData[] { image.getImageData() };
            imageLoader.save(stream, format);
        } catch (Throwable t) {
            DroolsEclipsePlugin.log(t);
        } finally {
            if (g != null) {
                g.dispose();
            }
            if (gc != null) {
                gc.dispose();
            }
            if (image != null) {
                image.dispose();
            }
        }
    }
public void createImage ( OutputStream stream , int format ) { SWTGraphics g = null ; GC gc = null ; Image image = null ; LayerManager layerManager = ( LayerManager ) getGraphicalViewer ( ) . getEditPartRegistry ( ) . get ( LayerManager . ID ) ; IFigure figure = layerManager . getLayer ( LayerConstants . PRINTABLE_LAYERS ) ; Rectangle r = figure . getBounds ( ) ; try { image = new Image ( Display . getDefault ( ) , r . width , r . height ) ; gc = new GC ( image ) ; g = new SWTGraphics ( gc ) ; g . translate ( r . x * - 1 , r . y * - 1 ) ; figure . paint ( g ) ; ImageLoader imageLoader = new ImageLoader ( ) ; imageLoader . data = new ImageData [ ] { image . getImageData ( ) } ; imageLoader . save ( stream , format ) ; } catch ( Throwable t ) { DroolsEclipsePlugin . log ( t ) ; } finally { if ( g != null ) { g . dispose ( ) ; } if ( gc != null ) { gc . dispose ( ) ; } if ( image != null ) { image . dispose ( ) ; } } }
Writes the content of this editor to the given stream.
Possible formats are for example SWT.IMAGE_BMP, IMAGE_GIF,
IMAGE_JPEG, IMAGE_PNG.
@param stream
@param format
Writes the content of this editor to the given stream . Possible formats are for example SWT . IMAGE_BMP IMAGE_GIF IMAGE_JPEG IMAGE_PNG .