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.
          主站蜘蛛池模板: 福州市| 郑州市| 静乐县| 玉溪市| 织金县| 双城市| 新津县| 满洲里市| 宁武县| 九龙城区| 赤壁市| 罗平县| 临洮县| 宿州市| 万载县| 安岳县| 固安县| 黎城县| 乌拉特前旗| 诸城市| 阜南县| 土默特右旗| 扬州市| 基隆市| 石泉县| 江口县| 鄢陵县| 启东市| 天峻县| 凤冈县| 隆回县| 汽车| 澄江县| 宣城市| 定边县| 古交市| 无棣县| 嘉黎县| 托克托县| 青岛市| 宜黄县|