Java Code Examples for org.eclipse.gef.editparts.ZoomManager#getZoom()
The following examples show how to use
org.eclipse.gef.editparts.ZoomManager#getZoom() .
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: 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 2
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 3
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 4
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 5
Source File: TableViewGraphicalNodeEditPolicy.java From ermasterr with Apache License 2.0 | 5 votes |
@Override public void showTargetFeedback(final Request request) { final ERDiagram diagram = (ERDiagram) getHost().getRoot().getContents().getModel(); if (diagram.isTooltip()) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final TableView tableView = (TableView) getHost().getModel(); final Rectangle tableBounds = getHostFigure().getBounds(); final String name = TableViewEditPart.getTableViewName(tableView, diagram); final Label label = new Label(); label.setText(name); label.setBorder(new SimpleRaisedBorder()); label.setBackgroundColor(ColorConstants.orange); label.setOpaque(true); final Dimension dim = FigureUtilities.getTextExtents(name, Display.getCurrent().getSystemFont()); label.setBounds(new Rectangle((int) (zoom * (tableBounds.x + 33)), (int) (zoom * (tableBounds.y + 5)), (int) (dim.width * 1.5), 20)); addFeedback(label); } super.showTargetFeedback(request); }
Example 6
Source File: ERDiagramLayoutEditPolicy.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected void showSizeOnDropFeedback(final 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 7
Source File: ERDiagramMultiPageEditor.java From ermasterr with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void doSave(final IProgressMonitor monitor) { final ZoomManager zoomManager = (ZoomManager) getActiveEditor().getAdapter(ZoomManager.class); final double zoom = zoomManager.getZoom(); diagram.setZoom(zoom); final ERDiagramEditor activeEditor = getActiveEditor(); final Point location = activeEditor.getLocation(); diagram.setLocation(location.x, location.y); final Persistent persistent = Persistent.getInstance(); try { diagram.getDiagramContents().getSettings().getModelProperties().setUpdatedDate(new Date()); final InputStream source = persistent.createInputStream(diagram); if (inputFile != null) { if (!inputFile.exists()) { inputFile.create(source, true, monitor); } else { inputFile.setContents(source, true, false, monitor); } } } catch (final Exception e) { ERDiagramActivator.showExceptionDialog(e); } for (int i = 0; i < getPageCount(); i++) { final IEditorPart editor = getEditor(i); editor.doSave(monitor); } validate(); }
Example 8
Source File: TableViewComponentEditPolicy.java From erflute with Apache License 2.0 | 5 votes |
private int getColumnIndex(DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure figure = ((TableViewEditPart) getHost()).getFigure(); final int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom); int index = 0; if (editRequest.getLocation().y >= center) { final TableView newTableView = (TableView) getHost().getModel(); index = newTableView.getColumns().size(); } return index; }
Example 9
Source File: TableViewGraphicalNodeEditPolicy.java From erflute with Apache License 2.0 | 5 votes |
@Override public void showTargetFeedback(Request request) { final ERDiagram diagram = ERModelUtil.getDiagram(getHost().getRoot().getContents()); if (diagram.isTooltip()) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final TableView tableView = (TableView) getHost().getModel(); final Rectangle tableBounds = getHostFigure().getBounds(); final String name = TableViewEditPart.getTableViewName(tableView, diagram); final Label label = new Label(); label.setText(name); label.setBorder(new SimpleRaisedBorder()); label.setBackgroundColor(ColorConstants.orange); label.setOpaque(true); final Dimension dim = FigureUtilities.getTextExtents(name, Display.getCurrent().getSystemFont()); label.setBounds(new Rectangle( (int) (zoom * (tableBounds.x + 33)), (int) (zoom * (tableBounds.y + 5)), (int) (dim.width * 1.5), 20)); addFeedback(label); } super.showTargetFeedback(request); }
Example 10
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 11
Source File: ERFluteMultiPageEditor.java From erflute with Apache License 2.0 | 5 votes |
@Override public void doSave(IProgressMonitor monitor) { monitor.setTaskName("save initialize..."); final ZoomManager zoomManager = (ZoomManager) getActiveEditor().getAdapter(ZoomManager.class); final double zoom = zoomManager.getZoom(); diagram.setZoom(zoom); final MainDiagramEditor activeEditor = (MainDiagramEditor) getActiveEditor(); final Point location = activeEditor.getLocation(); diagram.setLocation(location.x, location.y); final Persistent persistent = Persistent.getInstance(); final IFile file = ((IFileEditorInput) getEditorInput()).getFile(); try { monitor.setTaskName("create stream..."); final InputStream source = persistent.write(diagram); if (!file.exists()) { file.create(source, true, monitor); } else { file.setContents(source, true, false, monitor); } } catch (final Exception e) { Activator.showExceptionDialog(e); } monitor.beginTask("saving...", getPageCount()); for (int i = 0; i < getPageCount(); i++) { final IEditorPart editor = getEditor(i); editor.doSave(monitor); monitor.worked(i + 1); } monitor.done(); monitor.setTaskName("finalize..."); validate(); monitor.done(); }
Example 12
Source File: ColumnSelectionHandlesEditPolicy.java From ermaster-b with Apache License 2.0 | 5 votes |
private int getColumnIndex(DirectEditRequest editRequest) { ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); ColumnEditPart columnEditPart = (ColumnEditPart) this.getHost(); Column column = (Column) columnEditPart.getModel(); TableView newTableView = (TableView) this.getHost().getParent() .getModel(); List<Column> columns = newTableView.getColumns(); if (column.getColumnHolder() instanceof ColumnGroup) { column = (ColumnGroup) column.getColumnHolder(); } int index = columns.indexOf(column); Rectangle columnRectangle = this.getColumnRectangle(); int center = (int) ((columnRectangle.y + (columnRectangle.height / 2)) * zoom); if (editRequest.getLocation().y >= center) { index++; } return index; }
Example 13
Source File: TableViewGraphicalNodeEditPolicy.java From ermaster-b with Apache License 2.0 | 5 votes |
@Override public void showTargetFeedback(Request request) { ERDiagram diagram = ERModelUtil.getDiagram(this.getHost().getRoot().getContents()); if (diagram.isTooltip()) { ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); TableView tableView = (TableView) this.getHost().getModel(); Rectangle tableBounds = this.getHostFigure().getBounds(); String name = TableViewEditPart.getTableViewName(tableView, diagram); Label label = new Label(); label.setText(name); label.setBorder(new SimpleRaisedBorder()); label.setBackgroundColor(ColorConstants.orange); label.setOpaque(true); Dimension dim = FigureUtilities.getTextExtents(name, Display .getCurrent().getSystemFont()); label.setBounds(new Rectangle((int) (zoom * (tableBounds.x + 33)), (int) (zoom * (tableBounds.y + 5)), (int) (dim.width * 1.5), 20)); this.addFeedback(label); } super.showTargetFeedback(request); }
Example 14
Source File: ERDiagramMultiPageEditor.java From ermaster-b with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void doSave(IProgressMonitor monitor) { monitor.setTaskName("save initialize..."); ZoomManager zoomManager = (ZoomManager) this.getActiveEditor() .getAdapter(ZoomManager.class); double zoom = zoomManager.getZoom(); this.diagram.setZoom(zoom); ERDiagramEditor activeEditor = (ERDiagramEditor) this.getActiveEditor(); Point location = activeEditor.getLocation(); this.diagram.setLocation(location.x, location.y); Persistent persistent = Persistent.getInstance(); IFile file = ((IFileEditorInput) this.getEditorInput()).getFile(); try { monitor.setTaskName("create stream..."); diagram.getDiagramContents().getSettings().getModelProperties() .setUpdatedDate(new Date()); InputStream source = persistent.createInputStream(this.diagram); if (!file.exists()) { file.create(source, true, monitor); } else { file.setContents(source, true, false, monitor); } } catch (Exception e) { Activator.showExceptionDialog(e); } monitor.beginTask("saving...", this.getPageCount()); for (int i = 0; i < this.getPageCount(); i++) { IEditorPart editor = this.getEditor(i); editor.doSave(monitor); monitor.worked(i + 1); } monitor.done(); monitor.setTaskName("finalize..."); validate(); monitor.done(); }
Example 15
Source File: RelationBendpointEditPolicy.java From ermasterr with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected void showMoveBendpointFeedback(final BendpointRequest bendpointrequest) { final Relation relation = (Relation) getHost().getModel(); final RelationEditPart editPart = (RelationEditPart) getHost(); if (relation.getSource() == relation.getTarget()) { if (bendpointrequest.getIndex() != 1) { return; } final Point point = bendpointrequest.getLocation(); getConnection().translateToRelative(point); final Bendpoint rate = getRate(point); rate.setRelative(true); final float rateX = (100f - (rate.getX() / 2)) / 100; final float rateY = (100f - (rate.getY() / 2)) / 100; final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource(); final Rectangle bounds = tableEditPart.getFigure().getBounds(); final Rectangle rect = new Rectangle(); rect.x = (int) (bounds.x + (bounds.width * rateX)); rect.y = (int) (bounds.y + (bounds.height * rateY)); rect.width = bounds.width * rate.getX() / 100; rect.height = bounds.height * rate.getY() / 100; relation.setSourceLocationp(100, (int) (100 * rateY)); relation.setTargetLocationp((int) (100 * rateX), 100); final LayerManager manager = (LayerManager) tableEditPart.getRoot(); final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER); getFeedbackLayer().setBounds(layer.getBounds()); final List children = getFeedbackLayer().getChildren(); children.clear(); getFeedbackLayer().repaint(); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final Polyline feedbackFigure = new Polyline(); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.setLineStyle(SWT.LINE_DASH); feedbackFigure.translateToRelative(feedbackFigure.getLocation()); addFeedback(feedbackFigure); } else { super.showMoveBendpointFeedback(bendpointrequest); } }
Example 16
Source File: RelationBendpointEditPolicy.java From ermaster-b with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) { Relation relation = (Relation) getHost().getModel(); RelationEditPart editPart = (RelationEditPart) this.getHost(); if (relation.getSource() == relation.getTarget()) { if (bendpointrequest.getIndex() != 1) { return; } Point point = bendpointrequest.getLocation(); this.getConnection().translateToRelative(point); Bendpoint rate = this.getRate(point); rate.setRelative(true); float rateX = (100f - (rate.getX() / 2)) / 100; float rateY = (100f - (rate.getY() / 2)) / 100; ERTableEditPart tableEditPart = (ERTableEditPart) editPart .getSource(); Rectangle bounds = tableEditPart.getFigure().getBounds(); Rectangle rect = new Rectangle(); rect.x = (int) (bounds.x + (bounds.width * rateX)); rect.y = (int) (bounds.y + (bounds.height * rateY)); rect.width = (int) (bounds.width * rate.getX() / 100); rect.height = (int) (bounds.height * rate.getY() / 100); relation.setSourceLocationp(100, (int) (100 * rateY)); relation.setTargetLocationp((int) (100 * rateX), 100); LayerManager manager = (LayerManager) tableEditPart.getRoot(); IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER); this.getFeedbackLayer().setBounds(layer.getBounds()); List children = this.getFeedbackLayer().getChildren(); children.clear(); this.getFeedbackLayer().repaint(); ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this .getHost().getRoot()).getZoomManager(); double zoom = zoomManager.getZoom(); Polyline feedbackFigure = new Polyline(); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point( (int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure .addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.setLineStyle(SWT.LINE_DASH); feedbackFigure.translateToRelative(feedbackFigure.getLocation()); this.addFeedback(feedbackFigure); } else { super.showMoveBendpointFeedback(bendpointrequest); } }
Example 17
Source File: RelationBendpointEditPolicy.java From erflute with Apache License 2.0 | 4 votes |
@Override protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) { final Relationship relation = (Relationship) getHost().getModel(); final RelationEditPart editPart = (RelationEditPart) getHost(); if (relation.getSourceWalker() == relation.getTargetWalker()) { if (bendpointrequest.getIndex() != 1) { return; } final Point point = bendpointrequest.getLocation(); getConnection().translateToRelative(point); final Bendpoint rate = getRate(point); rate.setRelative(true); final float rateX = (100f - (rate.getX() / 2)) / 100; final float rateY = (100f - (rate.getY() / 2)) / 100; final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource(); final Rectangle bounds = tableEditPart.getFigure().getBounds(); final Rectangle rect = new Rectangle(); rect.x = (int) (bounds.x + (bounds.width * rateX)); rect.y = (int) (bounds.y + (bounds.height * rateY)); rect.width = (int) (bounds.width * rate.getX() / 100); rect.height = (int) (bounds.height * rate.getY() / 100); relation.setSourceLocationp(100, (int) (100 * rateY)); relation.setTargetLocationp((int) (100 * rateX), 100); final LayerManager manager = (LayerManager) tableEditPart.getRoot(); final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER); getFeedbackLayer().setBounds(layer.getBounds()); final List<?> children = getFeedbackLayer().getChildren(); children.clear(); getFeedbackLayer().repaint(); final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final Polyline feedbackFigure = new Polyline(); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom))); feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom))); feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom))); feedbackFigure.setLineStyle(SWT.LINE_DASH); feedbackFigure.translateToRelative(feedbackFigure.getLocation()); addFeedback(feedbackFigure); } else { super.showMoveBendpointFeedback(bendpointrequest); } }
Example 18
Source File: TableViewComponentEditPolicy.java From ermasterr with Apache License 2.0 | 4 votes |
private int getColumnIndex(final DirectEditRequest editRequest) { final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager(); final double zoom = zoomManager.getZoom(); final IFigure figure = ((TableViewEditPart) getHost()).getFigure(); final int center = (int) (figure.getBounds().y + (figure.getBounds().height / 2) * zoom); int index = 0; if (editRequest.getLocation().y >= center) { final TableView newTableView = (TableView) getHost().getModel(); index = newTableView.getColumns().size(); } return index; }