|
@@ -345,12 +345,12 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
|
|
|
if (dragging) {
|
|
|
try {
|
|
|
- float xDist, yDist; //Distance
|
|
|
-
|
|
|
+ float xDist, yDist; // Distance
|
|
|
+
|
|
|
x = e.getX() - controller.getScaleDiv2();
|
|
|
y = e.getY() - controller.getScaleDiv2();
|
|
|
|
|
|
- //Make sure its in bounds
|
|
|
+ // Make sure its in bounds
|
|
|
if (e.getX() < controller.getScaleDiv2())
|
|
|
x = 0;
|
|
|
else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
|
|
@@ -360,33 +360,33 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
else if (e.getY() > this.getHeight() - controller.getScaleDiv2())
|
|
|
y = this.getHeight() - controller.getScale();
|
|
|
|
|
|
- //Distance
|
|
|
- xDist = x-tempCps.getPosition().x;
|
|
|
- yDist = y-tempCps.getPosition().y;
|
|
|
-
|
|
|
+ // Distance
|
|
|
+ xDist = x - tempCps.getPosition().x;
|
|
|
+ yDist = y - tempCps.getPosition().y;
|
|
|
+
|
|
|
tempCps.setPosition(x, y); // Drag Position
|
|
|
selectRect.setLocation(x - (controller.getScale() / 20), y - (controller.getScale() / 20)); // Highlighting-Position
|
|
|
-
|
|
|
+
|
|
|
// TipText Position and name
|
|
|
objectTT.setTipText(tempCps.getName());
|
|
|
objectTT.setLocation(x, y + controller.getScale());
|
|
|
-
|
|
|
- //All Selected Objects
|
|
|
+
|
|
|
+ // All Selected Objects
|
|
|
for (CpsObject cps : model.getSelectedCpsObjects()) {
|
|
|
if (cps != tempCps) {
|
|
|
- x = (int) (cps.getPosition().x+xDist);
|
|
|
- y = (int) (cps.getPosition().y+yDist);
|
|
|
+ x = (int) (cps.getPosition().x + xDist);
|
|
|
+ y = (int) (cps.getPosition().y + yDist);
|
|
|
|
|
|
- //Make sure its in bounds
|
|
|
- if (x < 0)
|
|
|
+ // Make sure its in bounds
|
|
|
+ if (x < 0 - controller.getScaleDiv2())
|
|
|
x = 0;
|
|
|
- else if (x > this.getWidth())
|
|
|
+ else if (x > this.getWidth() - controller.getScale())
|
|
|
x = this.getWidth() - controller.getScale();
|
|
|
if (y < controller.getScaleDiv2())
|
|
|
y = 0;
|
|
|
- else if (y > this.getHeight())
|
|
|
+ else if (y > this.getHeight() - controller.getScale())
|
|
|
y = this.getHeight() - controller.getScale();
|
|
|
-
|
|
|
+
|
|
|
cps.setPosition(x, y);
|
|
|
}
|
|
|
}
|