首页 >> 药膳食疗

将GEF模型显示保存为图片

药膳食疗  2020年06月22日  浏览:1 次

项目需求,要把GEF模型在editor中的显示保存为一张图片,便于预览或在文档中使用。研究了GMF的代码,它使用AWT来进行图片的输出,所以在中间作了一个SWT和AWT的转换Adapter. 是一个叫做AWTGraphics的类.其实使用SWT本身就可以进行。

使用draw2D提供的SWTGraphics可以进行GEG图像的保存。本程序假定读者对GEF有一定了解。

privatevoidsaveOutlinePicture(ScrollingGraphicalViewerviewer)限于保密...{

LayerManagerlayerManager=(LayerManager)tEditPartRegistry().get();

//saveimageusingswt

//getrootfigure

// 获取显示在editor中的背景层和打印层

IFigurebackgroundLayer=tLayer(ID_LAYER);

IFigurecontentLayer=tLayer(INTABLE_LAYERS);

//createimagefromrootfigure

Imageimg=newImage(null,tSize().width,tSize().height);

GCgc=newGC(img);

Graphicsgraphics=newSWTGraphics(gc);

anslate(tBounds().getLocation());

// 传送显示图层

int(graphics);

int(graphics);

spose();

spose();

//saveimagetofile

ImageLoaderil=newImageLoader();

ta=newImageData[]...{tImageData()};

//保存地址和保存图片的类型

ve(“c:/g"不能超出这个数量。因为多了的话,AGE_JPEG);

}

查看本文来源

颈动脉有斑块看什么科
治灰指甲的亮甲多少钱一盒
松原什么医院治疗白癜风
友情链接