Kevin Trometer 8 年之前
父節點
當前提交
2c04fd17bf
共有 1 個文件被更改,包括 17 次插入17 次删除
  1. 17 17
      src/ui/view/MyCanvas.java

+ 17 - 17
src/ui/view/MyCanvas.java

@@ -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);
 					}
 				}