Browse Source

änderungen auch für uppernodecanvas

dominik.rieder 8 years ago
parent
commit
b1c1e8c33a

+ 17 - 0
src/ui/controller/SimulationManager.java

@@ -5,6 +5,7 @@ import java.util.HashMap;
 
 import classes.CpsEdge;
 import classes.CpsNode;
+import classes.CpsUpperNode;
 import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
@@ -448,6 +449,12 @@ public class SimulationManager {
 				if (!visited.contains(b.getID()) && legitState(cps)) {
 					sN = buildSubNet(b, visited, sN);
 				}
+				if(a instanceof CpsUpperNode && a.getID() != cps.getID()){
+					checkForConnectedSates(b, (CpsUpperNode)a);
+				}
+				if(b instanceof CpsUpperNode && b.getID() != cps.getID()){
+					checkForConnectedSates(a, (CpsUpperNode)b);
+				}
 			}
 		}
 		return sN;
@@ -556,5 +563,15 @@ public class SimulationManager {
 	public ArrayList<SubNet> getSubNets() {
 		return subNets;
 	}
+	
+	/**
+	 * checks wether a given object is connected to an object inside the upperNode.
+	 * if yes, the state for the edge is changed in "connected" or "not connected"
+	 * @param cps
+	 * @param cUNode
+	 */
+	public void checkForConnectedSates(AbstractCpsObject cps, CpsUpperNode cUNode){
+		for(CpsEdge edge: cps.getConnections());
+	}
 
 }

+ 1 - 0
src/ui/view/GUI.java

@@ -1879,6 +1879,7 @@ public class GUI<E> implements CategoryListener {
 					((UpperNodeCanvas) ((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
 							.getComponent(0)).path + " -> ");
 		}
+		unc.setShowedInformation(canvas.getShowedInformation());
 
 		// check if tab already open for clicked NodeOfNode
 		boolean dupl = false;

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

@@ -118,7 +118,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 
 		showedInformation[0] = true;
 		showedInformation[1] = true;
-		showedInformation[2] = false;
+		showedInformation[3] = false;
 		control.setMaxCapacity(10000);
 
 		popmenu.add(itemCut);
@@ -396,7 +396,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				controller.addSubNetColor(new Color((int) (Math.random() * 255), (int) (Math.random() * 255),
 						(int) (Math.random() * 255)));
 			}
-			if(showedInformation[2]){
+			if(showedInformation[3]){
 			for (HolonObject cps : s.getObjects()) {
 				cps.setBorderColor(model.getSubNetColors().get(i));
 			}
@@ -504,13 +504,13 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		// Objects
 		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			// Border Highlighting
-			if(showedInformation[2]){
-			g2.setColor(cps.getBorderColor());
-			if (g2.getColor() != Color.WHITE) {
-				g2.fillRect((int) (cps.getPosition().x - scalediv20 - 3), (int) (cps.getPosition().y - scalediv20 - 3),
-						(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
-						(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
-			}
+			if(showedInformation[3]){
+				g2.setColor(cps.getBorderColor());
+				if (g2.getColor() != Color.WHITE) {
+					g2.fillRect((int) (cps.getPosition().x - scalediv20 - 3), (int) (cps.getPosition().y - scalediv20 - 3),
+							(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
+							(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
+				}
 			}
 			// node image
 			if (cps instanceof CpsNode && (cps == tempCps || model.getSelectedCpsObject() == cps
@@ -1004,7 +1004,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	public void setShowedInformation(boolean connection, boolean object, boolean border) {
 		showedInformation[0] = connection;
 		showedInformation[1] = object;
-		showedInformation[2] = border;
+		showedInformation[3] = border;
 	}
 
 	/**

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

@@ -78,7 +78,7 @@ public class ShowedInformationPopUp extends JDialog {
 		colorizedBorderCheckbox = new JCheckBox("Show colorized Border for Objects");
 		colorizedBorderCheckbox.setBounds(19, 96, 195, 23);
 		contentPanel.add(colorizedBorderCheckbox);
-		colorizedBorderCheckbox.setSelected(canvas.getShowedInformation()[2]);
+		colorizedBorderCheckbox.setSelected(canvas.getShowedInformation()[3]);
 	}
 
 	/**

+ 25 - 11
src/ui/view/UpperNodeCanvas.java

@@ -229,6 +229,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 				for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
 					if (upperNode.getNodes().contains(cps)) {
 						controller.delObjUpperNode(cps, upperNode);
+						// Removes the object from the tracked objects, in case it was tracked
+						controller.removeTrackingObj(cps);
 						// Remove UpperNodeTab if UpperNode deleted
 						if (cps instanceof CpsUpperNode) {
 							JTabbedPane tabbedPane = (JTabbedPane) getParent().getParent().getParent();
@@ -431,11 +433,13 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 		// Objects in upper node
 		for (AbstractCpsObject cps : upperNode.getNodes()) {
 			// Border Highlighting
-			g2.setColor(cps.getBorderColor());
-			if (g2.getColor() != Color.WHITE) {
-				g2.fillRect((int) (cps.getPosition().x - scalediv20 - 3), (int) (cps.getPosition().y - scalediv20 - 3),
-						(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
-						(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
+			if(showedInformation[3]){
+				g2.setColor(cps.getBorderColor());
+				if (g2.getColor() != Color.WHITE) {
+					g2.fillRect((int) (cps.getPosition().x - scalediv20 - 3), (int) (cps.getPosition().y - scalediv20 - 3),
+							(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
+							(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
+				}
 			}
 
 			// node image
@@ -516,12 +520,14 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 			}
 
 			// Border Highlighting
-			g2.setColor(cps.getBorderColor());
-			if (g2.getColor() != Color.WHITE) {
-				g2.fillRect((int) ((borderPos >> 1) - model.getScaleDiv2() - scalediv20) - 3,
-						(int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count - scalediv20) - 3,
-						(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
-						(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
+			if(showedInformation[3]){
+				g2.setColor(cps.getBorderColor());
+				if (g2.getColor() != Color.WHITE) {
+					g2.fillRect((int) ((borderPos >> 1) - model.getScaleDiv2() - scalediv20) - 3,
+							(int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count - scalediv20) - 3,
+							(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
+							(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
+				}
 			}
 
 			// node image
@@ -1222,6 +1228,14 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 		showedInformation[0] = connection;
 		showedInformation[1] = object;
 	}
+	
+	/**
+	 * copies a set of given informations
+	 * @param informations
+	 */
+	public void setShowedInformation(boolean[] informations){
+		showedInformation = informations;
+	}
 
 	/**
 	 * Returns if Information should be shown.