gef中连接线设置抗锯齿

方法:更改策略
绘制完成线后,在其所在editpart中的refreshVisuals()中获取连接线线层后,设置setAntialias(SWT.ON)即可
今天有人问我该加在哪,我也不拐弯抹角了,
在最底层画布的model上对应的part复写refreshVisuals(),在里面编写Animation.markBegin();
ConnectionLayer connectionLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
connectionLayer.setConnectionRouter(new ManhattanConnectionRouter());
    if ((getViewer().getControl().getStyle() & SWT.MIRRORED ) == 0)
        connectionLayer.setAntialias(SWT.ON);
    Animation.run(400);


这样就可以了,但是这样就不能划斜线了,那么如何更改呢?改换策略
  ConnectionLayer connectionLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER); 
  connectionLayer.setConnectionRouter(new ShortestPathConnectionRouter(figure)); 
  connectionLayer.setAntialias(SWT.ON);  

或者
ConnectionLayer connectionLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);connectionLayer.setConnectionRouter(null);connectionLayer.setAntialias(SWT.ON);
也能搞定

你可能感兴趣的:(gef connection)