Skip to content
Snippets Groups Projects
Commit 6afa3907 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

- 4 utility methods in ZoomUiUtils are now delegating to utility methods in...

- 4 utility methods in ZoomUiUtils are now delegating to utility methods in ZoomUtils which unifies code paths an helps to avoid future issues (handles FIXME).
- Correct a typo in the PointStaticImpl class which led to a wrong method call.
- Removed invalid TODO in PointStaticImpl.
refs 2491
parent 15f4b815
No related branches found
No related tags found
No related merge requests found
......@@ -17,12 +17,16 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.utils;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createDimension;
import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createPoint;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.gef.RootEditPart;
import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
import org.eclipse.gef.editparts.ScalableRootEditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.fortiss.tooling.base.utils.ZoomUtils;
/**
* Utility code to support zooming.
......@@ -30,7 +34,7 @@ import org.eclipse.gef.requests.ChangeBoundsRequest;
* @author hummel
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: 6AF5B5579B5AAC03335C46B9AE4219BE
* @ConQAT.Rating YELLOW Hash: CB335AF31B2C5D008D897A7F36EDA84D
*/
public class ZoomUIUtils {
......@@ -57,13 +61,16 @@ public class ZoomUIUtils {
request.setSizeDelta(screenToInternalDimension(request.getSizeDelta(), zoom));
}
// FIXME: Make the methods below call the methods in the model plugin
/**
* Converts a point expressed in screen coordinates, into a point in internal coordinates,
* taking the zoom into account.
*/
public static Point screenToInternalPoint(Point pos, double zoom) {
return pos.scale(1 / zoom);
org.fortiss.tooling.base.model.layout.Point modelPoint =
createPoint(pos.x(), pos.y(), pos.toString());
modelPoint = ZoomUtils.screenToInternalPoint(modelPoint, zoom);
pos.setLocation(modelPoint.getX(), modelPoint.getY());
return pos;
}
/**
......@@ -71,7 +78,11 @@ public class ZoomUIUtils {
* taking the zoom into account.
*/
public static Point internalToScreenPoint(Point pos, double zoom) {
return pos.scale(zoom);
org.fortiss.tooling.base.model.layout.Point modelPoint =
createPoint(pos.x(), pos.y(), pos.toString());
modelPoint = ZoomUtils.internalToScreenPoint(modelPoint, zoom);
pos.setLocation(modelPoint.getX(), modelPoint.getY());
return pos;
}
/**
......@@ -79,7 +90,11 @@ public class ZoomUIUtils {
* taking the zoom into account.
*/
public static Dimension screenToInternalDimension(Dimension dim, double zoom) {
return dim.scale(1 / zoom);
org.fortiss.tooling.base.model.layout.Dimension modelDim =
createDimension(dim.width(), dim.height(), dim.toString());
modelDim = ZoomUtils.screenToInternalDimension(modelDim, zoom);
dim.setSize(modelDim.getWidth(), modelDim.getHeight());
return dim;
}
/**
......@@ -87,6 +102,10 @@ public class ZoomUIUtils {
* taking the zoom into account.
*/
public static Dimension internalToScreenDimension(Dimension dim, double zoom) {
return dim.scale(zoom);
org.fortiss.tooling.base.model.layout.Dimension modelDim =
createDimension(dim.width(), dim.height(), dim.toString());
modelDim = ZoomUtils.internalToScreenDimension(modelDim, zoom);
dim.setSize(modelDim.getWidth(), modelDim.getHeight());
return dim;
}
}
......@@ -27,7 +27,7 @@ import org.fortiss.tooling.base.utils.LayoutModelElementFactory;
* @author diewald
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash: 063732F424E3243BB7C56AC45139A5C3
* @ConQAT.Rating YELLOW Hash: 91DB29602A8E231106ACB8202D9DE36B
*/
public class PointStaticImpl {
......@@ -38,8 +38,6 @@ public class PointStaticImpl {
compPoint.toString());
}
// FIXME (FH): todo without issue
// TODO: The key for the new point is not unique !?!?
/** Static implementation of the method {@link Point#getTranslated(int, int)}. */
public static Point getTranslated(Point point, int offsetX, int offsetY) {
Point retPoint =
......@@ -56,7 +54,7 @@ public class PointStaticImpl {
/** Static helper method performing the scale operation. */
private static Point scale(Point point, double factorX, double factorY) {
point.setX((int)Math.floor(point.getX() * factorX));
point.setY((int)Math.floor(point.getX() * factorY));
point.setY((int)Math.floor(point.getY() * factorY));
return point;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment