Browse Source

double click on switch switches state (manual mode only)

Kevin Trometer 7 years ago
parent
commit
f300120096
2 changed files with 5 additions and 9 deletions
  1. 0 8
      src/classes/HolonSwitch.java
  2. 5 1
      src/ui/view/MyCanvas.java

+ 0 - 8
src/classes/HolonSwitch.java

@@ -63,15 +63,7 @@ public class HolonSwitch extends CpsObject {
 				setImage("/Images/switch-on.png");
 			}
 			this.manualActive = !manualActive;
-		} else {
-			if (this.autoActive == true) {
-				setImage("/Images/switch-off.png");
-			} else {
-				setImage("/Images/switch-on.png");
-			}
-			this.autoActive = !autoActive;
 		}
-
 	}
 
 	public boolean getState() {

+ 5 - 1
src/ui/view/MyCanvas.java

@@ -382,7 +382,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			sx = e.getX();
 			sy = e.getY();
 			doMark = true;
-		}
+		}		
 		// Object Selection Highlighting (selectRect)
 		objectSelectionHighlighting();
 
@@ -431,6 +431,10 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			}
 			TempSelected.clear();
 		}
+		
+		if (doubleClick() && tempCps != null && tempCps instanceof HolonSwitch) {
+			((HolonSwitch)tempCps).switchState();
+		}
 
 		controller.calculateStateForTimeStep(model.getCurIteration());