1

我们正在努力创建一个基于 GMF 框架和工具的建模工具。我们要求允许用户在运行时添加视图(图形)并在他们的图表中使用它们。我们将使用 SVG 文件来表示图形。

在这种情况下,EditParts 和其他 GEF 相关类的正确结构是什么?我们正在考虑实现单个 GEF EditPart 类,该类将基于模型中存在的参数(SVG 文件的路径)创建适当的图形。到目前为止,它似乎没有工作。

必须有人以前已经做过这样的事情。到目前为止,谷歌搜索和 Eclipse 论坛都没有帮助......

4

2 回答 2

1

好吧,我们找到了一个(部分)解决方案。我们有一个元素,根据参数,我们在其中创建一个子图形,它使用 SVG 文件(基于参数)。

在Figure的构造函数中调用如下测试代码:

ScalableImageFigure svg; 网址网址;if (type == 1) { url = ArchitectureStudioDiagramEditorPlugin.getInstance().getBundle().getEntry("icons" + IPath.SEPARATOR + "shadow-box.svg"); } else { url = ArchitectureStudioDiagramEditorPlugin.getInstance().getBundle().getEntry("icons" + IPath.SEPARATOR + "star.svg"); } svg = new ScalableImageFigure(RenderedImageFactory.getInstance(url), true, true, true);

  this.add(svg);

现在我们需要弄清楚如何在 Palette 中拥有多个元素。

于 2009-06-03T19:39:43.597 回答
0

The correct way is to have one to one mapping between figure and editpart . Also painting task should be left to the figure . How the image should be painted , the logic must be inside the figure not in the editpart.

Thanks

于 2009-12-22T09:17:24.013 回答