读书人

gef中默许提供的RootEditPart

发布时间: 2012-06-26 10:04:13 作者: rapoo

gef中默认提供的RootEditPart

在我们实现一个gef编辑器的时候,会重新configureGraphicalViewer()方法,在这个方法里面我们会为GraphicalViewer设置一个RootEditPart,一般是ScalableFreeformRootEditPart。

?

RootEditPart接口:这个接口定义了几个方法,主要是用于获取当前的EditPartViewer,在gef中EditPartViewer才是我们在界面看到的一个个有效单元,而EditPart只是它的一个控制器。

?

1.FreeformGraphicalRootEditPart:一个gef默认提供的类,它是一个RootEditPart,它默认的建立了N个Layer,用分层展示的方式,展示编辑器中的界面元素,所有的layer都放在FreeformViewport里面。

?

关于创建layer的代码:

?

getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE,                false);        getGraphicalViewer().setProperty(SnapToGrid.PROPERTY_GRID_ENABLED,                false);        getGraphicalViewer().setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED,                true);

?

ScalableFreeformRootEditPart:是FreeformGraphicalRootEditPart的子类,它里面增加了一个ZoomManager的功能。

?

RulerRootEditPart:为编辑提供游标功能的EditPart,主要被gef默认提供的封装组件RulerComposite使用。RulerComposite大家肯定熟悉,是用于实现游标的那个功能的。

?

ScalableRootEditPart:能够缩放,但是不自由伸展。

?

读书人网 >开源软件

热点推荐