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.
          主站蜘蛛池模板: 禹州市| 宁强县| 新和县| 娱乐| 达孜县| 焦作市| 莱州市| 濮阳县| 肇源县| 栾川县| 澄迈县| 科技| 清水县| 上饶县| 朝阳县| 普定县| 枣庄市| 修文县| 铁力市| 衡东县| 山丹县| 永靖县| 抚顺县| 瑞安市| 荣成市| 玛纳斯县| 湖北省| 新乡市| 固始县| 五莲县| 义马市| 长宁区| 临江市| 遵化市| 中西区| 始兴县| 汶上县| 滦平县| 洛川县| 潍坊市| 嘉峪关市|