SubmodelComponent now reports rounded coordinates, too
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 5 Jun 2019 12:22:05 +0000 (14:22 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 5 Jun 2019 12:22:05 +0000 (14:22 +0200)
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/SubmodelComponent.java

index 8068e06..7dceec8 100644 (file)
@@ -178,7 +178,11 @@ public class SubmodelComponent extends GUIComponent
        public boolean clicked(double x, double y)
        {
                // TODO
-               System.out.println(((x - getBounds().x) / submodelScale) + "|" + ((y - getBounds().y) / submodelScale));
+               double scaledX = (x - getBounds().x) / submodelScale;
+               double scaledY = (y - getBounds().y) / submodelScale;
+               double roundedScaledX = Math.round(scaledX / 5 * 2) * 5 / 2.;
+               double roundedScaledY = Math.round(scaledY / 5 * 2) * 5 / 2.;
+               System.out.println(scaledX + "|" + scaledY + ", rounded " + roundedScaledX + "|" + roundedScaledY);
                return true;
        }