我的世界

          我的世界

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            2 Posts :: 1 Stories :: 0 Comments :: 0 Trackbacks

          2007年6月27日 #

          draw2d中的層到底有什么作用?
          posted @ 2007-06-27 11:19 賀輝 閱讀(278) | 評論 (0)編輯 收藏

          /*******************************************************************************
           * Copyright (c) 2000, 2005 IBM Corporation and others.
           * All rights reserved. This program and the accompanying materials
           * are made available under the terms of the Eclipse Public License v1.0
           * which accompanies this distribution, and is available at
           * http://www.eclipse.org/legal/epl-v10.html
           *
           * Contributors:
           *     IBM Corporation - initial API and implementation
           *******************************************************************************/
          package com.example.layout;

          import java.util.Iterator;

          import org.eclipse.draw2d.FreeformLayout;
          import org.eclipse.draw2d.IFigure;
          import org.eclipse.draw2d.geometry.Point;

          /**
           * A layout for {@link org.eclipse.draw2d.FreeformFigure FreeformFigures}.
           */
          public class FreeformLayout2
           extends FreeformLayout
           {
          int colum;
           
          int width;

           
          public FreeformLayout2(int colum, int width) {

           this.colum = colum;
           this.width = width;

          }

           

           public void layout(IFigure parent) {
            
            
            
           // parent.set
            
            
           System.out.println(parent.getClass().toString());

            
            
            
           //parent.getBounds().x=10;
           //parent.getBounds().y=20;
            int x = parent.getBounds().x;
            int y = parent.getBounds().y;
            /*
            int ph = parent.getBounds().height;
            int pw = parent.getBounds().width;
            int h = parent.getBounds().height / this.rows;
            int w = parent.getBounds().width / this.colum;*/

            Iterator children = parent.getChildren().iterator();
          System.out.println(x+"         "+y);
            
            
            IFigure f;

            int cx =x, cy =y;
            int  count=0;
            while (children.hasNext()) {
             count++;
             
             //System.out.println(pw);
             f = (IFigure) children.next();

             f.setLocation(new Point(cx, cy));

             f.setSize(width, width);
             cx +=width;
             if (count>=colum) {
              cx = 0;
              cy +=width;
              count=0;
             }

            
            }

           }

           


          }

          posted @ 2007-06-27 08:46 賀輝 閱讀(318) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 封丘县| 宣威市| 米泉市| 犍为县| 蓬莱市| 新沂市| 子洲县| 肃宁县| 祁门县| 昭通市| 如皋市| 泰兴市| 赣榆县| 吉林省| 突泉县| 海阳市| 盖州市| 原平市| 沽源县| 柯坪县| 梁河县| 宜黄县| 华亭县| 龙川县| 宜春市| 韩城市| 永修县| 晋宁县| 栖霞市| 宾川县| 红桥区| 宝丰县| 尖扎县| 法库县| 怀化市| 正安县| 巴青县| 巧家县| 阳原县| 广德县| 调兵山市|