graphiti笔记1

来源:互联网 发布:郭天祥51单片机百度云 编辑:程序博客网 时间:2024/05/01 05:38

1           概述

1.1      结构

1.1.1       Graphiti是一个简单快速创建图形工具的eclipse开源框架。

Graphti的目标是支持快速、简单地创建统一的图形化编辑器,这些编辑器允许使用自定义的图形符号显示和编辑相关的领域模型(数据模型)。

领域模型(domain model)的图形展示(graphical representation)本身也是一个模型,其中包含的模型元素,如“矩形”、“文本”和“连接”。这使得每个图形编辑器分成以下几个部分:

(1)     从领域模型到图形模型(用于查看)的转变,反之亦然vice versa(用于编辑)。包括图形模型的不依赖可视化平台的交互行为的定义,如定义如何创建和调整图形、哪些上下文菜单和工具栏可用。

①      这部分依赖于特定的域模型和图形符号(graphical notation),所以它必须由Graphiti的用户为每个图形编辑器去实现。因为不依赖可视化平台,所以图形模型的渲染已经被框架完成。

②      该图形模型是基于EMF的,但是也可以基于其他的建模技术。

(2)     在一个特定可视化平台上的图形模型的渲染,以及可视化平台上的特定交互(如鼠标事件)与定义的不依赖平台的交互之间的映射。

①      这部分依赖于可视化平台,但它独立于特定的域模型和图形符号。因此,它可以完全由Graphiti提供。用户有可能在一些地方添加可视化平台的具体实现,但不建议这样做,因为它会阻碍相同图表(diagram)在不同平台上的渲染。

②      Graphiti的技术实现基于GEFDraw2D

 

渲染引擎和交互组件共同构成了Graphiti的框架组件(framework components)也就是Graphiti的运行时。

1.1.1       Diagram Type Agent



 

(1)   一个Diagram Type Agent的主要任务是修改模型数据。

(2)   Pictogram Model(显示模型/图符模型,其元模型由graphiti创建):数据的图形化展示定义(符号)。(PE:图形结构,GA:图形外观)

(3)   Domain model(领域模型 ):来自开发者地数据模型。

(4)   Link Model (链接模型):用来链接领域模型的数据和图形展示(Pictogram Model的数据Pictogram Element)。

(5)   Features 类似于操作(operations).

①    Add Features:即给领域模型的元素在图符模型中创建图形化表达。

②    Create Features:在领域模型以及相应的图形表示中生新的对象。

③    Remove Features:删除图符模型中的图形表示。

④    Delete Features:删除域模型对象和它在图符模型中的图形化表示。

(6)   Diagram Type Provider:图表类型特定的和工具特定的对交互组件的请求是由图类型提供器处理的。当同步域模型和图符模型时,选择合适的更新策略。

(7)   Diagram Type Agent的实现步骤:

①      实现Diagram Type Provider

      注册Diagram Type ProviderDiagram Typelugin.xml->extention)

③      创建Feature Provider并注册,实现具体的Feature

      提供 一组IToolBehaviorProvider

2           Plug-In Structure

Graphiti consists of a UI platform independent and a UI platform dependent part.

org.eclipse.graphiti

Graphiti: UI platform independent part

org.eclipse.graphiti.ui

Graphiti: UI platform dependent part

org.eclipse.graphiti.mm

plug-in for EMF pictogram model

用于EMF象形图模型的插件。

org.eclipse.graphiti.pattern

framework for an alternative generic approach to combine all implementation aspects in one pattern

用于一般的可变方法来组合所有的实现方面到一个模式中的框架

org.eclipse.graphiti.doc

Graphiti tutorial in Eclipse help

org.eclipse.graphiti.examples.common

samples and test tools for Graphiti; helper UIs, e.g. repository explorerand wizard(for Graphiti internal use; must not be used by the Graphiti customers)

org.eclipse.graphiti.examples.tutorial

implementation of Graphiti tutorial in final stage

org.eclipse.graphiti.tests

Graphiti internal tests

 

3       Diagram

3.1      创建插件工程

3.2      创建Diagram Type Provider

Diagramgraphiti内置的显示模型的根节点,通过type D标示。

(1)     Diagram Type Provider实现IDiagramTypeProvider.或继承AbstractDiagramTypeProvider.

(2)      如果为diagram type 创建了类型提供器,而这种diagram type不存在,则需要在plugin.xml中声明该类型的信息。

   <extension

         point="org.eclipse.graphiti.ui.diagramTypes">

      <diagramType

            id="chessdemo.ChessDiagramType"

            name="Diagram Type for Chess Demo"

            type="chessDemo">

      </diagramType>

</extension>

Graphiti中的“add”是为业务对象(领域模型对象)创建图形表达。哪种业务(business)对象能够添加到特定类型的diagram里是由feature provider发布的 add feature决定的。

Graphiti支持Pictogram links,即领域模型的元素与定义图形化展示的模型(Pictogram model)的元素的链接。每个diagram有一个容器(图形,例如矩形)装载pictogram links

 

 



figure ['fɪgə]: 数字;人物;图形; 计算;描绘

feature ['fiːtʃə]: 特性,功能;

feather['feðə]:羽毛 

deliver:传递,转发,提供,交付,发布,释放


原创粉丝点击