Procházet zdrojové kódy

Suspended to check on BP_master

Ludwig Tietze před 7 roky
rodič
revize
113f861ed1

+ 3 - 13
src/classes/HolonSwitch.java

@@ -94,7 +94,7 @@ public class HolonSwitch extends AbstractCpsObject implements IGraphedElement {
 		setLocalPeriod(((IGraphedElement)obj).getLocalPeriod());
 		setActiveAt(true);
 		for (int i = 0; i < activeAt.length; i++) {
-			activeAt[i] = ((HolonSwitch) obj).getActiveAt(i);
+			activeAt[i] = ((HolonSwitch) obj).getState(i);
 		}
 		setGraphPoints(new LinkedList<Point>());
 		for (Point p : ((HolonSwitch) obj).getGraphPoints()) {
@@ -130,7 +130,7 @@ public class HolonSwitch extends AbstractCpsObject implements IGraphedElement {
 		if (manualMode) {
 			return this.manualActive;
 		} else {
-			return getActiveAt(timeStep);
+			return activeAt[UnitGraph.getEffectiveIndex(this, timeStep)];
 		}
 	}
 
@@ -207,16 +207,6 @@ public class HolonSwitch extends AbstractCpsObject implements IGraphedElement {
 	public void setGraphPoints(LinkedList<Point> points) {
 		this.graphPoints = points;
 	}
-
-	/**
-	 * All values of the graph for the selected Switch (only auto-Mode) get the
-	 * activeAt Array.
-	 * 
-	 * @return boolean[] the States of each Iteration
-	 */
-	public boolean/*[]*/ getActiveAt(int i) {
-		return activeAt[UnitGraph.getEffectiveIndex(this, i)];
-	}
 	
 	public boolean[] getValueArray() {//TODO: Only used in SubNet line 97. I am not entirely sure how important it is there.
 		return activeAt;
@@ -238,7 +228,7 @@ public class HolonSwitch extends AbstractCpsObject implements IGraphedElement {
 	 *            the default value
 	 */
 	public void setActiveAt(boolean active) {
-		//activeAt = new boolean[100];
+		activeAt = new boolean[100];//TODO This is necessary because of thisgson rubbish.
 		for (int i = 0; i < activeAt.length; i++) {
 			this.activeAt[i] = active;
 		}

+ 1 - 1
src/classes/SubNet.java

@@ -75,7 +75,7 @@ public class SubNet {
         sb.append("  Switches:");
         for (int j = 0; j < getSwitches().size(); j++) {
             HolonSwitch sw = getSwitches().get(j);
-            sb.append("    " + sw.getName() + " " + sw.getId() + " State:" + sw.getActiveAt(timeStep));
+            sb.append("    " + sw.getName() + " " + sw.getId() + " State:" + sw.getValueArray());//TODO: Value or array???
         }
 
         return sb.toString();

+ 1 - 1
src/ui/controller/UpdateController.java

@@ -315,7 +315,7 @@ public class UpdateController {
 					model.getPropertyTable().setCellEditable(3, 1, true);
 				} else {
 					Object[] tempActive = { Languages.getLanguage()[75],
-							((HolonSwitch) obj).getActiveAt(model.getCurIteration()) };
+							((HolonSwitch) obj).getState(model.getCurIteration()) };
 					model.getPropertyTable().addRow(tempActive);
 					model.getPropertyTable().setCellEditable(3, 1, false);
 				}

+ 1 - 1
src/ui/view/AbstractCanvas.java

@@ -280,7 +280,7 @@ public abstract class AbstractCanvas extends JPanel {
 			img = Util.loadImage(this, "/Images/node_selected.png");
 		} else {
 			if (cps instanceof HolonSwitch) {
-				if (((HolonSwitch) cps).getActiveAt(model.getCurIteration())) {
+				if (((HolonSwitch) cps).getState(model.getCurIteration())) {
 					((HolonSwitch) cps).setAutoState(true);
 				} else {
 					((HolonSwitch) cps).setAutoState(false);

+ 1 - 1
src/ui/view/StatisticGraph.java

@@ -354,7 +354,7 @@ public class StatisticGraph extends JPanel {
                             set.setValAt(0, model.getCurIteration());
                         }
                     } else {
-                        if (((HolonSwitch) set.getCpsObject()).getActiveAt(model.getCurIteration())) {
+                        if (((HolonSwitch) set.getCpsObject()).getState(model.getCurIteration())) {
                             set.setValAt(1, model.getCurIteration());
                         } else {
                             set.setValAt(0, model.getCurIteration());

+ 3 - 3
src/ui/view/UnitGraph.java

@@ -221,16 +221,16 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 
                 // Iteration Value
                 g2.setColor(Color.BLUE);
-                textWidth = g.getFontMetrics().stringWidth("" + ((HolonSwitch)current).getActiveAt(model.getCurIteration())/*arrayOfBooleans[effectiveX]*/) + 2;
+                textWidth = g.getFontMetrics().stringWidth("" + ((HolonSwitch)current).getState(model.getCurIteration())/*arrayOfBooleans[effectiveX]*/) + 2;
                 if (textWidth
                         + (effectiveX) * (this.getWidth() - (border * 2)) / (/*model.getIterations()*/100 - 1) + 2
                         + border <= this.getWidth()) {
-                    g2.drawString("" + ((HolonSwitch)current).getActiveAt(model.getCurIteration()),
+                    g2.drawString("" + ((HolonSwitch)current).getState(model.getCurIteration()),
                             (effectiveX) * (this.getWidth() - (border * 2)) / (/*model.getIterations()*/100 - 1)
                                     + 2 + border,
                             this.getHeight() - 10);
                 } else {
-                    g2.drawString("" + ((HolonSwitch)current).getActiveAt(model.getCurIteration()),
+                    g2.drawString("" + ((HolonSwitch)current).getState(model.getCurIteration()),
                             (effectiveX) * (this.getWidth() - (border * 2)) / (/*model.getIterations()*/100 - 1)
                                     + border - textWidth,
                             this.getHeight() - 10);

+ 1 - 1
src/ui/view/UpperNodeCanvas.java

@@ -478,7 +478,7 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
             	img = Util.loadImage(this,"/Images/node_selected.png");
             } else {
                 if (cps instanceof HolonSwitch) {
-                    if (((HolonSwitch) cps).getActiveAt(model.getCurIteration())) {
+                    if (((HolonSwitch) cps).getState(model.getCurIteration())) {
                         ((HolonSwitch) cps).setAutoState(true);
                     } else {
                         ((HolonSwitch) cps).setAutoState(false);