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.
          主站蜘蛛池模板: 中超| 清丰县| 商都县| 吉水县| 阿合奇县| 田林县| 顺昌县| 什邡市| 同德县| 萍乡市| 康保县| 本溪市| 井研县| 乐山市| 获嘉县| 宜宾县| 鹤峰县| 开封市| 嘉善县| 台前县| 阿城市| 襄垣县| 淳化县| 增城市| 海林市| 岫岩| 宜章县| 库尔勒市| 蒙自县| 文水县| 犍为县| 阿拉善右旗| 舟曲县| 宜城市| 绥宁县| 北海市| 都兰县| 金平| 太原市| 洛扎县| 大连市|