學無止境  
          日歷
          <2005年10月>
          2526272829301
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345
          統計
          • 隨筆 - 9
          • 文章 - 0
          • 評論 - 2
          • 引用 - 0

          導航

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

           

          2005年10月25日

          You have implemented your own graphical editor as a new eclipse plugin. You are looking for a way to add zoom functions into the graphical editor. It is very easy!
          1. Add the action into the toolbar:
          ...in Class: ActionBarContributor...
              ...in Method: contributeToToolBar...
                  toolBarManager.add(getAction(GEFActionConstants.ZOOM_IN));
                  toolBarManager.add(getAction(GEFActionConstants.ZOOM_OUT));
                  toolBarManager.add(new ZoomComboContributionItem(getPage()));

          2. Connect the Zoom Manager with your edit part:
          ...in Class: YourEditor...
              ...in Method: configureGraphicalViewer...
                  ScalableFreeformRootEditPart rootEditPart= new ScalableFreeformRootEditPart();
                  getGraphicalViewer().setRootEditPart(rootEditPart);

                  ZoomManager manager = rootEditPart.getZoomManager();
                  IAction action = new ZoomInAction(manager);
                  getActionRegistry().registerAction(action);
                  action = new ZoomOutAction(manager);
                  getActionRegistry().registerAction(action);

                  //define the zoom possibilities
                  double[] zoomLevels = new double[] {0.25,0.5,0.75,1.0,1.5,2.0,2.5,3.0,4.0};
                  manager.setZoomLevels(zoomLevels);
             ...in Method: getAdapter...
                  if (type == ZoomManager.class)
                        return ((ScalableFreeformRootEditPart) getGraphicalViewer().
                                  getRootEditPart()).getZoomManager();

          That's all! Now you have two buttons to zoom in and zoom out. And you can see the zoom level in percent.  With the example here you  can change  zoom level from 25% to 400%.

          posted @ 2005-10-25 23:38 lucia 閱讀(1378) | 評論 (0)編輯 收藏
           
          Copyright © lucia Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 渭南市| 荆门市| 三河市| 天门市| 砀山县| 措美县| 益阳市| 晋州市| 高安市| 临邑县| 临泽县| 阳城县| 白城市| 福清市| 紫金县| 微山县| 蕲春县| 安化县| 遵义市| 余庆县| 巫溪县| 云梦县| 玉环县| 大丰市| 观塘区| 五华县| 浦东新区| 高雄市| 道孚县| 镇赉县| 宜良县| 香河县| 荣昌县| 凉城县| 贵州省| 乌鲁木齐市| 陆川县| 新安县| 龙里县| 迭部县| 五峰|