Java Code Examples for org.eclipse.gef.editparts.ScalableFreeformRootEditPart#getZoomManager()

The following examples show how to use org.eclipse.gef.editparts.ScalableFreeformRootEditPart#getZoomManager() . 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: GraphicalEditorWithFlyoutPalette.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
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 2
Source File: ERDiagramEditor.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
@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 vote down vote up
@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 vote down vote up
@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);
}