Java Code Examples for org.eclipse.gef.editparts.ZoomManager#setZoomLevelContributions()
The following examples show how to use
org.eclipse.gef.editparts.ZoomManager#setZoomLevelContributions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SankeyDiagram.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override protected void configureGraphicalViewer() { super.configureGraphicalViewer(); MenuManager menu = SankeyMenu.create(this); getGraphicalViewer().setContextMenu(menu); GraphicalViewer viewer = getGraphicalViewer(); viewer.setEditPartFactory(new SankeyEditPartFactory()); ScalableRootEditPart root = new ScalableRootEditPart(); viewer.setRootEditPart(root); // append zoom actions to action registry ZoomManager zoom = root.getZoomManager(); getActionRegistry().registerAction(new ZoomInAction(zoom)); getActionRegistry().registerAction(new ZoomOutAction(zoom)); zoom.setZoomLevelContributions(Arrays.asList( ZoomManager.FIT_ALL, ZoomManager.FIT_HEIGHT, ZoomManager.FIT_WIDTH)); // create key handler KeyHandler keyHandler = new KeyHandler(); keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_IN)); keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT)); viewer.setKeyHandler(keyHandler); viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE), MouseWheelZoomHandler.SINGLETON); }
Example 2
Source File: ERDiagramEditor.java From ermasterr with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private void initViewerAction(final GraphicalViewer viewer) { final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram); viewer.setRootEditPart(rootEditPart); final ZoomManager manager = rootEditPart.getZoomManager(); final double[] zoomLevels = new double[] {0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0}; manager.setZoomLevels(zoomLevels); final List<String> zoomContributions = new ArrayList<String>(); zoomContributions.add(ZoomManager.FIT_ALL); zoomContributions.add(ZoomManager.FIT_HEIGHT); zoomContributions.add(ZoomManager.FIT_WIDTH); manager.setZoomLevelContributions(zoomContributions); final ZoomInAction zoomInAction = new ZoomInAction(manager); final ZoomOutAction zoomOutAction = new ZoomOutAction(manager); final ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager); getActionRegistry().registerAction(zoomInAction); getActionRegistry().registerAction(zoomOutAction); getActionRegistry().registerAction(zoomAdjustAction); addKeyHandler(zoomInAction); addKeyHandler(zoomOutAction); final IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER); gridLayer.setForegroundColor(Resources.GRID_COLOR); IAction action = new ToggleGridAction(viewer); getActionRegistry().registerAction(action); action = new ToggleSnapToGeometryAction(viewer); getActionRegistry().registerAction(action); action = new ChangeBackgroundColorAction(this, diagram); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new TooltipAction(this); getActionRegistry().registerAction(action); action = new LockEditAction(this); getActionRegistry().registerAction(action); action = new ExportToDBAction(this); getActionRegistry().registerAction(action); actionBarContributor = new ERDiagramActionBarContributor(); actionBarContributor.init(getEditorSite().getActionBars(), getSite().getPage()); // action = new ToggleRulerVisibilityAction(viewer); // this.getActionRegistry().registerAction(action); }
Example 3
Source File: MainDiagramEditor.java From erflute with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected void initViewerAction(GraphicalViewer viewer) { final ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart(diagram); viewer.setRootEditPart(rootEditPart); final ZoomManager manager = rootEditPart.getZoomManager(); final double[] zoomLevels = new double[] { 0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 }; manager.setZoomLevels(zoomLevels); final List<String> zoomContributions = new ArrayList<>(); zoomContributions.add(ZoomManager.FIT_ALL); zoomContributions.add(ZoomManager.FIT_HEIGHT); zoomContributions.add(ZoomManager.FIT_WIDTH); manager.setZoomLevelContributions(zoomContributions); final ZoomInAction zoomInAction = new ZoomInAction(manager); final ZoomOutAction zoomOutAction = new ZoomOutAction(manager); final ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager); getActionRegistry().registerAction(zoomInAction); getActionRegistry().registerAction(zoomOutAction); getActionRegistry().registerAction(zoomAdjustAction); addKeyHandler(zoomInAction); addKeyHandler(zoomOutAction); final IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER); gridLayer.setForegroundColor(DesignResources.GRID_COLOR); IAction action = new ToggleGridAction(viewer); getActionRegistry().registerAction(action); action = new ChangeBackgroundColorAction(this, diagram); getActionRegistry().registerAction(action); getSelectionActions().add(action.getId()); action = new ToggleMainColumnAction(this); getActionRegistry().registerAction(action); action = new LockEditAction(this); getActionRegistry().registerAction(action); action = new ExportToDBAction(this); getActionRegistry().registerAction(action); this.actionBarContributor = new ERDiagramActionBarContributor(zoomComboContributionItem); }
Example 4
Source File: ERDiagramEditor.java From ermaster-b with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected void initViewerAction(GraphicalViewer viewer) { ScalableFreeformRootEditPart rootEditPart = new PagableFreeformRootEditPart( this.diagram); viewer.setRootEditPart(rootEditPart); ZoomManager manager = rootEditPart.getZoomManager(); double[] zoomLevels = new double[] { 0.1, 0.25, 0.5, 0.75, 0.8, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 }; manager.setZoomLevels(zoomLevels); List<String> zoomContributions = new ArrayList<String>(); zoomContributions.add(ZoomManager.FIT_ALL); zoomContributions.add(ZoomManager.FIT_HEIGHT); zoomContributions.add(ZoomManager.FIT_WIDTH); manager.setZoomLevelContributions(zoomContributions); ZoomInAction zoomInAction = new ZoomInAction(manager); ZoomOutAction zoomOutAction = new ZoomOutAction(manager); ZoomAdjustAction zoomAdjustAction = new ZoomAdjustAction(manager); this.getActionRegistry().registerAction(zoomInAction); this.getActionRegistry().registerAction(zoomOutAction); this.getActionRegistry().registerAction(zoomAdjustAction); this.addKeyHandler(zoomInAction); this.addKeyHandler(zoomOutAction); IFigure gridLayer = rootEditPart.getLayer(LayerConstants.GRID_LAYER); gridLayer.setForegroundColor(Resources.GRID_COLOR); IAction action = new ToggleGridAction(viewer); this.getActionRegistry().registerAction(action); action = new ChangeBackgroundColorAction(this, this.diagram); this.getActionRegistry().registerAction(action); this.getSelectionActions().add(action.getId()); action = new EditExcelAction(this, this.diagram); this.getActionRegistry().registerAction(action); this.getSelectionActions().add(action.getId()); action = new ToggleMainColumnAction(this); this.getActionRegistry().registerAction(action); action = new LockEditAction(this); this.getActionRegistry().registerAction(action); action = new ExportToDBAction(this); this.getActionRegistry().registerAction(action); this.actionBarContributor = new ERDiagramActionBarContributor( this.zoomComboContributionItem); // action = new ToggleRulerVisibilityAction(viewer); // this.getActionRegistry().registerAction(action); // // action = new ToggleSnapToGeometryAction(viewer); // this.getActionRegistry().registerAction(action); }