GEF回顾——shapes示例分析(View篇)

来源:互联网 发布:金域名都公寓出售 编辑:程序博客网 时间:2024/05/16 09:54

    下面来简单描述一下这个工程中对应的View——视图。由于对应的图形元素(Figure)都很简单,这里没有用单独的类来描述图形元素,而是使用GEF或者Draw2D中内置的几种Figure:Ellipse(椭圆)、RectangleFigure(矩形)和PolylineConnection(连接线)。这些Figure都将作为RootFigure的children,安放在RootFigure上。这里ShapeDragram对应的图形为FreeformLayer(一个可以扩展的Layer)。


    我们来把上面得model和view关联起来:
a)    Connection <-->PolylineConnection
b)    EllipticalShape <-->Ellipse
c)    RectangularShape <-->RectangleFigure
d)    ShapeDiagram <-->  FreeformLayer

 

这里简单讲解一下Connection对应的图形元素PolylineConnectionPolylineConnection是一种基于线条的连接,是最常用的连接之一,它的主要特点有:

a)        连接线有实线、虚线、点线等之分,同时还可以设定颜色、宽度

b)        有双向连接和单向连接之分,通过设定源和目的箭头装饰

setTargetDecoration(newPolygonDecoration())

当然,不设定则默认为无箭头的连接

c)        连接可以弯曲,由Bendpoint负责

d)        可以设置连接路径,比如使用最短路径连接还是弯曲连接

setConnectionRouter(ConnectionRoutercr)

常见的ConnectionRouterBendpointConnectionRouter, FanRouter,

ConnectionRouter.NullConnectionRouter,ManhattanConnectionRouter,ShortestPathConnectionRouter(详细见org.eclipse.draw2d类包API

PolylineConnectionConnectionLayer中均有此方法,注意相互设置的影响,一般以ConnectionLayer设置的优先

ManhattanConnectionRouter

ManhattanConnectionRouter,

ShortestPathConnectionRouter

ShortestPathConnectionRouter

        ConnectionRouter.NullConnectionRouter

 

 

原创粉丝点击