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

    下面来简单描述一下这个工程中对应的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 对应的图形元素 PolylineConnection PolylineConnection 是一种基于线条的连接,是最常用的连接之一,它的主要特点有:

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

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

setTargetDecoration(new PolygonDecoration())

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

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

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

setConnectionRouter(ConnectionRouter cr)

常见的 ConnectionRouter BendpointConnectionRouter, FanRouter,

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

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

ManhattanConnectionRouter

ManhattanConnectionRouter,

ShortestPathConnectionRouter

ShortestPathConnectionRouter

        ConnectionRouter.NullConnectionRouter

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值