`
liugang594
  • 浏览: 978510 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

(译)Eclipse Zest一

    博客分类:
  • GEF
阅读更多

1. Eclipse Zest

1.1 概述

Eclipse Zest是一个可视化的图形工具。它基于SWT/Draw2D。Zest还支持JFace中Viewer的概念,因此允许模型和视图的分离。这篇文章假设你已经熟悉了Eclipse RCP或Eclipse Plugin开发。

 

(我注:其实也可以在一个普通的SWT程序中使用Zest)

 

1.2 组件

Eclipse Zest有以下组件:

 

  • GraphNode                --             graph中,带属性的结点
  • GraphConnections     --             graph中,用来连接两个结点的边线
  • GraphContainer         --             graph中,用来包含其他结点的容器
  • Graph                         --             根,用来包含所有其他的结点(nodes,connections,container)
(我注:graph可以理解为画板,用来画这些结点的)

1.3 布局

Zest提供了一些布局管理器,用来决定怎么布局graph上的结点。下面列出的就是所提供的一些布局:

表1 布局管理器

 

 

TreeLayoutAlgorithm Graph is displayed in the form of a vertical tree
HorizontalTreeLayoutAlgorithm Similar to TreeLayoutAlgorithm, but layout is horizontal
RadialLayoutAlgorithm Root is the center, the others nodes are placed around this node

GridLayoutAlgorithm

SpringLayoutAlgorithm

layout the graph, so that all connections should have approx the same length and that the edges overlap minimal
HorizontalShift move overlapping nodes to the right
CompositeLayoutAlgorithm combines other layout algorithms, for example, HorizontalShift can be the second layout algorithm to move nodes which were still overlapping if another algorithm is used.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1.4 Filter

可以通过调用setFilter(filter)方法,在布局上增加过滤器(org.eclipse.zest.layouts.filter),用于决定哪些结点和边线是可见的。filter收到一个LayoutItem对象,实际的graph结点可以通过方法getGraphData()得到。

2. 安装

(我注:好像现在安装完GEF后,自动就有了,所以这里略了)

3 你的第一个Zest工程

3.1 开始

创建一个Eclipse RCP应用“de.vogella.zest.first”。选择模板"Eclipse RCP with a view“。 增加"org.eclipse.zest.core" 和 "org.eclipse.zest.layouts" 依赖项。

 

修改"View.java"的代码如下,用于创建一个简单的graph和连接它的元素:

package de.vogella.zest.first;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.zest.core.widgets.Graph;
import org.eclipse.zest.core.widgets.GraphConnection;
import org.eclipse.zest.core.widgets.GraphNode;
import org.eclipse.zest.core.widgets.ZestStyles;
import org.eclipse.zest.layouts.LayoutStyles;
import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;
import org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm;

public class View extends ViewPart {
	public static final String ID = "de.vogella.zest.first.view";
	private Graph graph;
	private int layout = 1;

	public void createPartControl(Composite parent) {
		// Graph will hold all other objects
		graph = new Graph(parent, SWT.NONE);
		// Now a few nodes
		GraphNode node1 = new GraphNode(graph, SWT.NONE, "Jim");
		GraphNode node2 = new GraphNode(graph, SWT.NONE, "Jack");
		GraphNode node3 = new GraphNode(graph, SWT.NONE, "Joe");
		GraphNode node4 = new GraphNode(graph, SWT.NONE, "Bill");
		// Lets have a directed connection
		new GraphConnection(graph, ZestStyles.CONNECTIONS_DIRECTED, node1,
				node2);
		// Lets have a dotted graph connection
		new GraphConnection(graph, ZestStyles.CONNECTIONS_DOT, node2, node3);
		// Standard connection
		new GraphConnection(graph, SWT.NONE, node3, node1);
		// Change line color and line width
		GraphConnection graphConnection = new GraphConnection(graph, SWT.NONE,
				node1, node4);
		graphConnection.changeLineColor(parent.getDisplay().getSystemColor(
				SWT.COLOR_GREEN));
		// Also set a text
		graphConnection.setText("This is a text");
		graphConnection.setHighlightColor(parent.getDisplay().getSystemColor(
				SWT.COLOR_RED));
		graphConnection.setLineWidth(3);
		graphConnection.addListener(SWT.SELECTED, new Listener() {

			@Override
			public void handleEvent(Event event) {
				System.out.println("Selected");
			}

		});
		graph.setLayoutAlgorithm(new SpringLayoutAlgorithm(
				LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);

	}

	public void setLayoutManager() {
		switch (layout) {
		case 1:
			graph.setLayoutAlgorithm(new TreeLayoutAlgorithm(
					LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
			layout++;
			break;
		case 2:
			graph.setLayoutAlgorithm(new SpringLayoutAlgorithm(
					LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
			layout = 1;
			break;

		}

	}

	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
	}
}

 

运行以后,得到下图:

3.2 通过command来改变布局

创建一个command,并把以下"de.vogella.zest.first.handler.ChangeLayout"作为它的handler,此handler用于更改布局。最后把这个command加到一个menu上:

package de.vogella.zest.first.handler;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.handlers.HandlerUtil;

import de.vogella.zest.first.View;

public class ChangeLayout extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IViewPart findView = HandlerUtil.getActiveWorkbenchWindow(event)
				.getActivePage().findView("de.vogella.zest.first.view");
		View view = (View) findView;
		view.setLayoutManager();
		return null;
	}

}

 运行应用,如果你选择了上面的菜单,视图的布局将会改变

4.Zest和JFace

JFace提供了viewers用于分离数据和展现。请看Eclipse JFace TableViewer Eclipse JFace TreeViewer 。JFace要求一个content provider和一个label provider。Zest提供了一个"GraphViewer“作为一个viewer。content provider则是基于connections或者是nodes的。

 

标准的Zest content providers有:

Content Provider Description
IGraphContentProvider Based on the connections. The connections contain the information which nodes they refer to. Cannot display nodes without connections.
IGraphEntityContentProvider Based on the Node which contain the information about which relationship they have. These relationship are available in the label provider as EntityConnectionData objects.
IGraphEntityRelationshipContentProvider Node based, the content provider defines getRelationShips(sourceNode, destinationNode) which determines the connections. The advantages compared with IGraphEntityContentProvider is that you decide which objects you return.

 

Zest的label provider可以是一个标准的JFace的 ILabelProvider,也可以是Zest特定的IEntityStyleProvider。

 

分享到:
评论

相关推荐

    maven_eclipse_GEF-zest-3.7.1_m2e-extras_m2e.zip

    maven_eclipse_GEF-zest-3.7.1_m2e-extras_m2e.zip maven的eclipse插件

    maven与eclipse集成所需插件

    maven插件安装以及eclipse安装maven插件的资料

    压缩包里有maven的安装以及eclipse安装maven插件的资料,压缩包里有maven的安装以及eclipse安装maven插件的资料

    Eclipse Indigo 离线安装maven插件m2eclipse

    旧版本eclipse,比如indigo版本要安装maven,旧的在线安装方式已经失效,因为依赖的zest和m2eclipse的location url都已经无法访问。所以从已经安装这两个包的eclipse中分离出离线的安装包,拷贝到对应的features和...

    GEF-zest-3.6.1.zip

    GEF-zest-3.6.1.zipGEF-zest-3.6.1.zipGEF-zest-3.6.1.zipGEF-zest-3.6.1.zipGEF-zest-3.6.1.zipGEF-zest-3.6.1.zip

    zest-creator:用于创建有效的 zest 脚本并与脚本交互的节点包

    Zest Creator 工具,用于创建有效的 zest 脚本并通过辅助方法与脚本交互。 使用 安装它: ```bash $ npm i zest-creator ``` 需要它并使用: ```js var ZestCreator = require('zest-creator'); var opts = { ...

    西数WDC WD3200BPVT固件-80ZEST0-板号1672-WD-WXB1AC064983-01.01A01-0015002M-256-1091-KL

    自己用WDR备份的固件,WDC WD3200BPVT-80ZEST0-WD-WXB1AC064983-01.01A01-0015002M-256-1091-KL 测试完好

    Zest - Distilled Marketing Content-crx插件

    Zest不仅是一个内容共享平台,还比它更部落化。专业人士互相关注,查看他们建议,保存的内容,当然还可以个性化您的提炼内容流。选择与您相关的标签,并自定义Zest的主题和布局以适合您的喜好。还有一组内置功能可...

    Zest - New Tab for Marketing Content-crx插件

    Zest不仅仅是一个内容阅读平台-拥有20,000多名营销专家的社区互相追随,为发展自己的个人品牌或博客做出贡献,并将内容带给他们的团队以提高工作效率。 通过选择与您的专业需求相关的主题来个性化您的内容提要,并...

    Zest_Framework:Zest Framework的核心文件

    Zest提供了一组定义明确的工具包,可以处理这些事情,使您可以专注于构建应用程序。 Zest框架的目的对于PHP,当今有许多可用PHP框架,因此提出了一个问题,即为什么我们应该使用ZestFramework。 Zest框架的主要目的...

    Zest

    热情 这个项目编号是由开发: APIPHP Laravel Web应用程序的VueJS和TypeScript 作者

    Zest - The Zendesk Colour Coder-crx插件

    只需单击chrome浏览器右上角的图标,输入要上色的类别,选择一种颜色,然后单击添加。 刷新Zendesk页面以查看更改生效。 更改类别的颜色也很容易,只需单击类别名称旁边的颜色,然后进行更改并刷新Zendesk页面即可。...

    zest-runner:Zest runner 的 JavaScript 实现

    Zest 脚本的运行时。 使用 安装它: ```bash $ npm i zest-runner ``` 需要它并使用: ```js var ZestRunner = require('zest-runner'); var opts = { sourceType: 'file', file: 'abc.zst' }; var zr = new ...

    GEF-ALL-3.2.2

    GEF: Graphical Editing Framework <br>GEF是一套MVC Framework,它能帮你比较容易的...依赖:org.eclipse.draw2d*** 本软件GEF-ALL-3.2.2完整版包含(Draw2D, GEF and Zest) 大小:6.6M 请用于Eclipse3.2.2环境下.

    Python库 | zbs.zest-1.1.24.tar.gz

    python库。 资源全名:zbs.zest-1.1.24.tar.gz

    ZeST-开源

    ZeST是用于强调文件系统/磁盘的TUI程序。 仅对curses起作用,它可在任何POSIX系统上使用。 它为IPC使用fork()和一个命名的fifo。 如果一个进程启动太多,则可以终止单个进程,这不会中断测试。

    gef:Eclipse GEF:trade_mark:

    当前的代码库是与2004年以来提供的原始Draw2d 3.x , GEF(MVC)3.x和Zest 1.x项目组件并行开发的。直到4.0版本为止。 0(Neon)在2016年发布,此代码库分别称为'GEF4'或org.eclipse.gef4 ,这就是为什么这些术语仍...

    Zest是一款基于Spring的易于使用的单元测试工具(高分毕设).zip

    1. Spring框架:Spring是一个轻量级的Java开发框架,提供了丰富的功能和模块,用于开发企业级应用。它包括IoC(Inverse of Control,控制反转)容器、AOP(Aspect-Oriented Programming,面向切面编程)等特性,可以...

    GEF-ALL-3.7.1

    ECLIPSE相关插件 解决eclipse安装插件时提示以下错误 Java代码 Software being installed: Maven Integration for ...Software being installed: Maven Integration for Eclipse (Required) 0.12.1.20110112-1712

    Zest Assistant-crx插件

    一个虚拟屋顶下的所有文件只需连接您的信息源,并通过统一的智能搜索即可访问文件。 Zest当前与Gmail,Google云端硬盘,Confluence,Box,GitHub,Dropbox和Pocket同步。 再也不会中断您的工作流程所有文件都只是...

Global site tag (gtag.js) - Google Analytics