org.eclipse.gef.editparts.ZoomManager Java Examples
The following examples show how to use
org.eclipse.gef.editparts.ZoomManager.
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: ERFluteMultiPageEditorActionBarContributor.java From erflute with Apache License 2.0 | 6 votes |
@Override public void setActivePage(IEditorPart activeEditor) { final MainDiagramEditor editor = (MainDiagramEditor) activeEditor; final ERDiagramActionBarContributor actionBarContributor = editor.getActionBarContributor(); final IActionBars actionBars = getActionBars(); actionBars.clearGlobalActionHandlers(); actionBars.getToolBarManager().removeAll(); actionBarContributor.init(actionBars, editor.getEditorSite().getPage()); actionBarContributor.setActiveEditor(editor); final ZoomComboContributionItem item = (ZoomComboContributionItem) getActionBars().getToolBarManager().find(GEFActionConstants.ZOOM_TOOLBAR_WIDGET); if (item != null) { final ZoomManager zoomManager = (ZoomManager) editor.getAdapter(ZoomManager.class); item.setZoomManager(zoomManager); } getActionBars().updateActionBars(); }
Example #2
Source File: ERDiagramEditor.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public Object getAdapter(Class type) { if (type == ZoomManager.class) { return ((ScalableFreeformRootEditPart) getGraphicalViewer() .getRootEditPart()).getZoomManager(); } if (type == IContentOutlinePage.class) { return this.outlinePage; } if (type == IGotoMarker.class) { return this.gotoMaker; } if (type == IPropertySheetPage.class) { return this.propertySheetPage; } return super.getAdapter(type); }
Example #3
Source File: MainDiagramEditor.java From erflute with Apache License 2.0 | 6 votes |
@Override public Object getAdapter(@SuppressWarnings("rawtypes") Class type) { if (type == ZoomManager.class) { return ((ScalableFreeformRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager(); } if (type == IContentOutlinePage.class) { return outlinePage; } if (type == IGotoMarker.class) { return gotoMaker; } if (type == IPropertySheetPage.class) { return propertySheetPage; } return super.getAdapter(type); }
Example #4
Source File: GraphicalEditorWithFlyoutPalette.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ public Object getAdapter( Class type ) { if ( type == PalettePage.class ) { if ( splitter == null ) { page = createPalettePage( ); return page; } return createPalettePage( ); } if ( type == PaletteRoot.class ) { return getPaletteRoot( ); } if ( type == ZoomManager.class ) { return getGraphicalViewer( ).getProperty( ZoomManager.class.toString( ) ); } return super.getAdapter( type ); }
Example #5
Source File: ERDiagramLayoutEditPolicy.java From ermaster-b with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void showSizeOnDropFeedback(CreateRequest request) { Point p = new Point(request.getLocation().getCopy()); ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); IFigure feedback = getSizeOnDropFeedback(request); Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height) .expand(getCreationFeedbackOffset(request))); }
Example #6
Source File: EditorRulerFigure.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * @param manager */ public void setZoomManager( ZoomManager manager ) { if ( zoomManager != manager ) { if ( zoomManager != null ) { zoomManager.removeZoomListener( zoomListener ); } zoomManager = manager; if ( zoomManager != null ) { zoomManager.addZoomListener( zoomListener ); } } }
Example #7
Source File: ColumnSelectionHandlesEditPolicy.java From ermasterr with Apache License 2.0 | 6 votes |
private int getColumnIndex(final DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final ColumnEditPart columnEditPart = (ColumnEditPart) getHost(); Column column = (Column) columnEditPart.getModel(); final TableView newTableView = (TableView) getHost().getParent().getModel(); final List<Column> columns = newTableView.getColumns(); if (column.getColumnHolder() instanceof ColumnGroup) { column = (ColumnGroup) column.getColumnHolder(); } int index = columns.indexOf(column); final Rectangle columnRectangle = getColumnRectangle(); final int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom); if (editRequest.getLocation().y >= center) { index++; } return index; }
Example #8
Source File: ColumnSelectionHandlesEditPolicy.java From erflute with Apache License 2.0 | 6 votes |
private int getColumnIndex(DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final ColumnEditPart columnEditPart = (ColumnEditPart) getHost(); ERColumn column = (ERColumn) columnEditPart.getModel(); final TableView newTableView = (TableView) getHost().getParent().getModel(); final List<ERColumn> columns = newTableView.getColumns(); if (column.getColumnHolder() instanceof ColumnGroup) { column = (ColumnGroup) column.getColumnHolder(); } int index = columns.indexOf(column); final Rectangle columnRectangle = getColumnRectangle(); final int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom); if (editRequest.getLocation().y >= center) { index++; } return index; }
Example #9
Source File: TableViewComponentEditPolicy.java From ermaster-b with Apache License 2.0 | 6 votes |
private int getColumnIndex(DirectEditRequest editRequest) { ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); IFigure figure = ((TableViewEditPart) this.getHost()).getFigure(); int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom); int index = 0; if (editRequest.getLocation().y >= center) { TableView newTableView = (TableView) this.getHost().getModel(); index = newTableView.getColumns().size(); } return index; }
Example #10
Source File: MultipleShapesVerticalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * creates the command to move the shapes left or right. */ protected Command getCommand() { if (_container == null) { return null; } CompoundCommand command = new CompoundCommand("Multiple Shape Move"); TransactionalEditingDomain editingDomain = _container.getEditingDomain(); Point moveDelta = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy(); Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y); ZoomManager zoomManager = ((DiagramRootEditPart) getCurrentViewer().getRootEditPart()).getZoomManager(); spSizeDelta.scale(1/zoomManager.getZoom()); command.add(_container.getCommand(getSourceRequest())); for (IGraphicalEditPart sp : _subProcesses) { Dimension spDim = sp.getFigure().getBounds().getSize().getCopy(); spDim.expand(spSizeDelta); SetBoundsCommand setBounds = new SetBoundsCommand(editingDomain,"MultipleShape Move", sp, spDim); command.add(new ICommandProxy(setBounds)); } return command; }
Example #11
Source File: ERDiagramMultiPageEditorActionBarContributor.java From ermaster-b with Apache License 2.0 | 6 votes |
@Override public void setActivePage(IEditorPart activeEditor) { ERDiagramEditor editor = (ERDiagramEditor) activeEditor; ERDiagramActionBarContributor actionBarContributor = editor .getActionBarContributor(); IActionBars actionBars = this.getActionBars(); actionBars.clearGlobalActionHandlers(); actionBars.getToolBarManager().removeAll(); actionBarContributor.init(actionBars, editor.getEditorSite().getPage()); actionBarContributor.setActiveEditor(editor); ZoomComboContributionItem item = (ZoomComboContributionItem) getActionBars() .getToolBarManager().find( GEFActionConstants.ZOOM_TOOLBAR_WIDGET); if (item != null) { ZoomManager zoomManager = (ZoomManager) editor .getAdapter(ZoomManager.class); item.setZoomManager(zoomManager); } getActionBars().updateActionBars(); }
Example #12
Source File: MultipleShapesHorizontalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * creates the command to move the shapes left or right. */ protected Command getCommand() { if (_container == null) { return null; } CompoundCommand command = new CompoundCommand("Multiple Shape Move"); TransactionalEditingDomain editingDomain = _container.getEditingDomain(); Point moveDelta = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy(); Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y); ZoomManager zoomManager = ((DiagramRootEditPart) getCurrentViewer().getRootEditPart()).getZoomManager(); spSizeDelta.scale(1/zoomManager.getZoom()); command.add(_container.getCommand(getSourceRequest())); for (IGraphicalEditPart sp : _subProcesses) { Dimension spDim = sp.getFigure().getBounds().getSize().getCopy(); spDim.expand(spSizeDelta); SetBoundsCommand setBounds = new SetBoundsCommand(editingDomain,"MultipleShape Move", sp, spDim); command.add(new ICommandProxy(setBounds)); } return command; }
Example #13
Source File: ZoomAdjustAction.java From ermaster-b with Apache License 2.0 | 5 votes |
public ZoomAdjustAction(ZoomManager zoomManager) { super(ResourceString.getResourceString("action.title.zoom.adjust"), Activator.getImageDescriptor(ImageKey.ZOOM_ADJUST)); this.zoomManager = zoomManager; zoomManager.addZoomListener(this); setToolTipText(ResourceString .getResourceString("action.title.zoom.adjust")); setId(ID); }
Example #14
Source File: EditorDragGuidePolicy.java From birt with Eclipse Public License 1.0 | 5 votes |
public Command getCommand( Request request ) { Command cmd; final ChangeBoundsRequest req = (ChangeBoundsRequest) request; if ( isDeleteRequest( req ) ) { cmd = getGuideEditPart( ).getRulerProvider( ) .getDeleteGuideCommand( getHost( ).getModel( ) ); } else { int pDelta; if ( getGuideEditPart( ).isHorizontal( ) ) { pDelta = req.getMoveDelta( ).y; } else { pDelta = req.getMoveDelta( ).x; } if ( isMoveValid( getGuideEditPart( ).getZoomedPosition( ) + pDelta ) ) { ZoomManager zoomManager = getGuideEditPart( ).getZoomManager( ); if ( zoomManager != null ) { pDelta = (int) Math.round( pDelta / zoomManager.getZoom( ) ); } cmd = getGuideEditPart( ).getRulerProvider( ) .getMoveGuideCommand( getHost( ).getModel( ), pDelta ); } else { cmd = UnexecutableCommand.INSTANCE; } } return cmd; }
Example #15
Source File: ERDiagramMultiPageEditor.java From ermasterr with Apache License 2.0 | 5 votes |
private void initStartPage() { final int pageIndex = diagram.getPageIndex(); setActivePage(pageIndex); if (pageIndex > 0) { pageChange(pageIndex); } final ERDiagramEditor activeEditor = getActiveEditor(); final ZoomManager zoomManager = (ZoomManager) activeEditor.getAdapter(ZoomManager.class); zoomManager.setZoom(diagram.getZoom()); activeEditor.setLocation(diagram.getX(), diagram.getY()); }
Example #16
Source File: GraphicalEditorWithFlyoutPalette.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void hookZoom( ScalableFreeformRootEditPart root ) { List zoomLevels = new ArrayList( 3 ); zoomLevels.add( ZoomManager.FIT_ALL ); zoomLevels.add( ZoomManager.FIT_WIDTH ); zoomLevels.add( ZoomManager.FIT_HEIGHT ); root.getZoomManager( ).setZoomLevelContributions( zoomLevels ); IAction zoomIn = new ZoomInAction( root.getZoomManager( ) ); IAction zoomOut = new ZoomOutAction( root.getZoomManager( ) ); getActionRegistry( ).registerAction( zoomIn ); getActionRegistry( ).registerAction( zoomOut ); getSite( ).getKeyBindingService( ).registerAction( zoomIn ); getSite( ).getKeyBindingService( ).registerAction( zoomOut ); }
Example #17
Source File: DesignerActionBarContributor.java From birt with Eclipse Public License 1.0 | 5 votes |
public void contributeToToolBar( IToolBarManager tbm ) { tbm.add( new Separator( ) ); String[] zoomStrings = new String[]{ ZoomManager.FIT_ALL, ZoomManager.FIT_HEIGHT, ZoomManager.FIT_WIDTH }; ZoomComboContributionItem zoomComboContributionItem = new ZoomComboContributionItem( getPage( ), zoomStrings ) { protected Control createControl( Composite parent ) { Control control = super.createControl( parent ); control.setToolTipText( Messages.getString( "DesignerActionBarContributor.menu.zoomCombo.tooltip" ) ); return control; } }; if ( getPage( ) != null && getPage( ).getActivePart( ) != null ) { zoomComboContributionItem.setZoomManager( (ZoomManager) getPage( ).getActivePart( ) .getAdapter( ZoomManager.class ) ); } zoomComboContributionItem.setVisible( true ); tbm.add( zoomComboContributionItem ); toggleBreadcrumbAction = new ToggleBreadcrumbAction( getPage( ) ); tbm.add( toggleBreadcrumbAction ); }
Example #18
Source File: XtextDirectEditManager.java From statecharts with Eclipse Public License 1.0 | 5 votes |
/** * This method obtains the fonts that are being used by the figure at its * zoom level. * * @param gep * the associated <code>GraphicalEditPart</code> of the figure * @param actualFont * font being used by the figure * @param display * @return <code>actualFont</code> if zoom level is 1.0 (or when there's an * error), new Font otherwise. */ private Font getZoomLevelFont(Font actualFont, Display display) { Object zoom = getEditPart().getViewer().getProperty(ZoomManager.class.toString()); if (zoom != null) { double zoomLevel = ((ZoomManager) zoom).getZoom(); if (zoomLevel == 1.0f) return actualFont; FontData[] fd = new FontData[actualFont.getFontData().length]; FontData tempFD = null; for (int i = 0; i < fd.length; i++) { tempFD = actualFont.getFontData()[i]; fd[i] = new FontData(tempFD.getName(), (int) (zoomLevel * tempFD.getHeight()), tempFD.getStyle()); } try { FontDescriptor fontDescriptor = FontDescriptor.createFrom(fd); cachedFontDescriptors.add(fontDescriptor); return getResourceManager().createFont(fontDescriptor); } catch (DeviceResourceException e) { Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getZoomLevelFonts", e); //$NON-NLS-1$ Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getZoomLevelFonts", e); //$NON-NLS-1$ return actualFont; } } else return actualFont; }
Example #19
Source File: ERDiagramLayoutEditPolicy.java From erflute with Apache License 2.0 | 5 votes |
@Override protected void showSizeOnDropFeedback(CreateRequest request) { final Point p = new Point(request.getLocation().getCopy()); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure feedback = getSizeOnDropFeedback(request); final Dimension size = request.getSize().getCopy(); feedback.translateToRelative(size); feedback.setBounds(new Rectangle((int) (p.x * zoom), (int) (p.y * zoom), size.width, size.height) .expand(getCreationFeedbackOffset(request))); }
Example #20
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 #21
Source File: SankeyMiniViewAction.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void createScale(Composite composite) { Scale scale = new Scale(composite, SWT.NONE); scale.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); double[] values = new double[] { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 }; scale.setIncrement(9); scale.setMinimum(0); scale.setMaximum(99); Controls.onSelect(scale, (e) -> { ZoomManager zoom = part.getZoomManager(); zoom.setZoom(values[scale.getSelection() / 9]); }); scale.setSelection(33); }
Example #22
Source File: MultipleShapesHorizontalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @return the current position with a zoom multiplier */ protected int getCurrentPosition() { int position = getCurrentPositionZoomed(); ZoomManager zoomManager = ((DiagramRootEditPart) getCurrentViewer().getRootEditPart()).getZoomManager(); if (zoomManager != null) { position = (int)Math.round(position * zoomManager.getZoom()); } return position; }
Example #23
Source File: ProductSystemGraphEditor.java From olca-app with Mozilla Public License 2.0 | 5 votes |
@Override @SuppressWarnings("rawtypes") public Object getAdapter(final Class type) { if (type == ZoomManager.class) return ((ScalableRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager(); if (type == IContentOutlinePage.class) { outline = new OutlinePage(model); outline.setEditDomain(getEditDomain()); outline.setSelectionSynchronizer(getSelectionSynchronizer()); return outline; } return super.getAdapter(type); }
Example #24
Source File: MultipleShapesVerticalMoveTool.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @return the current position with a zoom multiplier */ protected int getCurrentPosition() { int position = getCurrentPositionZoomed(); ZoomManager zoomManager = ((DiagramRootEditPart) getCurrentViewer().getRootEditPart()).getZoomManager(); if (zoomManager != null) { position = (int)Math.round(position * zoomManager.getZoom()); } return position; }
Example #25
Source File: OpenMiniatureViewAction.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void update(Viewport port, IFigure figure, Control control, ZoomManager zoomManager) { this.port = port; this.figure = figure; this.control = control; this.zoomManager = zoomManager; if (window != null) window.refresh(); }
Example #26
Source File: ZoomInCommandHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ; ZoomManager zm = ((DiagramRootEditPart)editor.getDiagramEditPart().getRoot()).getZoomManager() ; ZoomInAction action = new ZoomInAction(zm) ; action.run() ; return null; }
Example #27
Source File: ZoomInCommandHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public boolean isEnabled() { DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ; ZoomManager zm = ((DiagramRootEditPart)editor.getDiagramEditPart().getRoot()).getZoomManager() ; ZoomInAction action = new ZoomInAction(zm) ; return action.isEnabled(); }
Example #28
Source File: ZoomOutCommandHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ; ZoomManager zm = ((DiagramRootEditPart)editor.getDiagramEditPart().getRoot()).getZoomManager() ; ZoomOutAction action = new ZoomOutAction(zm) ; action.run() ; return null; }
Example #29
Source File: ZoomOutCommandHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public boolean isEnabled() { DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ; ZoomManager zm = ((DiagramRootEditPart)editor.getDiagramEditPart().getRoot()).getZoomManager() ; ZoomOutAction action = new ZoomOutAction(zm) ; return action.isEnabled(); }
Example #30
Source File: DraggableElementCreationTool.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @param toolEntry The tool entry to create the node * @param draggableElement */ public DraggableElementCreationTool(UnspecifiedTypeCreationTool tool, DraggableElement draggableElement, ZoomManager zoomManager) { this.tool = tool; this.draggableElement = draggableElement; this.zoomManager = zoomManager; this.figure = createImage(); // Remove cursor // initCursor(); setDefaultCursor(Pics.getClosedHandCursor()); setUnloadWhenFinished(true); }