浏览代码

ticket #2 switch to manual

jess 8 年之前
父节点
当前提交
0377e1b725
共有 1 个文件被更改,包括 16 次插入13 次删除
  1. 16 13
      src/classes/HolonSwitch.java

+ 16 - 13
src/classes/HolonSwitch.java

@@ -74,31 +74,33 @@ public class HolonSwitch extends AbstractCpsObject {
 	public HolonSwitch(AbstractCpsObject obj) {
 		super(obj);
 		super.setName(obj.getName());
-		setManualState(((HolonSwitch)obj).getActiveManual());
+		setManualState(((HolonSwitch) obj).getActiveManual());
 		setAutoState(true);
 		setActiveAt(true);
 		for (int i = 0; i < activeAt.length; i++) {
-			activeAt[i] = ((HolonSwitch)obj).getActiveAt()[i];
+			activeAt[i] = ((HolonSwitch) obj).getActiveAt()[i];
 		}
 		setGraphPoints(new LinkedList<Point>());
-		for (Point p :((HolonSwitch)obj).getGraphPoints()) {
-			this.graphPoints.add(new Point((int)p.getX(), (int)p.getY()));
+		for (Point p : ((HolonSwitch) obj).getGraphPoints()) {
+			this.graphPoints.add(new Point((int) p.getX(), (int) p.getY()));
 		}
-		setManualMode(((HolonSwitch)obj).getManualMode());
+		setManualMode(((HolonSwitch) obj).getManualMode());
 	}
 
 	/**
 	 * Calculates the state of the Switch.
 	 */
 	public void switchState() {
-		if (manualMode) {
-			if (this.manualActive == true) {
-				setImage("/Images/switch-off.png");
-			} else {
-				setImage("/Images/switch-on.png");
-			}
-			this.manualActive = !manualActive;
+		if (!manualMode) {
+			setManualMode(true);
+		}
+		if (this.manualActive == true) {
+			setImage("/Images/switch-off.png");
+		} else {
+			setImage("/Images/switch-on.png");
 		}
+		this.manualActive = !manualActive;
+
 	}
 
 	/**
@@ -225,7 +227,8 @@ public class HolonSwitch extends AbstractCpsObject {
 	/**
 	 * Set the overall value of the Switch (manual mode).
 	 * 
-	 * @param mode the mode (boolean)
+	 * @param mode
+	 *            the mode (boolean)
 	 */
 	public void setManualMode(boolean mode) {
 		manualMode = mode;