|
@@ -49,43 +49,44 @@ public class CanvasController {
|
|
|
/**
|
|
|
* check if we should drag & drop replace
|
|
|
*/
|
|
|
-
|
|
|
- /** x of the dragged Object */
|
|
|
- int x = object.getPosition().x;
|
|
|
-
|
|
|
- /** y of the dragged Object */
|
|
|
- int y = object.getPosition().y;
|
|
|
-
|
|
|
- /** distance treshold for replacement */
|
|
|
- int treshhold = model.getScale()/2;
|
|
|
-
|
|
|
- /** number of Objects that might be replaced (should be 1) */
|
|
|
- int replaceCounter = 0;
|
|
|
-
|
|
|
- /** last object that could be replaced */
|
|
|
- AbstractCpsObject toBeReplaced = null;
|
|
|
-
|
|
|
- /** for each cps on Canvas */
|
|
|
- for (AbstractCpsObject cps : model.getObjectsOnCanvas()){
|
|
|
+ if(!(object instanceof CpsNode)){
|
|
|
+ /** x of the dragged Object */
|
|
|
+ int x = object.getPosition().x;
|
|
|
+
|
|
|
+ /** y of the dragged Object */
|
|
|
+ int y = object.getPosition().y;
|
|
|
|
|
|
- /** same object -> ignore */
|
|
|
- if(cps == object)continue;
|
|
|
+ /** distance treshold for replacement */
|
|
|
+ int treshhold = model.getScale()/2;
|
|
|
|
|
|
- /** x of object that might get replaced */
|
|
|
- int c_x = cps.getPosition().x;
|
|
|
+ /** number of Objects that might be replaced (should be 1) */
|
|
|
+ int replaceCounter = 0;
|
|
|
|
|
|
- /** y of object that might get replaced */
|
|
|
- int c_y = cps.getPosition().y;
|
|
|
+ /** last object that could be replaced */
|
|
|
+ AbstractCpsObject toBeReplaced = null;
|
|
|
|
|
|
- /** if near enough */
|
|
|
- if(Math.abs(x-c_x)<treshhold && Math.abs(y-c_y)<treshhold){
|
|
|
- replaceCounter++;
|
|
|
- toBeReplaced = cps;
|
|
|
+ /** for each cps on Canvas */
|
|
|
+ for (AbstractCpsObject cps : model.getObjectsOnCanvas()){
|
|
|
+
|
|
|
+ /** same object -> ignore */
|
|
|
+ if(cps == object)continue;
|
|
|
+
|
|
|
+ /** x of object that might get replaced */
|
|
|
+ int c_x = cps.getPosition().x;
|
|
|
+
|
|
|
+ /** y of object that might get replaced */
|
|
|
+ int c_y = cps.getPosition().y;
|
|
|
+
|
|
|
+ /** if near enough */
|
|
|
+ if(Math.abs(x-c_x)<treshhold && Math.abs(y-c_y)<treshhold){
|
|
|
+ replaceCounter++;
|
|
|
+ toBeReplaced = cps;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /** if replacement of exactly one object possible */
|
|
|
+ if(replaceCounter == 1 && toBeReplaced != null){
|
|
|
+ replaceObjectOnCanvas(toBeReplaced, object);
|
|
|
}
|
|
|
- }
|
|
|
- /** if replacement of exactly one object possible */
|
|
|
- if(replaceCounter == 1 && toBeReplaced != null){
|
|
|
- replaceObjectOnCanvas(toBeReplaced, object);
|
|
|
}
|
|
|
|
|
|
|