- 浏览: 264507 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (152)
- lucene (5)
- java (12)
- eclipse (2)
- GEF (34)
- SWT/JFACE/PLUGIN (58)
- EMF (8)
- GMF (0)
- fckeditor (1)
- AIX (1)
- 云计算 (2)
- 使用 Grails 构建富 Internet 应用程序 (1)
- Grails (1)
- 动态调用动态语言 (2)
- W3C DOM (3)
- Google Maps (1)
- 优化 (1)
- WebSphere (1)
- NSIS (1)
- 计算机安全 (1)
- Mina (2)
- Draw2d (4)
- Compass (1)
- 原创诗集 (3)
- 人生 (1)
- 翻版 (1)
- OSGI (1)
- Ubuntu (2)
- Ireport (2)
最新评论
-
扬手就是一长鞭:
移动label也无法使得save可以执行。
让连线上的Label动起来吧 -
扬手就是一长鞭:
我的save是正常的,我添加删除node或者connectio ...
让连线上的Label动起来吧 -
扬手就是一长鞭:
我也是这扥写的,可是我双击label改变他的文字时,发现sav ...
让连线上的Label动起来吧 -
ae6623:
这段代码放到哪里??
控制拖拽范围 -
ae6623:
真牛!鼠标滚轮缩放GEF画布 ..
getGraphicalV ...
GEF实现用鼠标滑轮控制画布的放大与缩小
我这里以gef.tutorial.step为例,在此工程基础修改代码实现该功能
首先将ContentsEditPart的布局做如下调整
然后实现连线转折点模型:
在来实现Command:
关于转折点的命令这里做了个基类以便添加删除移动实现的方便BendpointCommand:
CreateBendpointCommand:
MoveBendpointCommand:
DeleteBendpointCommand:
对应的Plicy做如下修改:
首先将ContentsEditPart的布局做如下调整
protected IFigure createFigure() { Layer figure = new Layer() { public void paint(Graphics graphics) { graphics.setAntialias(SWT.ON); graphics.setTextAntialias(SWT.ON); super.paint(graphics); } }; figure.setLayoutManager(new XYLayout()); ConnectionLayer layer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER); layer.setConnectionRouter(ConnectionRouter.NULL); return figure; }
然后实现连线转折点模型:
/******************************************************************************* * Copyright (c) 2005-2011, Chinese Eclipse Community(CEC) All rights reserved. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.ceclipse.org * * Contributors: * Ming.He <heming@ceclipse.com> - initial API and implementation *******************************************************************************/ package gef.tutorial.step.parts; import java.io.Serializable; import org.eclipse.draw2d.Bendpoint; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; /** * TODO 此处填写 class 信息 * * @author Ming.He * @date 2011-4-15 */ public class ConnectionBendpoint implements Serializable, Bendpoint { /** * */ private static final long serialVersionUID = 1L; private float weight = 0.5f; private Dimension d1 = null; private Dimension d2 = null; public ConnectionBendpoint() { // ignore } public ConnectionBendpoint(Dimension dim1, Dimension dim2) { d1 = dim1; d2 = dim2; } public Dimension getFirstRelativeDimension() { return d1; } public Point getLocation() { return null; } public Dimension getSecondRelativeDimension() { return d2; } public float getWeight() { return weight; } public void setRelativeDimensions(Dimension dim1, Dimension dim2) { d1 = dim1; d2 = dim2; } public void setWeight(float w) { weight = w; } }
在来实现Command:
关于转折点的命令这里做了个基类以便添加删除移动实现的方便BendpointCommand:
/******************************************************************************* * Copyright (c) 2005-2011, Chinese Eclipse Community(CEC) All rights reserved. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.ceclipse.org * * Contributors: * Ming.He <heming@ceclipse.com> - initial API and implementation *******************************************************************************/ package gef.tutorial.step.commands; import gef.tutorial.step.model.AbstractConnectionModel; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.gef.commands.Command; /** * TODO 此处填写 class 信息 * * @author Ming.He * @date 2011-4-15 */ public class BendpointCommand extends Command { protected int index = 0; protected Point location = null; protected AbstractConnectionModel connectionModel = null; private Dimension d1 = null; private Dimension d2 = null; protected Dimension getFirstRelativeDimension() { return d1; } protected Dimension getSecondRelativeDimension() { return d2; } protected int getIndex() { return index; } @SuppressWarnings("unused") protected Point getLocation() { return location; } protected AbstractConnectionModel getConnectionModel() { return connectionModel; } public void redo() { execute(); } public void setRelativeDimensions(Dimension dim1, Dimension dim2) { d1 = dim1; d2 = dim2; } public void setIndex(int i) { index = i; } public void setLocation(Point p) { location = p; } public void setConnectionModel(AbstractConnectionModel connection) { connectionModel = connection; } }
CreateBendpointCommand:
/******************************************************************************* * Copyright (c) 2005-2011, Chinese Eclipse Community(CEC) All rights reserved. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.ceclipse.org * * Contributors: * Ming.He <heming@ceclipse.com> - initial API and implementation *******************************************************************************/ package gef.tutorial.step.commands; import gef.tutorial.step.parts.ConnectionBendpoint; /** * TODO 此处填写 class 信息 * * @author Ming.He * @date 2011-4-15 */ public class CreateBendpointCommand extends BendpointCommand { public void execute() { ConnectionBendpoint rbp = new ConnectionBendpoint(getFirstRelativeDimension(), getSecondRelativeDimension()); getConnectionModel().addBendpoint(getIndex(), rbp); super.execute(); } public void undo() { super.undo(); getConnectionModel().removeBendpoint(getIndex()); } }
MoveBendpointCommand:
/******************************************************************************* * Copyright (c) 2005-2011, Chinese Eclipse Community(CEC) All rights reserved. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.ceclipse.org * * Contributors: * Ming.He <heming@ceclipse.com> - initial API and implementation *******************************************************************************/ package gef.tutorial.step.commands; import gef.tutorial.step.parts.ConnectionBendpoint; /** * TODO 此处填写 class 信息 * * @author Ming.He * @date 2011-4-15 */ public class MoveBendpointCommand extends BendpointCommand { private ConnectionBendpoint bendpoint = null; public void execute() { bendpoint = (ConnectionBendpoint) getConnectionModel().getBendpoints().get(getIndex()); getConnectionModel().removeBendpoint(getIndex()); super.execute(); } public void undo() { super.undo(); getConnectionModel().addBendpoint(getIndex(), bendpoint); } }
DeleteBendpointCommand:
/******************************************************************************* * Copyright (c) 2005-2011, Chinese Eclipse Community(CEC) All rights reserved. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.ceclipse.org * * Contributors: * Ming.He <heming@ceclipse.com> - initial API and implementation *******************************************************************************/ package gef.tutorial.step.commands; import gef.tutorial.step.parts.ConnectionBendpoint; /** * TODO 此处填写 class 信息 * * @author Ming.He * @date 2011-4-15 */ public class DeleteBendpointCommand extends BendpointCommand { private ConnectionBendpoint bendpoint = null; public void execute() { bendpoint = (ConnectionBendpoint) getConnectionModel().getBendpoints().get(getIndex()); getConnectionModel().removeBendpoint(getIndex()); super.execute(); } public void undo() { super.undo(); getConnectionModel().addBendpoint(getIndex(), bendpoint); } }
对应的Plicy做如下修改:
/******************************************************************************* * Copyright (c) 2005-2011, Chinese Eclipse Community(CEC) All rights reserved. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.ceclipse.org * * Contributors: * Ming.He <heming@ceclipse.com> - initial API and implementation *******************************************************************************/ package gef.tutorial.step.policies; import gef.tutorial.step.commands.BendpointCommand; import gef.tutorial.step.commands.CreateBendpointCommand; import gef.tutorial.step.commands.DeleteBendpointCommand; import gef.tutorial.step.commands.MoveBendpointCommand; import gef.tutorial.step.model.AbstractConnectionModel; import org.eclipse.draw2d.Connection; import org.eclipse.draw2d.geometry.Point; import org.eclipse.gef.commands.Command; import org.eclipse.gef.editpolicies.BendpointEditPolicy; import org.eclipse.gef.requests.BendpointRequest; /** * TODO 此处填写 class 信息 * * @author Ming.He * @date 2011-4-15 */ public class CustomBendpointEditPolicy extends BendpointEditPolicy { protected Command getCreateBendpointCommand(BendpointRequest request) { CreateBendpointCommand command = new CreateBendpointCommand(); Point p = request.getLocation(); Connection conn = getConnection(); conn.translateToRelative(p); command.setLocation(p); Point ref1 = getConnection().getSourceAnchor().getReferencePoint(); Point ref2 = getConnection().getTargetAnchor().getReferencePoint(); conn.translateToRelative(ref1); conn.translateToRelative(ref2); command.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2)); command.setConnectionModel((AbstractConnectionModel) request.getSource().getModel()); command.setIndex(request.getIndex()); return command; } protected Command getDeleteBendpointCommand(BendpointRequest request) { BendpointCommand command = new DeleteBendpointCommand(); Point p = request.getLocation(); command.setLocation(p); command.setConnectionModel((AbstractConnectionModel) request.getSource().getModel()); command.setIndex(request.getIndex()); return command; } protected Command getMoveBendpointCommand(BendpointRequest request) { // ������bend���λ�� MoveBendpointCommand command = new MoveBendpointCommand(); Point p = request.getLocation(); Connection conn = getConnection(); conn.translateToRelative(p); command.setLocation(p); Point ref1 = getConnection().getSourceAnchor().getReferencePoint(); Point ref2 = getConnection().getTargetAnchor().getReferencePoint(); conn.translateToRelative(ref1); conn.translateToRelative(ref2); command.setRelativeDimensions(p.getDifference(ref1), p.getDifference(ref2)); command.setConnectionModel((AbstractConnectionModel) request.getSource().getModel()); command.setIndex(request.getIndex()); return command; } }
发表评论
-
缺省将Palette展开
2011-07-29 17:37 1471/** 弹出调色板使用状态的首选项标识 */ priv ... -
图元间多条连线处理方式
2011-04-10 01:10 1298DiagramEditPart implements Laye ... -
给Figure添加滚动条
2011-04-10 00:53 1909Draw2d中有ScrollPane这样一个IFigure,它 ... -
去掉子节点句柄
2011-04-09 19:40 1287虽然可以通过给子节点添加SelectionPolicy来完成对 ... -
给DiagramEditPart添加Request
2011-01-14 00:16 1091实现ScalableFreeformRootEditPart中 ... -
缺省将FlyoutPalette放在左边
2010-12-30 22:49 1100重写FlyoutPaletteComposite.Flyout ... -
连线上加文字
2010-12-30 13:50 1557前面写了个连线上显示文字,直接用的label,那样确实简单,但 ... -
实现GEF RulerComposite
2010-12-30 13:41 1776模型部分: public class ElementBase ... -
根据模型得到对应的控制器
2010-12-30 10:49 886(EditPart) getGraphicalViewer() ... -
创建连线后点击空白区域箭头恢复成默认样式
2010-12-29 21:39 1636关于连线创建的过程大家可以看http://blog.china ... -
GEF实现用鼠标滑轮控制画布的放大与缩小
2010-10-28 13:22 1911很简单哇,GEF已经实现了,一行代码我就不多说了,在confi ... -
实现GEF中editor的背景为网格
2010-05-13 17:32 1206在editor中的initializeGraphicalVie ... -
横向排列算法
2010-03-15 20:17 1165List<NetunitModel> childr ... -
星形排列算法
2010-03-15 20:15 1342List<NetunitModel> childr ... -
外部执行Command而Editor不提示已修改的解决办法
2009-12-21 16:19 1243理论:有些时候的需求往往不是通过plette来创建模型和连线以 ... -
选择或取消选择当前的EditPart,改变连线视图的连线样式
2009-12-21 14:45 1272在LineConnectionEditPart类中实现Abst ... -
自定义Decoration
2009-12-21 14:36 1377大家都知道new PolygonDecoration就表示带箭 ... -
让连线上的Label动起来吧
2009-12-19 12:24 1563大家都知道GEF中连线上的label默认是在线的中间,一旦要连 ... -
设置连线样式
2009-12-16 12:26 1624private void setConnectionShiap ... -
public忽悠了不少人啊
2009-12-09 16:29 1300当有人想继承org.eclipse.draw2d.graph中 ...
相关推荐
MapX本身提供了点图元移动功能,但是用起来不方便和直观,本例子采用状态模式的设计思路,实现了点图元的移动和缩放功能。
应用设计上,我完成了满足文件接口要求的命令行程序,完成了基于鼠标点击的图元绘制、基于鼠标拖曳的图元移动,和基于可视化锚点及鼠标滚轮的图元旋转、图元缩放,并将控制逻辑集成到 GUI 应用中。最终使用静态编译...
通 过 改 变 图 元 大 小 来 实 现 闪 烁,
目前已支持简单的矩形图元和图元间的连线(直线、直角连线两种),拖拽图元等能力。 该javascript library的实现借鉴了NetronLight的不少思路,相应地将之命名为ternlight。 目前,支持的主要能力如下: 1...
自定义QGraphicsItem图元,可以进行拖动绘制,拖动拉伸缩放图元的示例源码demo
地图图元修改工具 可批量修改选定图层的地图图元Style。
定义成SVG 格式的电力图元
相连图元转边框 可以实现相连的图元自动转换成边框
用AI 设计制作的 风向标 svg 图元
mapx 在地图上移动图元,在地图上画线
openGL实现线画图元,填充图元。 DDA算法和Bresenham算法画多边形,扫描线转换填充填充多边形
使用此方法不需要去搜索地图上的图元 就能直接对图元进行 删,改,查操作
基于GDI+的图元绘制拾取 C#实现 程序效果如博客http://blog.csdn.net/small_fish__/article/details/7394304所见
采用AutoLISP语言对AutoCAD软件进行了二次开发,用以实现各图元(即各直线段、圆弧以及直线段与圆弧)间位置关系的正确判断,为需要精确绘制草图的3D构图及至后序的编程加工提供方便。此二次开发程序使用起来方便准确。
VC + MapX 实现图元信息查询 控制,点击选择,矩形选择,圆形选择,多边形选择的实现。点击选种图元属性
计算机图形学上机程序之二维基本图元的生成代码
图元电脑行业管理软件
快速选择同类图元.lsp cad程序应用
绝对给力的好东西!2011年最新思科VISIO图元大全!
在已有电力图元的基础上,利用Visual C++平台,通过各个电力图元始末位置坐标的距离判断图元是否连接,然后定义一系列数组存储图元的类型、编号和连接节点号等信息,连接节点号相同的图元表示其实现了电力连接。...