首页 新闻 会员 周边

GEF中实现对Polyline的节点编辑

0
悬赏园豆:50 [已关闭问题] 关闭于 2011-04-02 11:59

我在GEF中实现了画带多个折点的polyline,现在的问题是:当我选中该polyline时,那个Handle为一个矩形(由8个可拖拉的黑点组成),现在我希望,这些点能分布在polyline的拐点上,这样,我就可以通过拖拉这些点,来改变我的polyline,请问该如何实现?

网上有朋友写了如下函数

1 protected List<ResizeHandle> createSelectionHandles() {
2 List<ResizeHandle> list = new ArrayList<ResizeHandle>();
3 List<Point> points=((GraphicsPolyline)getHost().getModel()).getPointsList();
4 for(int i=0;i<points.size();i++)
5 {
6 Figure moveHandleRef=new Figure();
7 moveHandleRef.setSize(7, 7);
8 moveHandleRef.setLocation(new Point(points.get(i).x-2,points.get(i).y-2));
9 MoveHandleLocator mhl=new MoveHandleLocator(moveHandleRef);
10 list.add(new ResizeHandle((GraphicalEditPart) getHost(),mhl,null));
11 }
12 return list;
13 }
并说覆盖getLocator() 方法能实现这个功能,请问该如何覆盖getLocator() 方法?

hasegetc的主页 hasegetc | 初学一级 | 园豆:200
提问于:2011-03-24 11:48
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册