- 浏览: 977551 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
运乃强谦:
老哥,你确定这个wsdl 地址 可以访问?
[CXF] Server与Client实现方式五:HTTPS -
wangyudong:
由CXF实现的微服务需要有比较好的工具去测试RESTful A ...
[CXF] Server与Client实现方式四:JMS -
dengmiao:
JAXB学习三 (验证) -
panamera:
你好。可以提供maven pom配置是怎么配置的?不知道你使用 ...
[CXF] Server与Client实现方式四:JMS -
u010221220:
请问楼主一二三部分的代码都应该放在哪个函数体中。
使用JDI监听Java程序运行
之前有一篇文件介绍怎么实现GEF Editor中的图元的渐近、动态变化过程的显示技巧。
在GEF的Flow例子里,已经提供了另一种实现动态变化的方式,这个实现方法主要由以下三部分组成:
- 需要有一个辅助类,用于记录初始和终态,并计算渐近过程
- 需要自定义一个布局类,借助上面的辅助类来给出当前布局
- 需要窗口类控制器需要监听状态变化,以决定什么时候开始激活动态过程
- 每个可能属于变化集的对象都需要提供一个方法,用于把自己加入到这个变化集中。
下面一部分一部分的介绍。
首先第一个部分,就是辅助类的实现,不过我也没写过自己的实现方式,暂且先以flow中的类作例子,见附件GraphAnimation.zip.
第二部分也是一个类实现,简单如下:
class GraphLayoutManager extends AbstractLayout { private NumaDiagramNodePart diagram; GraphLayoutManager(NumaDiagramNodePart diagram) { this.diagram = diagram; } protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) { container.validate(); List children = container.getChildren(); Rectangle result = new Rectangle().setLocation(container.getClientArea().getLocation()); for (int i = 0; i < children.size(); i++) result.union(((IFigure)children.get(i)).getBounds()); result.resize(container.getInsets().getWidth(), container.getInsets().getHeight()); return result.getSize(); } public void layout(IFigure container) { GraphAnimation.recordInitialState(container); if (GraphAnimation.playbackState(container)) return; CompoundDirectedGraph graph = new CompoundDirectedGraph(); graph.setDirection(PositionConstants.EAST); Map partsToNodes = new HashMap(); diagram.contributeNodesToGraph(graph, partsToNodes); diagram.contributeEdgesToGraph(graph, partsToNodes); new CompoundDirectedGraphLayout().visit(graph); diagram.applyGraphResults(graph, partsToNodes); } }
这里借助了两个对象来实现过程:CompoundDirectedGraph和CompoundDirectedGraphLayout。
第三,监听状态变化,这部分主要就是通过在容器类中增加Command变化监听来实现,例如:
CommandStackListener stackListener = new CommandStackListener() { public void commandStackChanged(EventObject event) { if (!GraphAnimation.captureLayout(getFigure())) return; while (GraphAnimation.step()) getFigure().getUpdateManager().performUpdate(); GraphAnimation.end(); } }; public void activate() { super.activate(); getViewer().getEditDomain().getCommandStack().addCommandStackListener( stackListener); } public void deactivate() { getViewer().getEditDomain().getCommandStack() .removeCommandStackListener(stackListener); super.deactivate(); }
最后一部分,也就是参与的过程,虽然上面我们已经定义好了整个辅助过程,但是具体在这一过程中有哪些对象会参与,怎么参与,需要我们自己实现,例如A是容器对象,里面有B和C对象,且B和C之间有一条连线,那么一般来说,一旦有变化,那么B,C和他们连线都需要处理。
对于一个结点对象,处理过程通常如:
public void applyGraphResults(CompoundDirectedGraph graph, Map map) { for (int i = 0; i < getChildren().size(); i++) { NumaNodePart node = (NumaNodePart) getChildren().get(i); Dimension dimension = node.getFigure().getPreferredSize(-1, -1); Node n = (Node) map.get(node); node.getFigure().setBounds( new Rectangle(n.x, n.y, n.width, dimension.height)); applyEdgesResults(node, graph, map); } } public void contributeNodesToGraph(CompoundDirectedGraph graph, Map map) { GraphAnimation.recordInitialState(getContentPane()); for (int i = 0; i < getChildren().size(); i++) { NumaNodePart node = (NumaNodePart) getChildren().get(i); Node n = new Node(node); n.width = node.getFigure().getPreferredSize().width; n.height = node.getFigure().getPreferredSize().height; n.setPadding(new Insets(10, 8, 30, 12)); map.put(node, n); graph.nodes.add(n); } } public void contributeEdgesToGraph(CompoundDirectedGraph graph, Map map) { for (int i = 0; i < getChildren().size(); i++) { NumaNodePart node = (NumaNodePart) children.get(i); List outgoing = node.getSourceConnections(); for (int j = 0; j < outgoing.size(); j++) { NodeRelationPart conn = (NodeRelationPart) outgoing.get(j); conn.contributeToGraph(graph, map); } } } public void applyEdgesResults(NumaNodePart node, CompoundDirectedGraph graph, Map map) { List outgoing = node.getSourceConnections(); for (int j = 0; j < outgoing.size(); j++) { NodeRelationPart conn = (NodeRelationPart) outgoing.get(j); conn.applyGraphResults(graph, map); } }
对于连线,因为要处理他们的Bend点,通常如下:
protected void applyGraphResults(CompoundDirectedGraph graph, Map map) { Edge e = (Edge)map.get(this); NodeList nodes = e.vNodes; PolylineConnection conn = (PolylineConnection)getConnectionFigure(); // conn.setTargetDecoration(new PolygonDecoration()); if (nodes != null) { List bends = new ArrayList(); for (int i = 0; i < nodes.size(); i++) { Node vn = nodes.getNode(i); int x = vn.x; int y = vn.y; if (e.isFeedback()) { bends.add(new AbsoluteBendpoint(x, y + vn.height)); bends.add(new AbsoluteBendpoint(x, y)); } else { bends.add(new AbsoluteBendpoint(x, y)); bends.add(new AbsoluteBendpoint(x, y + vn.height)); } } conn.setRoutingConstraint(bends); } else { conn.setRoutingConstraint(Collections.EMPTY_LIST); } } public void contributeToGraph(CompoundDirectedGraph graph, Map map) { GraphAnimation.recordInitialState(getConnectionFigure()); Node source = (Node)map.get(getSource()); Node target = (Node)map.get(getTarget()); Edge e = new Edge(this, source, target); e.weight = 2; graph.edges.add(e); map.put(this, e); }
并且,在他们重连的时候需要处理:
figure.setConnectionRouter(new BendpointConnectionRouter(){ public void route(Connection conn) { GraphAnimation.recordInitialState(conn); if (!GraphAnimation.playbackState(conn)) super.route(conn); } });
- GraphAnimation.zip (2.3 KB)
- 下载次数: 26
发表评论
-
GEF中用鼠标移动画布
2011-12-27 13:37 1319第一步 增加Palette项: moveTool = n ... -
Draw2d的ScrollPane的使用
2011-04-19 15:05 1579ScrollPane scrollpane = ne ... -
(译)Eclipse Zest二
2011-01-07 15:41 19005. Zest和JFace的例子 5.1 创建工程 创建一 ... -
(译)Eclipse Zest一
2011-01-07 15:14 28291. Eclipse Zest 1.1 概述 Eclips ... -
增加GEF的动态性
2011-01-06 10:25 1741在一个GEF应用中,最常的操作是移位和缩放。移位和缩放实现本身 ... -
GEF中Palette项的属性页显示
2010-11-04 14:25 1941一般来说我们只需要在GraphicalViewer部分显示在P ... -
定制GEF的Palette
2009-11-23 16:35 2493用GEF框架实现一个Editor时,会有一个默认的palett ... -
GEF增加之连接助手二
2009-10-29 16:01 995上一篇说过怎么实现悬浮连接助手。一直想要怎么实现悬浮连接助手。 ... -
GEF功能增强之创建助手
2009-09-28 09:09 1667用过GMF就知道,GMF默认生成的editor有一个悬浮的创建 ... -
GEF功能增强之连接助手
2009-09-10 14:45 1771GEF图形编辑器中,通常 ... -
GEF中实现“拷贝为图片”
2009-09-06 09:13 1314在一个GEF的编辑器中,编辑器上是一个个的Figure,从外观 ... -
GEF中扩大、缩小时处理编辑行为
2008-12-30 10:54 1492我们为GEF应用提供了ZoomIn和ZoomOut功能之后,在 ... -
改变GEF的一些默认行为
2008-12-29 14:12 1385一、改变Layer GEF中会根据editpart的类 ... -
GEF中一个模型的多层图的问题
2008-12-26 16:00 1607一般来说,我们在做GEF的时候,通常是一个模型对应一个图,这个 ... -
GEF中增加ContextMenu的支持
2008-12-19 22:32 2601GEF中,增加对EditPart的右键菜单的支持是很普遍的一 ... -
增加Palette的拖放支持
2008-12-19 14:08 1927默认情况下,GEF中要创建一个新的结点都是通点在Palette ... -
给GEF拖放功能
2008-07-17 10:26 1854我们知道SWT支持Native的拖放。GEF使用SWT的拖放来 ... -
修改GEF中Connection的端点
2008-07-14 16:09 1787GEF中,选中一条连接线,默认的端点是两个小黑框,如下: ... -
GEF中导视图的使用
2008-07-10 17:01 2142有时增加一个导视图能给用户很大的方便性,例如在outline视 ... -
(接上篇)关于GEF Feedback的补充
2008-07-10 10:18 1373重复上篇,我们有以下类: 1、模型相关:RouteMap、H ...
相关推荐
GEF-ALL-3.7 GEF-ALL-3.8 官方包。 GEF Draw2d 学习资料
GEF入门必读 GEF入门系列 GEF-whole-upload 感谢八进制
GEF: Graphical Editing Framework <br>GEF是一套MVC Framework,它能帮你比较容易的建立图形化的编辑器,V(View)的部分常常是基于SWT的Draw2D,因此Draw2D也看作是GEF的一部分。依赖:org.eclipse.gef***, org...
安装m2eclipse插件时会依赖gef插件和svn插件,压缩包内包含m2eclipse + gef + svn的全部插件安装包,可以直接离线安装,本人亲测,在Eclipse3.7下安装成功,可以新建Maven项目。 需要注意的是,在离线安装时,切记...
我下的资源的打包,希望有帮助,包括:GEF_Tutorial,GEF实例,入门教程,GEF-whole-upload
这是我参考了一些其他资料,自己写的一个GEF示例程序。 在这个demo中你可以看到以下的功能: 1. 往画布上添加多种节点 2. 节点之间的连线 3. 节点内容的编辑功能 4. 删除连线 5. 删除节点 6. 对节点的拖动以改变...
Agenda Start things off What is GEF? GEF Demo Draw2d Overview Example GEF Overview Break Hands-on Activity: Shapes Example
Eclipse的图形编辑框架GEF的参考API,chm格式
GEF eclipse 插件
GEF简易教程-学习GEF的入门教程,不错的gef入门教程
gef 绘图折线的实现方法。 gef API chm 格式
GEF入门实例代码2《Eclipse插件开发》中实例
GEF-II电场仪使用手册
这是我自己在学习GEF的时候做的一些总结。 1、GEF中的概念比如Command,Tool,Request等等。 2、GEF中使用到的几种设计模式。 3、GEF中对鼠标键盘事件处理的机制、流程。
GEF.rar GEF.rar GEF.rar
GEF 入门系列 GEF
GEF理解之第三部分,学习gef必备文档资料啊,值得下载
GEF理解之第一部分,学习gef必备文档资料啊,值得下载
Eclipse插件GEF的介绍,对于学习GEF有很大帮助