diff options
| author | Laurent Redor | 2014-08-08 07:30:38 +0000 |
|---|---|---|
| committer | Laurent Redor | 2014-08-11 12:41:34 +0000 |
| commit | 5d3cfb58c9d91b1ab69d26d2cb9329b2bea54c33 (patch) | |
| tree | d90859579aa88dfaac9b85eebd499e05464b163a | |
| parent | 008bc96206e8afd5ad65cf0820cae88709c7be26 (diff) | |
| download | org.eclipse.sirius-5d3cfb58c9d91b1ab69d26d2cb9329b2bea54c33.tar.gz org.eclipse.sirius-5d3cfb58c9d91b1ab69d26d2cb9329b2bea54c33.tar.xz org.eclipse.sirius-5d3cfb58c9d91b1ab69d26d2cb9329b2bea54c33.zip | |
[441417] Cleans methods concerning zoom application.
Cleanup step for this bug: In GraphicalHelper, the methods concerning zoom application are not
correclty documented or have a bad name. This commit changes methods:
* applyZoomOnPoint(): to make what it is expected to do
* appliedZoomOnRelativePoint(): depreciate it, it is the same method as
applyZoomOnPoint()
* applyInverseZoomOnPoint(): new method added
These methods now handle PrecisionPoint, useful in case of "double" and
not "integer" result.
Bug: 441417
Change-Id: I87d46d6118217bc7b863abd0b88f6daa6ff400f3
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
5 files changed, 59 insertions, 12 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToDraw2DCommand.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToDraw2DCommand.java index c1db5e50be..dedc9c1af4 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToDraw2DCommand.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SetConnectionBendpointsAccordingToDraw2DCommand.java @@ -54,9 +54,9 @@ public class SetConnectionBendpointsAccordingToDraw2DCommand extends SetConnecti protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { if (getEdgeAdaptor() instanceof ConnectionEditPart) { ConnectionEditPart connectionEditPart = (ConnectionEditPart) getEdgeAdaptor(); - // Applied zoom on moveDelta, because moveDelta is only element in - // relative value - GraphicalHelper.appliedZoomOnRelativePoint(connectionEditPart, moveDelta); + // Apply inverse zoom on moveDelta, because moveDelta is only + // element in relative value + GraphicalHelper.applyInverseZoomOnPoint(connectionEditPart, moveDelta); Connection connection = connectionEditPart.getConnectionFigure(); Point tempSourceRefPoint = connection.getSourceAnchor().getReferencePoint(); diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusGraphicalNodeEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusGraphicalNodeEditPolicy.java index 93aeec720f..fb7807604e 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusGraphicalNodeEditPolicy.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/SiriusGraphicalNodeEditPolicy.java @@ -650,9 +650,9 @@ public class SiriusGraphicalNodeEditPolicy extends TreeGraphicalNodeEditPolicy { // Applied the zoom of the current diagram to set the pointList, the // source reference point and the target reference point. Point absoluteSourceLocationSnap = absoluteSourceLocationSnapIn100Percent.getCopy(); - GraphicalHelper.applyZoomOnPoint((IGraphicalEditPart) sourceEditPart, absoluteSourceLocationSnap); + GraphicalHelper.applyInverseZoomOnPoint((IGraphicalEditPart) sourceEditPart, absoluteSourceLocationSnap); Point absoluteTargteLoactionSnap = absoluteTargetLocationSnapIn100Percent.getCopy(); - GraphicalHelper.applyZoomOnPoint((IGraphicalEditPart) targetEditPart, absoluteTargteLoactionSnap); + GraphicalHelper.applyInverseZoomOnPoint((IGraphicalEditPart) targetEditPart, absoluteTargteLoactionSnap); edgeLayoutData.setSourceRefPoint(absoluteSourceLocationSnap); edgeLayoutData.setTargetRefPoint(absoluteTargteLoactionSnap); diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html index 9d526d991f..c6658e26cc 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html @@ -81,11 +81,20 @@ <code>org.eclipse.sirius.ext.gmf.runtime.editparts.GraphicalHelper</code>: <ul> <li> - <code>applyZoomOnPoint(IGraphicalEditPart, Point)</code>: Apply the current zoom, of the diagram of the - <code>IGraphicalEditPart</code>, to the + <code>applyZoomOnPoint(IGraphicalEditPart, Point)</code>: Apply the current zoom (of + <code>IGraphicalEditPart</code>'s diagram) on the <code>Point</code>. </li> <li> + <code>applyInverseZoomOnPoint(IGraphicalEditPart, Point)</code>: Apply the inverse of the current zoom(of + <code>IGraphicalEditPart</code>'s diagram) on the + <code>Point</code>. + </li> + <li> + <code>appliedZoomOnRelativePoint(IGraphicalEditPart, Point)</code> is now deprecated. Use + <code>applyZoomOnPoint(IGraphicalEditPart, Point)</code> instead. + </li> + <li> <code>getAnchorPoint(IGraphicalEditPart parent, Anchor anchor)</code>: Get the <code>Point</code> (absolute draw2d coordinates) corresponding to this <code>Anchor</code>. diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile index 47601afdcb..895213980c 100644 --- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile +++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile @@ -29,7 +29,9 @@ h4. Changes in @org.eclipse.sirius.diagram.ui@ h4. Changes in @org.eclipse.sirius.ext.gmf.runtime@ * Several utilities have been added in @org.eclipse.sirius.ext.gmf.runtime.editparts.GraphicalHelper@: -** @applyZoomOnPoint(IGraphicalEditPart, Point)@: Apply the current zoom, of the diagram of the @IGraphicalEditPart@, to the @Point@. +** @applyZoomOnPoint(IGraphicalEditPart, Point)@: Apply the current zoom (of @IGraphicalEditPart@'s diagram) on the @Point@. +** @applyInverseZoomOnPoint(IGraphicalEditPart, Point)@: Apply the inverse of the current zoom(of @IGraphicalEditPart@'s diagram) on the @Point@. +** @appliedZoomOnRelativePoint(IGraphicalEditPart, Point)@ is now deprecated. Use @applyZoomOnPoint(IGraphicalEditPart, Point)@ instead. ** @getAnchorPoint(IGraphicalEditPart parent, Anchor anchor)@: Get the @Point@ (absolute draw2d coordinates) corresponding to this @Anchor@. ** @getAnchorPoint(IGraphicalEditPart parent, IdentityAnchor anchor)@: Get the @Point@ (absolute draw2d coordinates) corresponding to this @IdentityAnchor@. ** @getIntersection(Point, Point, IGraphicalEditPart, boolean)@: Get intersection between a line between lineOrigin and lineTerminus, and the rectangle bounds of the @IGraphicalEditPart@. If there are several intersections, the shortest is returned. diff --git a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java index 0dcbe0e1b7..95c0b21c5d 100644 --- a/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java +++ b/plugins/org.eclipse.sirius.ext.gmf.runtime/src/org/eclipse/sirius/ext/gmf/runtime/editparts/GraphicalHelper.java @@ -66,19 +66,27 @@ public final class GraphicalHelper { * For example: * <UL> * <LI>For a zoom of 200%, the result of this method for the point (100, - * 100) is (50, 50)</LI> + * 100) is (200, 200)</LI> * <LI>For a zoom of 50%, the result of this method for the point (100, 100) - * is (200, 200)</LI> + * is (50, 50)</LI> * </UL> * * @param part * the current part * @param relativePoint * relative point + * @deprecated Use + * {@link #applyInverseZoomOnPoint(IGraphicalEditPart, Point)} + * instead */ + @Deprecated public static void appliedZoomOnRelativePoint(IGraphicalEditPart part, Point relativePoint) { double zoom = getZoom(part); - relativePoint.setLocation((int) (relativePoint.x / zoom), (int) (relativePoint.y / zoom)); + if (relativePoint instanceof PrecisionPoint) { + ((PrecisionPoint) relativePoint).setPreciseLocation(relativePoint.preciseX() / zoom, relativePoint.preciseY() / zoom); + } else { + relativePoint.setLocation((int) (relativePoint.x * zoom), (int) (relativePoint.y * zoom)); + } } /** @@ -98,7 +106,35 @@ public final class GraphicalHelper { */ public static void applyZoomOnPoint(IGraphicalEditPart part, Point point) { double zoom = getZoom(part); - point.setLocation((int) (point.x / zoom), (int) (point.y / zoom)); + if (point instanceof PrecisionPoint) { + ((PrecisionPoint) point).setPreciseLocation(point.preciseX() * zoom, point.preciseY() * zoom); + } else { + point.setLocation((int) (point.x * zoom), (int) (point.y * zoom)); + } + } + + /** + * Apply inverse zoom on a point.<BR> + * For example: + * <UL> + * <LI>For a zoom of 200%, the result of this method for the point (100, + * 100) is (50, 50)</LI> + * <LI>For a zoom of 50%, the result of this method for the point (100, 100) + * is (200, 200)</LI> + * </UL> + * + * @param part + * the current part + * @param point + * a point + */ + public static void applyInverseZoomOnPoint(IGraphicalEditPart part, Point point) { + double zoom = getZoom(part); + if (point instanceof PrecisionPoint) { + ((PrecisionPoint) point).setPreciseLocation(point.preciseX() / zoom, point.preciseY() / zoom); + } else { + point.setLocation((int) (point.x / zoom), (int) (point.y / zoom)); + } } /** |
