學(xué)無止境 |
|
|||
日歷
統(tǒng)計(jì)
導(dǎo)航常用鏈接留言簿(2)隨筆分類隨筆檔案搜索最新評(píng)論
閱讀排行榜評(píng)論排行榜 |
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%.
|
![]() |
|
Copyright © lucia | Powered by: 博客園 模板提供:滬江博客 |