Dengues Studio: Google Group:http://groups.google.com/group/dengues; QQ Group:24885404.
          GEF的默認Connection只是一根直線但是在實際運用中,用到了不同的線型.
          你只要在相應的Connection Edit Part里面的Figure里面添加一個Router.
           keyFigure.setConnectionRouter(new FKRouter());
          我這里產生的效果是:


          代碼如下:

          在GEF里面自帶一些線型:
          public class FKRouter extends AbstractRouter {

              
          /**
               * Qiang.Zhang.Adolf@gmail.com FKRouter constructor comment.
               
          */
              
          public FKRouter() {
              }

              
          private void processPositions(Ray start, Ray end, Connection conn) {
                  
          int i = 1;
                  PointList points 
          = new PointList();
                  points.addPoint(
          new Point(start.x, start.y));
                  Point p 
          = new Point(00);
                  
          if (start.x == end.x || start.x > end.x && Math.abs(start.x - end.x) > 40) {
                      i 
          = -1;
                  }
                  p.x 
          = start.x + i * 20;
                  p.y 
          = start.y;
                  points.addPoint(p);

                  
          if (Math.abs(start.x - end.x) < 40) {
                      i 
          = i * -1;
                  }
                  p 
          = new Point(00);
                  p.x 
          = end.x - i * 20;
                  p.y 
          = end.y;
                  points.addPoint(p);

                  points.addPoint(
          new Point(end.x, end.y));
                  conn.setPoints(points);
              }

              
          /**
               * 
          @see ConnectionRouter#route(Connection)
               
          */
              
          public void route(Connection conn) {
                  
          if ((conn.getSourceAnchor() == null|| (conn.getTargetAnchor() == null))
                      
          return;
                  Point startPoint 
          = getStartPoint(conn);
                  conn.translateToRelative(startPoint);
                  Point endPoint 
          = getEndPoint(conn);
                  conn.translateToRelative(endPoint);

                  Ray start 
          = new Ray(startPoint);
                  Ray end 
          = new Ray(endPoint);

                  processPositions(start, end, conn);
              }

          }
          BendpointConnectionRouter這個是折線。
          ManhattanConnectionRouter垂直水平線。




          Dengues論壇(http://groups.google.com/group/dengues/),一個很好的Eclipse開發者樂園.

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          Dengues Studio: Google Group:http://groups.google.com/group/dengues; QQ Group:24885404.
          主站蜘蛛池模板: 高唐县| 太仓市| 衡水市| 黄龙县| 织金县| 东辽县| 和硕县| 通海县| 淳化县| 陈巴尔虎旗| 扶沟县| 门源| 文登市| 海丰县| 沅陵县| 赫章县| 吉首市| 日照市| 株洲县| 清远市| 泗阳县| 新民市| 林芝县| 大姚县| 琼海市| 德兴市| 焉耆| 大荔县| 青铜峡市| 汉阴县| 盐源县| 牙克石市| 汉中市| 岱山县| 工布江达县| 高唐县| 金川县| 杂多县| 阿坝| 宁城县| 横峰县|