Prechádzať zdrojové kódy

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git

Kevin Trometer 7 rokov pred
rodič
commit
106c6aa214

+ 4 - 4
src/ui/controller/SaveController.java

@@ -217,7 +217,8 @@ public class SaveController {
 			file.add(key, new JsonPrimitive(cat.getName()));
 			// forall object in the category store them into the jsontree
 			for (AbstractCpsObject obj : cat.getObjects()) {
-				file.add("CGOBJECT" + getNumerator(NUMTYPE.OBJECT), model.getGson().toJsonTree(obj, AbstractCpsObject.class));
+				file.add("CGOBJECT" + getNumerator(NUMTYPE.OBJECT),
+						model.getGson().toJsonTree(obj, AbstractCpsObject.class));
 				// if its a holonobject add elements too
 				if (obj instanceof HolonObject)
 					elementsToJson(TYPE.CATEGORY, file, obj);
@@ -421,9 +422,8 @@ public class SaveController {
 	private void statisticgraphToJson(JsonObject file) {
 		// TODO Auto-generated method stub
 		JsonObject temp = new JsonObject();
-		
-		List<String> keys = model.getGraphTable().keySet().parallelStream()
-				.collect(Collectors.toCollection(ArrayList::new));
+
+		List<String> keys = model.getGraphTable().keySet().stream().collect(Collectors.toCollection(ArrayList::new));
 
 		for (String k : keys) {
 			JsonObject dataSet = new JsonObject();

+ 12 - 0
src/ui/model/Model.java

@@ -31,6 +31,7 @@ import ui.view.Console;
 import ui.view.DefaulTable;
 import ui.view.PropertyTable;
 import ui.view.StatisticGraphPanel;
+import ui.view.StatisticPanel;
 
 /**
  * The Class Model is the class where everything is saved. All changes made to
@@ -131,6 +132,8 @@ public class Model {
 	private ArrayList<JsonObject> statisticData = new ArrayList<>();
 	
 	private Gson gson;
+	
+	private StatisticPanel statPanel;
 
 	/**
 	 * Constructor for the model. It initializes the categories and
@@ -957,6 +960,7 @@ public class Model {
 		GsonBuilder builder = new GsonBuilder();
 		builder.serializeNulls();
 		builder.excludeFieldsWithoutExposeAnnotation();
+		builder.setPrettyPrinting();
 		builder.registerTypeAdapter(AbstractCpsObject.class, new AbstractCpsObjectAdapter());
 		builder.registerTypeAdapter(Position.class, new PositionAdapter());
 		builder.registerTypeAdapter(Color.class, new ColorAdapter());
@@ -978,4 +982,12 @@ public class Model {
 	public void setGson(Gson gson) {
 		this.gson = gson;
 	}
+	
+	public void setStatPanel(StatisticPanel sP){
+		statPanel = sP;
+	}
+	
+	public StatisticPanel getStatPanel(){
+		return statPanel;
+	}
 }

+ 3 - 2
src/ui/view/ShowedInformationPopUp.java → src/ui/view/DisplayedInformationPopUp.java

@@ -17,7 +17,7 @@ import ui.controller.Control;
  * 
  * @author Gruppe14
  */
-public class ShowedInformationPopUp extends JDialog {
+public class DisplayedInformationPopUp extends JDialog {
 
 	private static final long serialVersionUID = 1L;
 	private final JPanel contentPanel = new JPanel();
@@ -36,7 +36,7 @@ public class ShowedInformationPopUp extends JDialog {
 	 * @param canvas
 	 *            the Canvas
 	 */
-	public ShowedInformationPopUp(MyCanvas canvas, JPanel update, Control cont) {
+	public DisplayedInformationPopUp(MyCanvas canvas, JPanel update, Control cont) {
 		super((java.awt.Frame) null, true);
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		this.setTitle(Languages.getLanguage()[31]);
@@ -104,5 +104,6 @@ public class ShowedInformationPopUp extends JDialog {
 		canvas.setShowedInformation(connection, object, borders, nodeOfnode);
 		canvas.repaint();
 		toUpdate.updateUI();
+		
 	}
 }

+ 39 - 11
src/ui/view/FlexSubData.java

@@ -22,6 +22,7 @@ public class FlexSubData extends JSplitPane {
 	private JPanel currentObj;
 	private JButton btnShowObjects;
 	private FlexiblePane listener;
+	private boolean shown;
 	public FlexSubData(FlexibleData fD) {
 		setDividerSize(0);
 		setAlignmentY(Component.CENTER_ALIGNMENT);
@@ -39,25 +40,18 @@ public class FlexSubData extends JSplitPane {
 		btnShowObjects.addActionListener(new ActionListener(){
 			public void actionPerformed(ActionEvent e){
 				if(btnShowObjects.getText() == SHOW){
-					objectInfo.add(currentObj);
-					objectInfo.revalidate();
-					objectInfo.updateUI();
-					listener.revalidate();
-					btnShowObjects.setText(HIDE);
+					showAction();
 				}else if(btnShowObjects.getText() == HIDE){
-					objectInfo.removeAll();
-					objectInfo.revalidate();
-					objectInfo.updateUI();
-					listener.revalidate();
-					btnShowObjects.setText(SHOW);
+					hideAction();
 				}
 			}
 		});
 		subnetInfo.add(btnShowObjects);
-		
+
 		objectInfo = new JPanel();
 		setRightComponent(objectInfo);
 		objectInfo.setLayout(new BoxLayout(objectInfo, BoxLayout.X_AXIS));
+		shown = false;
 	}
 	
 	public void setObjects(JPanel obj){
@@ -72,4 +66,38 @@ public class FlexSubData extends JSplitPane {
 	public JPanel getSubInfo(){
 		return subnetInfo;
 	}
+	
+	public void repaint(){
+		if(btnShowObjects != null){
+			if(shown = true){
+				showAction();
+				System.out.println("show");
+			}else if(shown = false){
+				hideAction();
+				System.out.println("hide");
+			}
+		}
+		super.repaint();
+	}
+	
+	public void showAction(){
+		if(currentObj != null && listener != null){
+			objectInfo.removeAll();
+			objectInfo.add(currentObj);
+			objectInfo.revalidate();
+			objectInfo.updateUI();
+			listener.revalidate();
+			btnShowObjects.setText(HIDE);
+		}
+	}
+	
+	public void hideAction(){
+		if(listener != null){
+			objectInfo.removeAll();
+			objectInfo.revalidate();
+			objectInfo.updateUI();
+			listener.revalidate();
+			btnShowObjects.setText(SHOW);
+		}
+	}
 }

+ 6 - 4
src/ui/view/GUI.java

@@ -139,7 +139,7 @@ public class GUI<E> implements CategoryListener {
 	private JMenuItem editItem = new JMenuItem("Edit Object");
 	private String catOfObjToBeEdited;
 	private FlexiblePane flexPane;
-	private StatPanel2 statSplitPane;
+	private StatisticPanel statSplitPane;
 	private JScrollPane statScrollPane;
 	private UpperNodeCanvas unc;
 	private JPanel contentPane;
@@ -299,8 +299,9 @@ public class GUI<E> implements CategoryListener {
 	public GUI(Control control) {
 		this.controller = control;
 		this.model = control.getModel();
-		statSplitPane = new StatPanel2(controller);
+		statSplitPane = new StatisticPanel(controller);
 		model.addGraphListener(statSplitPane);
+		model.setStatPanel(statSplitPane);
 		statScrollPane = new JScrollPane(statSplitPane);
 		this.unitGraph = new UnitGraph(model, control);
 		this.canvas = new MyCanvas(model, control, unitGraph);
@@ -670,7 +671,7 @@ public class GUI<E> implements CategoryListener {
 		mntmEditShowedInformation.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 				try {
-					ShowedInformationPopUp dialog = new ShowedInformationPopUp(canvas, contentPane, controller);
+					DisplayedInformationPopUp dialog = new DisplayedInformationPopUp(canvas, contentPane, controller);
 					dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
 					dialog.setVisible(true);
 				} catch (Exception ex) {
@@ -2342,9 +2343,10 @@ public class GUI<E> implements CategoryListener {
 				cps = controller.searchTracked(obj.get("ID").getAsInt());
 				prop = obj.get("PROPERTY").getAsInt();
 				color = model.getGson().fromJson(obj.get("COLOR"), Color.class);
-				stat.getStatGraph().addObject(new TrackedDataSet(cps, prop, color));
+				stat.addObject(new TrackedDataSet(cps, prop, color));
 			}
 			model.getGraphTable().put(json.get("KEY").getAsString(), stat);
+			model.getStatPanel().getGraphPanel().add(stat);
 		}
 	}
 }

+ 0 - 840
src/ui/view/SplitPane.java

@@ -1,840 +0,0 @@
-package ui.view;
-
-import javax.swing.JSplitPane;
-import javax.swing.JScrollPane;
-import javax.swing.JPanel;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Random;
-
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
-import javax.swing.JLabel;
-import javax.swing.LayoutStyle.ComponentPlacement;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeModel;
-import DataSets.GraphDataSet;
-import DataSets.PropertyDataSet;
-import classes.AbstractCpsObject;
-import classes.CpsUpperNode;
-import classes.HolonObject;
-import classes.HolonSwitch;
-import classes.TrackedDataSet;
-import interfaces.GraphListener;
-import ui.controller.Control;
-
-import javax.swing.JTextField;
-import javax.swing.JComboBox;
-import javax.swing.JButton;
-import javax.swing.JTree;
-import java.awt.Color;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-
-import javax.swing.border.LineBorder;
-import javax.swing.JPopupMenu;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import javax.swing.JMenuItem;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-
-public class SplitPane extends JSplitPane implements GraphListener {
-	public static final String MAIN_GRID = "Main Grid";
-	public static final String HOLON = "Holons";
-	
-	// Property Strings
-	public static final String TOT_PROD_HOLON = "total Holon Production";
-	public static final String TOT_CONS_HOLON = "total Holon Consumption";
-	public static final String SUPPLIED_OBJ = "Percentage of supplied Objects";
-	public static final String NOT_SUPPLIED_OBJ = "Percentage of not supplied Objects";
-	public static final String PART_SUPPLIED_OBJ = "Percentage of partially supplied Objects";
-	public static final String NR_SUBNETS = "Nr. of Subnets";
-	public static final String NR_CLOSED_SWITCHES = "Nr. of closed Switches";
-	public static final String AVG_OBJ_IN_HOLONS = "Average amount of Objects in Holons";
-	public static final String AVG_ELEM_IN_HOLONS = "Average amount of Elements in Holons";
-	public static final String AVG_PRODS_IN_HOLONS ="Average amount of Producers in Holons";
-	public static final String AVG_CONS_ENERGY_IN_HOLONS = "Average consumed Energy";
-	public static final String AVG_WASTED_ENERGY_HOLONS = "Average wasted Energy";
-	public static final String NR_BROKEN_EDGES = "Amount of broken Edges";
-	public static final String PROD_CONS_RATIO = "Producer/Consumer Ratio";
-	
-	public static final String TOT_PROD_OBJ = "total Production";
-	public static final String TOT_CONS_OBJ = "total Consumption";
-	public static final String NR_ACTIVE_ELEMENTS = "active Elements";
-	
-	public static final String SW_ACTIVE = "active";
-	
-	public static final String TOT_PROD_GRID = "total Grid Production";
-	public static final String TOT_CONS_GRID = "total Grid Consumption";
-	
-	// editable textfields
-	private JTextField graphNrTxtField;
-	private JTextField redField;
-	private JTextField greenField;
-	private JTextField blueField;
-	
-	// Tree Properties
-	private JTree objectTree;
-	private DefaultTreeModel treeModel;
-	private DefaultMutableTreeNode objectsNode;
-	private DefaultMutableTreeNode mainGrid;
-	private DefaultMutableTreeNode holonNode;
-	private DefaultMutableTreeNode switchesNode;
-	private DefaultMutableTreeNode groupNode;
-	
-	private Hashtable<String, GraphDataSet> objectHashtable;
-	private Hashtable<String, StatisticGraphPanel> graphHashtable;
-	private Hashtable<String, PropertyDataSet> holonHashtable;
-	private Hashtable<String, Integer> propValTable;
-	private JPanel colorPanel;
-	
-	//contains information about a selected property
-	private PropertyDataSet currentProperty = new PropertyDataSet();
-	private JComboBox colorComboBox;
-	private Control controller;
-	private JPanel graphPanel;
-
-	JLabel showObjectlbl;
-	JLabel showPropertylbl;
-
-	public SplitPane(Control cont) {
-		this.setBorder(null);
-		setPreferredSize(new Dimension(0, 0));
-		setMinimumSize(new Dimension(0, 0));
-		setMaximumSize(new Dimension(0, 0));
-		setContinuousLayout(true);
-		this.controller = cont;
-		objectHashtable = new Hashtable<String, GraphDataSet>();
-		graphHashtable = new Hashtable<String, StatisticGraphPanel>();
-		
-		holonHashtable = new Hashtable<String, PropertyDataSet>();
-		holonHashtable.put(TOT_PROD_HOLON, new PropertyDataSet());
-		holonHashtable.put(TOT_CONS_HOLON, new PropertyDataSet());
-		holonHashtable.put(SUPPLIED_OBJ, new PropertyDataSet());
-		holonHashtable.put(NOT_SUPPLIED_OBJ, new PropertyDataSet());
-		holonHashtable.put(PART_SUPPLIED_OBJ, new PropertyDataSet());
-		holonHashtable.put(NR_SUBNETS, new PropertyDataSet());
-		holonHashtable.put(NR_CLOSED_SWITCHES, new PropertyDataSet());
-		holonHashtable.put(AVG_OBJ_IN_HOLONS, new PropertyDataSet());
-		holonHashtable.put(AVG_ELEM_IN_HOLONS, new PropertyDataSet());
-		holonHashtable.put(AVG_PRODS_IN_HOLONS, new PropertyDataSet());
-		holonHashtable.put(AVG_CONS_ENERGY_IN_HOLONS, new PropertyDataSet());
-		holonHashtable.put(AVG_WASTED_ENERGY_HOLONS, new PropertyDataSet());
-		holonHashtable.put(NR_BROKEN_EDGES, new PropertyDataSet());
-		holonHashtable.put(PROD_CONS_RATIO, new PropertyDataSet());
-		
-		//propValTable associates the Strings to the numbers
-		propValTable = new Hashtable<String, Integer>();
-		propValTable.put(TOT_PROD_OBJ, TrackedDataSet.PRODUCTION);
-		propValTable.put(TOT_CONS_OBJ, TrackedDataSet.CONSUMPTION);
-		propValTable.put(NR_ACTIVE_ELEMENTS, TrackedDataSet.ACTIVATED_ELEMENTS);
-		propValTable.put(SW_ACTIVE, TrackedDataSet.ON_OFF);
-		propValTable.put(TOT_PROD_HOLON, TrackedDataSet.TOTAL_PRODUCTION);
-		propValTable.put(TOT_CONS_HOLON, TrackedDataSet.TOTAL_CONSUMPTION);
-		propValTable.put(SUPPLIED_OBJ, TrackedDataSet.PERCENT_SUPPLIED);
-		propValTable.put(NOT_SUPPLIED_OBJ, TrackedDataSet.PERCENT_NOT_SUPPLIED);
-		propValTable.put(PART_SUPPLIED_OBJ, TrackedDataSet.PERCENT_PARTIAL_SUPPLIED);
-		propValTable.put(TOT_PROD_GRID, TrackedDataSet.GROUP_PRODUCTION);
-		propValTable.put(TOT_CONS_GRID, TrackedDataSet.GROUP_CONSUMPTION);
-		propValTable.put(NR_SUBNETS, TrackedDataSet.AMOUNT_HOLONS);
-		propValTable.put(NR_CLOSED_SWITCHES, TrackedDataSet.AMOUNT_CLOSED_SWITCHES);
-		propValTable.put(AVG_OBJ_IN_HOLONS, TrackedDataSet.AVG_AMOUNT_OBJECTS_IN_HOLONS);
-		propValTable.put(AVG_ELEM_IN_HOLONS, TrackedDataSet.AVG_AMOUNT_ELEMENTS_IN_HOLONS);
-		propValTable.put(AVG_PRODS_IN_HOLONS, TrackedDataSet.AVG_AMOUNT_PRODUCERS_IN_HOLONS);
-		propValTable.put(AVG_CONS_ENERGY_IN_HOLONS, TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS);
-		propValTable.put(AVG_WASTED_ENERGY_HOLONS, TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS);
-		propValTable.put(NR_BROKEN_EDGES, TrackedDataSet.AMOUNT_BROKEN_EDGES);
-		propValTable.put(PROD_CONS_RATIO, TrackedDataSet.RATIO_PRODUCERS_CONSUMERS);
-
-
-
-		JScrollPane dataPane = new JScrollPane();
-		setLeftComponent(dataPane);
-		JPanel panel = new JPanel();
-		panel.setBorder(null);
-		dataPane.setViewportView(panel);
-		dataPane.setBorder(null);
-
-		JScrollPane treeScrollPane = new JScrollPane();
-		
-		
-		//================= LABLES ON THE LEFT SIDE =================//
-		
-		JLabel lblObject = new JLabel("Object(s):");
-
-		showObjectlbl = new JLabel("...");
-
-		JLabel lblProperty = new JLabel("Property:");
-
-		showPropertylbl = new JLabel("...");
-
-		JLabel lblGraph = new JLabel("Graph:");
-
-		JLabel lblColor = new JLabel("Color:");
-		
-		//================= LABLES END ===============================//
-		
-		
-		//================= COLOR COMBOBOX ===========================//
-		
-		colorComboBox = new JComboBox();
-		colorComboBox.addItem("");
-		colorComboBox.addItem("Red");
-		colorComboBox.addItem("Blue");
-		colorComboBox.addItem("Green");
-		colorComboBox.addItem("Yellow");
-		colorComboBox.addItem("Orange");
-		colorComboBox.addItem("Cyan");
-		colorComboBox.addItem("Magenta");
-		colorComboBox.addItem("Pink");
-		colorComboBox.addItem("Gray");
-		colorComboBox.addItem("Random");
-		colorComboBox.addItemListener(new ItemListener() {
-
-			@Override
-			public void itemStateChanged(ItemEvent e) {
-				String colorName = (String) colorComboBox.getSelectedItem();
-				Color tmpColor = Color.WHITE;
-				switch (colorName) {
-				case "":
-					tmpColor = currentProperty.getColor();
-					break;
-				case "Red":
-					tmpColor = Color.RED;
-					colorChanged(tmpColor);
-					break;
-				case "Blue":
-					tmpColor = Color.BLUE;
-					colorChanged(tmpColor);
-					break;
-				case "Green":
-					tmpColor = Color.GREEN;
-					colorChanged(tmpColor);
-					break;
-				case "Yellow":
-					tmpColor = Color.YELLOW;
-					colorChanged(tmpColor);
-					break;
-				case "Orange":
-					tmpColor = Color.ORANGE;
-					colorChanged(tmpColor);
-					break;
-				case "Cyan":
-					tmpColor = Color.CYAN;
-					colorChanged(tmpColor);
-					break;
-				case "Magenta":
-					tmpColor = Color.MAGENTA;
-					colorChanged(tmpColor);
-					break;
-				case "Pink":
-					tmpColor = Color.PINK;
-					colorChanged(tmpColor);
-					break;
-				case "Gray":
-					tmpColor = Color.GRAY;
-					colorChanged(tmpColor);
-					break;
-				case "Random":
-					Random rdm = new Random();
-					tmpColor = new Color(rdm.nextInt(255), rdm.nextInt(255), rdm.nextInt(255));
-				}
-				redField.setText(Integer.toString(tmpColor.getRed()));
-				greenField.setText(Integer.toString(tmpColor.getGreen()));
-				blueField.setText(Integer.toString(tmpColor.getBlue()));
-			}
-
-		});
-		
-		// ==================== COLORBOX END ==========================//
-
-		// ====================GRAPH NR TEXTFIELD======================//
-		graphNrTxtField = new JTextField();
-		graphNrTxtField.setColumns(10);
-		graphNrTxtField.getDocument().addDocumentListener(new DocumentListener() {
-			/*
-			 * if textField for Red changes, changes will applied in the
-			 * DataStructure "currentProperty" if Value is legit
-			 */
-			@Override
-			public void insertUpdate(DocumentEvent e) {
-				if (currentProperty != null) {
-					currentProperty.setGraph(graphNrTxtField.getText());
-				}
-			}
-
-			@Override
-			public void removeUpdate(DocumentEvent e) {
-				if (currentProperty != null) {
-					currentProperty.setGraph(graphNrTxtField.getText());
-				}
-			}
-
-			@Override
-			public void changedUpdate(DocumentEvent e) {
-
-			}
-		});
-
-		// ====================GRAPH NR TEXTFIELD END==================//
-
-		// ====================RED TEXTFIELD===========================//
-		redField = new JTextField();
-		redField.setColumns(10);
-		redField.getDocument().addDocumentListener(new DocumentListener() {
-			/*
-			 * if textField for Red changes, changes will applied in the
-			 * DataStructure "currentProperty" if Value is legit
-			 */
-			@Override
-			public void insertUpdate(DocumentEvent e) {
-				int tmp = -1;
-				try {
-					tmp = Integer.parseInt(redField.getText());
-				} catch (NumberFormatException e1) {
-
-				}
-				if (tmp > -1 && tmp <= 255) {
-					if (currentProperty != null) {
-						Color oldColor = currentProperty.getColor();
-						Color color = new Color(tmp, oldColor.getGreen(), oldColor.getBlue());
-						currentProperty.setColor(color);
-						colorChanged(color);
-					}
-				}
-			}
-
-			@Override
-			public void removeUpdate(DocumentEvent e) {
-				int tmp = -1;
-				try {
-					tmp = Integer.parseInt(redField.getText());
-				} catch (NumberFormatException e1) {
-
-				}
-				if (tmp > -1 && tmp <= 255) {
-					if (currentProperty != null) {
-						Color oldColor = currentProperty.getColor();
-						Color color = new Color(tmp, oldColor.getGreen(), oldColor.getBlue());
-						currentProperty.setColor(color);
-						colorChanged(color);
-					}
-				}
-			}
-
-			@Override
-			public void changedUpdate(DocumentEvent e) {
-
-			}
-		});
-		// ======================RED TEXTFIELD END==========================//
-
-		// ======================GREEN TEXTFIELD============================//
-		greenField = new JTextField();
-		greenField.setColumns(10);
-		greenField.getDocument().addDocumentListener(new DocumentListener() {
-			/*
-			 * if textField for Red changes, changes will applied in the
-			 * DataStructure "currentProperty" if Value is legit
-			 */
-			@Override
-			public void insertUpdate(DocumentEvent e) {
-				int tmp = -1;
-				try {
-					tmp = Integer.parseInt(greenField.getText());
-				} catch (NumberFormatException e1) {
-
-				}
-				if (tmp > -1 && tmp <= 255) {
-					if (currentProperty != null) {
-						Color oldColor = currentProperty.getColor();
-						Color color = new Color(oldColor.getRed(), tmp, oldColor.getBlue());
-						currentProperty.setColor(color);
-						colorChanged(color);
-					}
-				}
-			}
-
-			@Override
-			public void removeUpdate(DocumentEvent e) {
-				int tmp = -1;
-				try {
-					tmp = Integer.parseInt(greenField.getText());
-				} catch (NumberFormatException e1) {
-
-				}
-				if (tmp > -1 && tmp <= 255) {
-					if (currentProperty != null) {
-						Color oldColor = currentProperty.getColor();
-						Color color = new Color(oldColor.getRed(), tmp, oldColor.getBlue());
-						currentProperty.setColor(color);
-						colorChanged(color);
-					}
-				}
-			}
-
-			@Override
-			public void changedUpdate(DocumentEvent e) {
-
-			}
-		});
-		// ======================GREEN TEXTFIELD END========================//
-
-		// ======================BLUE TEXTFIELD=============================//
-		blueField = new JTextField();
-		blueField.setColumns(10);
-		blueField.getDocument().addDocumentListener(new DocumentListener() {
-			/*
-			 * if textField for Red changes, changes will applied in the
-			 * DataStructure "currentProperty" if Value is legit
-			 */
-			@Override
-			public void insertUpdate(DocumentEvent e) {
-				int tmp = -1;
-				try {
-					tmp = Integer.parseInt(blueField.getText());
-				} catch (NumberFormatException e1) {
-
-				}
-				if (tmp > -1 && tmp <= 255) {
-					if (currentProperty != null) {
-						Color oldColor = currentProperty.getColor();
-						Color color = new Color(oldColor.getRed(), oldColor.getGreen(), tmp);
-						currentProperty.setColor(color);
-						colorChanged(color);
-					}
-				}
-			}
-
-			@Override
-			public void removeUpdate(DocumentEvent e) {
-				int tmp = -1;
-				try {
-					tmp = Integer.parseInt(blueField.getText());
-				} catch (NumberFormatException e1) {
-
-				}
-				if (tmp > -1 && tmp <= 255) {
-					if (currentProperty != null) {
-						Color oldColor = currentProperty.getColor();
-						Color color = new Color(oldColor.getRed(), oldColor.getGreen(), tmp);
-						currentProperty.setColor(color);
-						colorChanged(color);
-					}
-				}
-			}
-
-			@Override
-			public void changedUpdate(DocumentEvent e) {
-
-			}
-		});
-		// ======================BLUE TEXTFIELD END=========================//
-
-		JLabel lblR = new JLabel("R:");
-
-		JLabel lblG = new JLabel("G:");
-
-		JLabel lblB = new JLabel("B:");
-		
-		
-		//======================== ADD BUTTON =============================//
-
-		JButton btnAdd = new JButton("Add");
-		btnAdd.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent e) {
-				DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) objectTree
-						.getLastSelectedPathComponent();
-				if (selectedNode == null) {
-					return;
-				} else {
-					if (selectedNode.getLevel() == 3 || (selectedNode.getLevel() == 2 && 
-							(selectedNode.getParent().toString().equals(HOLON) || selectedNode.getParent().toString().equals(MAIN_GRID) ))) {
-						StatisticGraphPanel tmp = null;
-						if (graphNrTxtField.getText().length() > 0) {
-							if (!graphHashtable.containsKey(graphNrTxtField.getText())
-									&& graphNrTxtField.getText().length() > 0) {
-								tmp = new StatisticGraphPanel(controller.getModel(), controller,
-										graphNrTxtField.getText(), graphHashtable);
-								//tmp.setPreferredSize(new Dimension(280, 150));
-								//tmp.setMaximumSize(new Dimension(1000, 1000));
-								// tmp.setMinimumSize(new Dimension(100, 45));
-								tmp.setBorder(new LineBorder(new Color(0, 0, 0), 1));
-								graphPanel.add(tmp);
-								graphPanel.add(Box.createRigidArea(new Dimension(50, 50)));
-								graphPanel.revalidate();
-								graphPanel.updateUI();
-								graphHashtable.put(graphNrTxtField.getText(), tmp);
-							}
-							String object = ((DefaultMutableTreeNode) selectedNode.getParent()).toString();
-							String property = selectedNode.toString();
-							AbstractCpsObject absCps = null;
-							if(!object.equals(MAIN_GRID) && !object.equals(HOLON)){
-							GraphDataSet dataSet = objectHashtable.get(object);
-							absCps = dataSet.getObject();
-							}
-							TrackedDataSet tds = new TrackedDataSet(absCps, propValTable.get(property),
-									currentProperty.getColor());
-							graphHashtable.get(graphNrTxtField.getText()).addObjec(tds);
-						}
-					}
-				}
-			}
-		});
-		
-		//============================== ADD BUTTON END ==============================//
-
-		colorPanel = new JPanel();
-		colorPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
-		colorPanel.setBackground(Color.WHITE);
-		
-		
-		//================== LAYOUT FOR COMPONENTS ON THE LEFT SIDE ==================//
-		
-		GroupLayout gl_panel = new GroupLayout(panel);
-		gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING)
-				.addGroup(gl_panel.createSequentialGroup().addContainerGap().addGroup(gl_panel
-						.createParallelGroup(Alignment.TRAILING, false).addComponent(treeScrollPane,
-								Alignment.LEADING)
-						.addGroup(Alignment.LEADING,
-								gl_panel.createSequentialGroup()
-										.addGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(lblGraph)
-												.addComponent(lblObject).addComponent(lblProperty)
-												.addComponent(lblColor)
-												.addGroup(gl_panel.createSequentialGroup().addComponent(lblR)
-														.addPreferredGap(ComponentPlacement.RELATED).addGroup(gl_panel
-																.createParallelGroup(Alignment.LEADING, false)
-																.addComponent(colorPanel, GroupLayout.DEFAULT_SIZE,
-																		GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-																.addComponent(redField, GroupLayout.DEFAULT_SIZE, 37,
-																		Short.MAX_VALUE))))
-										.addPreferredGap(ComponentPlacement.RELATED)
-										.addGroup(gl_panel.createParallelGroup(Alignment.LEADING, false)
-												.addComponent(showObjectlbl, GroupLayout.DEFAULT_SIZE,
-														GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-												.addComponent(showPropertylbl, GroupLayout.DEFAULT_SIZE,
-														GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-												.addComponent(colorComboBox, 0, GroupLayout.DEFAULT_SIZE,
-														Short.MAX_VALUE)
-												.addComponent(graphNrTxtField)
-												.addGroup(gl_panel.createSequentialGroup().addGroup(gl_panel
-														.createParallelGroup(Alignment.TRAILING).addComponent(btnAdd)
-														.addGroup(gl_panel.createSequentialGroup().addComponent(lblG)
-																.addPreferredGap(ComponentPlacement.RELATED)
-																.addComponent(greenField, GroupLayout.PREFERRED_SIZE,
-																		37, GroupLayout.PREFERRED_SIZE)))
-														.addPreferredGap(ComponentPlacement.RELATED).addComponent(lblB)
-														.addPreferredGap(ComponentPlacement.RELATED)
-														.addComponent(blueField, GroupLayout.PREFERRED_SIZE, 37,
-																GroupLayout.PREFERRED_SIZE)))))
-						.addGap(32)));
-		gl_panel.setVerticalGroup(
-				gl_panel.createParallelGroup(Alignment.LEADING)
-						.addGroup(gl_panel.createSequentialGroup().addContainerGap()
-								.addComponent(treeScrollPane, GroupLayout.PREFERRED_SIZE, 174,
-										GroupLayout.PREFERRED_SIZE)
-								.addPreferredGap(ComponentPlacement.RELATED)
-								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE)
-										.addComponent(lblObject, GroupLayout.PREFERRED_SIZE, 14,
-												GroupLayout.PREFERRED_SIZE)
-										.addComponent(showObjectlbl))
-								.addPreferredGap(ComponentPlacement.RELATED)
-								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(lblProperty)
-										.addComponent(showPropertylbl))
-								.addPreferredGap(ComponentPlacement.RELATED)
-								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(lblGraph)
-										.addComponent(graphNrTxtField, GroupLayout.PREFERRED_SIZE,
-												GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-								.addPreferredGap(ComponentPlacement.RELATED)
-								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(lblColor)
-										.addComponent(colorComboBox, GroupLayout.PREFERRED_SIZE,
-												GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-								.addGap(18)
-								.addGroup(gl_panel.createParallelGroup(Alignment.BASELINE).addComponent(lblR)
-										.addComponent(redField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
-												GroupLayout.PREFERRED_SIZE)
-										.addComponent(lblG)
-										.addComponent(greenField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
-												GroupLayout.PREFERRED_SIZE)
-										.addComponent(lblB).addComponent(blueField, GroupLayout.PREFERRED_SIZE,
-												GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-								.addPreferredGap(ComponentPlacement.RELATED)
-								.addComponent(colorPanel, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
-								.addPreferredGap(ComponentPlacement.RELATED).addComponent(btnAdd)
-								.addContainerGap(35, Short.MAX_VALUE)));
-		
-		//======================== LAYOUT END ================================//
-		
-		
-		//======================== TREE STRUCTURE=============================//
-		
-		objectTree = new JTree();
-		treeModel = (DefaultTreeModel) objectTree.getModel();
-		DefaultMutableTreeNode root = new DefaultMutableTreeNode("Statistics");
-		mainGrid = new DefaultMutableTreeNode(MAIN_GRID);
-		mainGrid.add(new DefaultMutableTreeNode(TOT_PROD_HOLON));
-		mainGrid.add(new DefaultMutableTreeNode(TOT_CONS_HOLON));
-		mainGrid.add(new DefaultMutableTreeNode(SUPPLIED_OBJ));
-		mainGrid.add(new DefaultMutableTreeNode(NOT_SUPPLIED_OBJ));
-		mainGrid.add(new DefaultMutableTreeNode(PART_SUPPLIED_OBJ));
-		mainGrid.add(new DefaultMutableTreeNode(NR_SUBNETS));
-		mainGrid.add(new DefaultMutableTreeNode(PROD_CONS_RATIO));
-		mainGrid.add(new DefaultMutableTreeNode(NR_BROKEN_EDGES));
-		mainGrid.add(new DefaultMutableTreeNode(NR_CLOSED_SWITCHES));
-		
-		holonNode = new DefaultMutableTreeNode(HOLON);
-		holonNode.add(new DefaultMutableTreeNode(AVG_OBJ_IN_HOLONS));
-		holonNode.add(new DefaultMutableTreeNode(AVG_ELEM_IN_HOLONS));
-		holonNode.add(new DefaultMutableTreeNode(AVG_WASTED_ENERGY_HOLONS));
-		holonNode.add(new DefaultMutableTreeNode(AVG_CONS_ENERGY_IN_HOLONS));
-		holonNode.add(new DefaultMutableTreeNode(AVG_PRODS_IN_HOLONS));
-
-		objectsNode = new DefaultMutableTreeNode("Objects");
-		objectsNode.add(new DefaultMutableTreeNode("empty"));
-		
-		switchesNode = new DefaultMutableTreeNode("Switches");
-		switchesNode.add(new DefaultMutableTreeNode("empty"));
-		
-		groupNode = new DefaultMutableTreeNode("Groups");
-		groupNode.add(new DefaultMutableTreeNode("empty"));
-		
-		treeModel.setRoot(root);
-		root.add(mainGrid);
-		root.add(holonNode);
-		root.add(objectsNode);
-		root.add(switchesNode);
-		root.add(groupNode);
-		objectTree.setModel(treeModel);
-
-		treeScrollPane.setViewportView(objectTree);
-
-		JPopupMenu popupMenu = new JPopupMenu();
-		addPopup(objectTree, popupMenu);
-
-		JMenuItem mntmUntrack = new JMenuItem("Untrack");
-		mntmUntrack.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent e) {
-				DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) objectTree
-						.getLastSelectedPathComponent();
-				if (selectedNode.getLevel() == 2 && !selectedNode.getParent().toString().equals("whole Holon")) {
-					String object = selectedNode.toString();
-					controller.removeTrackingObj(objectHashtable.get(object).getObject());
-				}
-			}
-		});
-		popupMenu.add(mntmUntrack);
-
-		objectTree.addTreeSelectionListener(new TreeSelectionListener() {
-
-			@Override
-			public void valueChanged(TreeSelectionEvent e) {
-				resetFields();
-				showObjectlbl.setText("...");
-				showPropertylbl.setText("...");
-				DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) objectTree
-						.getLastSelectedPathComponent();
-				if (selectedNode == null) {
-					return;
-				} else {
-					if (selectedNode.getLevel() == 0) {
-						disableFields();
-					}
-					if (selectedNode.getLevel() == 1) {
-						disableFields();
-						currentProperty = null;
-						graphNrTxtField.setText("");
-						showObjectlbl.setText(selectedNode.toString());
-					}
-					if (selectedNode.getLevel() == 2) {
-						if (((DefaultMutableTreeNode) selectedNode.getParent()).toString().equals(MAIN_GRID)
-								|| ((DefaultMutableTreeNode) selectedNode.getParent()).toString().equals(HOLON)) {
-							enableFields();
-							String object = selectedNode.getParent().toString();
-							String property = selectedNode.toString();
-							currentProperty = holonHashtable.get(property);
-							Color color = currentProperty.getColor();
-							
-							redField.setText(Integer.toString(color.getRed()));
-							greenField.setText(Integer.toString(color.getGreen()));
-							blueField.setText(Integer.toString(color.getBlue()));
-							
-							showPropertylbl.setText(property);
-							showObjectlbl.setText(object);
-							graphNrTxtField.setText(currentProperty.getAssignedGraph());
-							colorPanel.setBackground(color);
-						} else {
-							disableFields();
-							currentProperty = null;
-							graphNrTxtField.setText("");
-							showObjectlbl.setText(selectedNode.toString());
-						}
-					}
-					if (selectedNode.getLevel() == 3) {
-						enableFields();
-						String object = ((DefaultMutableTreeNode) selectedNode.getParent()).toString();
-						String property = selectedNode.toString();
-						currentProperty = objectHashtable.get(object).getPropertytTable().get(property);
-						Color color = currentProperty.getColor();
-						redField.setText(Integer.toString(color.getRed()));
-						greenField.setText(Integer.toString(color.getGreen()));
-						blueField.setText(Integer.toString(color.getBlue()));
-
-						showObjectlbl.setText(object);
-						showPropertylbl.setText(property);
-						graphNrTxtField.setText(currentProperty.getAssignedGraph());
-						colorPanel.setBackground(color);
-					}
-				}
-			}
-
-		});
-		
-		//========================= TREE STRUCTURE END ============================//
-		
-		
-		panel.setLayout(gl_panel);
-
-		JScrollPane graphScrollPane = new JScrollPane();
-		graphScrollPane.setBorder(null);
-		setRightComponent(graphScrollPane);
-
-		graphPanel = new JPanel();
-		graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));
-		graphPanel.revalidate();
-		graphPanel.updateUI();
-		graphScrollPane.setViewportView(graphPanel);
-		repaintTree();
-	}
-	
-	//=============================== END CONSTRUCTOR ==============================//
-
-	
-	//=============================== METHODS ======================================//
-	@Override
-	public void repaintTree() {
-		treeModel.reload();
-	}
-
-	@Override
-	public void addTrackedObject(ArrayList<AbstractCpsObject> hlList) {
-		objectsNode.removeAllChildren();
-		switchesNode.removeAllChildren();
-		groupNode.removeAllChildren();
-		objectHashtable.clear();
-		if (hlList.size() > 0 && hlList != null) {
-			for (AbstractCpsObject abs : hlList) {
-				String name = abs.getName() + " " + abs.getId();
-				DefaultMutableTreeNode tmp = new DefaultMutableTreeNode(name);
-				Hashtable<String, PropertyDataSet> tmpHash = new Hashtable<String, PropertyDataSet>();
-
-				//HolonObjects
-				if(abs instanceof HolonObject){
-					tmp.add(new DefaultMutableTreeNode(TOT_PROD_OBJ));
-					tmp.add(new DefaultMutableTreeNode(TOT_CONS_OBJ));
-					tmp.add(new DefaultMutableTreeNode(NR_ACTIVE_ELEMENTS));
-					tmpHash.put(TOT_PROD_OBJ, new PropertyDataSet());
-					tmpHash.put(TOT_CONS_OBJ, new PropertyDataSet());
-					tmpHash.put(NR_ACTIVE_ELEMENTS, new PropertyDataSet());
-					objectsNode.add(tmp);
-				}
-				
-				//HolonSwitches
-				if(abs instanceof HolonSwitch){
-					tmp.add(new DefaultMutableTreeNode(SW_ACTIVE));
-					tmpHash.put(SW_ACTIVE, new PropertyDataSet());
-					switchesNode.add(tmp);
-				}
-				
-				//NodesOfNodes
-				if(abs instanceof CpsUpperNode){
-					tmp.add(new DefaultMutableTreeNode(TOT_PROD_GRID));
-					tmp.add(new DefaultMutableTreeNode(TOT_CONS_GRID));
-					tmpHash.put(TOT_PROD_GRID, new PropertyDataSet());
-					tmpHash.put(TOT_CONS_GRID, new PropertyDataSet());
-					groupNode.add(tmp);
-				}
-				
-				GraphDataSet gS = new GraphDataSet(abs, tmpHash);
-				objectHashtable.put(name, gS);
-			}
-		}
-		if(objectsNode.getChildCount() == 0){
-			objectsNode.add(new DefaultMutableTreeNode("empty"));
-		}
-		if(switchesNode.getChildCount() == 0){
-			switchesNode.add(new DefaultMutableTreeNode("empty"));
-		}
-		if(groupNode.getChildCount() == 0){
-			groupNode.add(new DefaultMutableTreeNode("empty"));
-		}
-
-	}
-
-	public void colorChanged(Color color) {
-		colorPanel.setBackground(color);
-	}
-
-	public void resetFields() {
-		colorPanel.setBackground(Color.WHITE);
-		redField.setText("");
-		greenField.setText("");
-		blueField.setText("");
-		colorComboBox.setSelectedIndex(0);
-	}
-
-	public void disableFields() {
-		redField.setEnabled(false);
-		greenField.setEnabled(false);
-		blueField.setEnabled(false);
-		graphNrTxtField.setEnabled(false);
-		colorComboBox.setEnabled(false);
-		colorPanel.setBackground(Color.LIGHT_GRAY);
-	}
-
-	public void enableFields() {
-		redField.setEnabled(true);
-		greenField.setEnabled(true);
-		blueField.setEnabled(true);
-		graphNrTxtField.setEnabled(true);
-		colorComboBox.setEnabled(true);
-		colorPanel.setBackground(Color.WHITE);
-	}
-
-	public void repaintGraphs() {
-		for (StatisticGraphPanel sg : graphHashtable.values()) {
-			sg.calcMaximum();
-			sg.addValues();
-			sg.repaint();
-		}
-	}
-
-	private static void addPopup(Component component, final JPopupMenu popup) {
-		component.addMouseListener(new MouseAdapter() {
-			public void mousePressed(MouseEvent e) {
-				if (e.isPopupTrigger()) {
-					showMenu(e);
-				}
-			}
-
-			public void mouseReleased(MouseEvent e) {
-				if (e.isPopupTrigger()) {
-					showMenu(e);
-				}
-			}
-
-			private void showMenu(MouseEvent e) {
-				popup.show(e.getComponent(), e.getX(), e.getY());
-			}
-		});
-	}
-}

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

@@ -152,7 +152,7 @@ public class StatisticGraphPanel extends JPanel {
 	 * 
 	 * @param set
 	 */
-	public void addObjec(TrackedDataSet set) {
+	public void addObject(TrackedDataSet set) {
 		sGraph.addObject(set);
 		String property = "";
 		switch (set.getProperty()) {

+ 9 - 3
src/ui/view/StatPanel2.java → src/ui/view/StatisticPanel.java

@@ -42,7 +42,7 @@ import classes.TrackedDataSet;
 import interfaces.GraphListener;
 import ui.controller.Control;
 
-public class StatPanel2 extends JSplitPane implements GraphListener {
+public class StatisticPanel extends JSplitPane implements GraphListener {
 	public static final String MAIN_GRID = "Main Grid";
 	public static final String HOLON = "Holons";
 	
@@ -104,7 +104,7 @@ public class StatPanel2 extends JSplitPane implements GraphListener {
 	private JButton btnAdd;
 	
 
-	public StatPanel2(Control cont) {
+	public StatisticPanel(Control cont) {
 		setBorder(null);
 		setMaximumSize(new Dimension(0, 0));
 		setPreferredSize(new Dimension(0, 0));
@@ -612,7 +612,7 @@ public class StatPanel2 extends JSplitPane implements GraphListener {
 							}
 							TrackedDataSet tds = new TrackedDataSet(absCps, propValTable.get(property),
 									currentProperty.getColor());
-							graphHashtable.get(graphNrTxtField.getText()).addObjec(tds);
+							graphHashtable.get(graphNrTxtField.getText()).addObject(tds);
 						}
 					}
 				}
@@ -803,7 +803,13 @@ public class StatPanel2 extends JSplitPane implements GraphListener {
 			sg.repaint();
 		}
 	}
+	
+	public JPanel getGraphPanel(){
+		return graphPanel;
+	}
 
 	private static void addPopup(Component component, final JPopupMenu popup) {
 	}
+	
+	
 }

+ 122 - 127
src/ui/view/UpperNodeCanvas.java

@@ -620,147 +620,128 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 				}
 			}
 
-			// Highlighted Edge
-			if (model.getSelectedObjectID() > 0 || !model.getSelectedCpsObjects().isEmpty()
-					|| !tempSelected.isEmpty()) {
-				g2.setColor(Color.BLUE);
-				for (CpsEdge con : upperNode.getNodeEdges()) {
-					if (con.getFlow() <= con.getCapacity()) {
-						g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 3) + 1, 4)));
+			// Border Highlighting
+			if (showedInformation[3]) {
+				g2.setColor(cps.getBorderColor());
+				if (g2.getColor() != Color.WHITE) {
+					g2.fillRect((int) ((upperNode.getLeftBorder() >> 1) - 25 - scalediv20) - 3,
+							(int) (scalediv20 + 5 + (25 + scalediv20 + 10) * count - scalediv20) - 3,
+							(int) (50 + ((scalediv20 + 3) * 2)), (int) (50 + ((scalediv20 + 3) * 2)));
+				}
+			}
+
+			// node image
+			if (cps instanceof CpsNode && (cps == tempCps || model.getSelectedCpsObject() == cps
+					|| model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps))) {
+				img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
+			} else {
+				if (cps instanceof HolonSwitch) {
+					if (((HolonSwitch) cps).getActiveAt()[model.getCurIteration()]) {
+						((HolonSwitch) cps).setAutoState(true);
 					} else {
-						g2.setStroke(new BasicStroke(2));
-					}
-					if (con.getA().getId() == model.getSelectedObjectID()
-							|| model.getSelectedCpsObjects().contains(con.getA()) || tempSelected.contains(con.getA())
-							|| con.getB().getId() == model.getSelectedObjectID()
-							|| model.getSelectedCpsObjects().contains(con.getB())
-							|| tempSelected.contains(con.getB()) && con != edgeHighlight) {
-						g2.drawLine(con.getA().getPosition().x, con.getA().getPosition().y, con.getB().getPosition().x,
-								con.getB().getPosition().y);
-
-						if (con.getCapacity() == -1) {
-							maxCap = Character.toString('\u221e');
-						} else if (con.getCapacity() == -2) {
-							maxCap = "???";
-						} else {
-							maxCap = String.valueOf(con.getCapacity());
-						}
-						if (showedInformation[0]) {
-							if (con.getConnected() == 0 || con.getConnected() == 1) {
-								g2.drawString(con.getFlow() + "/" + maxCap,
-										(con.getA().getPosition().x + con.getB().getPosition().x) / 2,
-										(con.getA().getPosition().y + con.getB().getPosition().y) / 2);
-							} else {
-								g2.drawString("not connected",
-										(con.getA().getPosition().x + con.getB().getPosition().x) / 2,
-										(con.getA().getPosition().y + con.getB().getPosition().y) / 2);
-							}
-						}
+						((HolonSwitch) cps).setAutoState(false);
 					}
 				}
-			} else if (edgeHighlight != null) {
-				g2.setColor(Color.BLUE);
-				if (edgeHighlight.getFlow() <= edgeHighlight.getCapacity()) {
-					g2.setStroke(new BasicStroke(
-							Math.min((edgeHighlight.getFlow() / edgeHighlight.getCapacity() * 3) + 1, 4)));
+				// Highlighting
+				if ((cps == tempCps && model.getSelectedCpsObjects().size() == 0 && tempSelected.size() == 0)
+						|| model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps)) {
+					g2.setColor(Color.BLUE);
+					g2.fillRect((int) ((upperNode.getLeftBorder() >> 1) - 25 - scalediv20),
+							(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count - scalediv20),
+							(int) (50 + (scalediv20 * 2)), (int) (50 + (scalediv20 * 2)));
+				} else if (cps instanceof HolonObject) {
+					g2.setColor(((HolonObject) cps).getColor());
+
+					g2.fillRect((int) ((upperNode.getLeftBorder() >> 1) - 25 - scalediv20),
+							(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count - scalediv20),
+							(int) (50 + (scalediv20 * 2)), (int) (50 + (scalediv20 * 2)));
+				}
+				// draw image
+				File checkPath = new File(cps.getImage());
+				if (checkPath.exists()) {
+					img = new ImageIcon(cps.getImage()).getImage();
+				} else {
+					img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
+				}
+			}
+			g2.drawImage(img, (upperNode.getLeftBorder() >> 1) - 25,
+					(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count), 50, 50, null);
+			count++;
+		}
+		// Highlighted Edge
+		if (model.getSelectedObjectID() > 0 || !model.getSelectedCpsObjects().isEmpty() || !tempSelected.isEmpty()) {
+			g2.setColor(Color.BLUE);
+			for (CpsEdge con : upperNode.getNodeEdges()) {
+				if (con.getFlow() <= con.getCapacity()) {
+					g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 3) + 1, 4)));
 				} else {
 					g2.setStroke(new BasicStroke(2));
 				}
-				if (upperNode.getNodeEdges().contains(edgeHighlight)) {
-					g2.drawLine(edgeHighlight.getA().getPosition().x, edgeHighlight.getA().getPosition().y,
-							edgeHighlight.getB().getPosition().x, edgeHighlight.getB().getPosition().y);
-
-					if (edgeHighlight.getCapacity() == -1) {
+				if (con.getA().getId() == model.getSelectedObjectID()
+						|| model.getSelectedCpsObjects().contains(con.getA()) || tempSelected.contains(con.getA())
+						|| con.getB().getId() == model.getSelectedObjectID()
+						|| model.getSelectedCpsObjects().contains(con.getB())
+						|| tempSelected.contains(con.getB()) && con != edgeHighlight) {
+					g2.drawLine(con.getA().getPosition().x, con.getA().getPosition().y, con.getB().getPosition().x,
+							con.getB().getPosition().y);
+
+					if (con.getCapacity() == -1) {
 						maxCap = Character.toString('\u221e');
-					} else if (edgeHighlight.getCapacity() == -2) {
+					} else if (con.getCapacity() == -2) {
 						maxCap = "???";
 					} else {
-						maxCap = String.valueOf(edgeHighlight.getCapacity());
+						maxCap = String.valueOf(con.getCapacity());
 					}
 					if (showedInformation[0]) {
-						g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
-								(edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2,
-								(edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2);
+						if (con.getConnected() == 0 || con.getConnected() == 1) {
+							g2.drawString(con.getFlow() + "/" + maxCap,
+									(con.getA().getPosition().x + con.getB().getPosition().x) / 2,
+									(con.getA().getPosition().y + con.getB().getPosition().y) / 2);
+						} else {
+							g2.drawString("not connected",
+									(con.getA().getPosition().x + con.getB().getPosition().x) / 2,
+									(con.getA().getPosition().y + con.getB().getPosition().y) / 2);
+						}
 					}
 				}
 			}
+		} else if (edgeHighlight != null) {
+			g2.setColor(Color.BLUE);
+			if (edgeHighlight.getFlow() <= edgeHighlight.getCapacity()) {
+				g2.setStroke(
+						new BasicStroke(Math.min((edgeHighlight.getFlow() / edgeHighlight.getCapacity() * 3) + 1, 4)));
+			} else {
+				g2.setStroke(new BasicStroke(2));
+			}
+			if (upperNode.getNodeEdges().contains(edgeHighlight)) {
+				g2.drawLine(edgeHighlight.getA().getPosition().x, edgeHighlight.getA().getPosition().y,
+						edgeHighlight.getB().getPosition().x, edgeHighlight.getB().getPosition().y);
 
-			// Objects in upper node
-			for (AbstractCpsObject cps1 : upperNode.getNodes()) {
-				// Border Highlighting
-				if (showedInformation[3]) {
-					g2.setColor(cps1.getBorderColor());
-					if (g2.getColor() != Color.WHITE) {
-						g2.fillRect((int) (cps1.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
-								(int) (cps1.getPosition().y - model.getScaleDiv2() - scalediv20 - 3),
-								(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
-								(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
-					}
-				}
-
-				// node image
-				if (cps1 instanceof CpsNode && (cps1 == tempCps || model.getSelectedCpsObject() == cps1
-						|| model.getSelectedCpsObjects().contains(cps1) || tempSelected.contains(cps1))) {
-					img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
+				if (edgeHighlight.getCapacity() == -1) {
+					maxCap = Character.toString('\u221e');
+				} else if (edgeHighlight.getCapacity() == -2) {
+					maxCap = "???";
 				} else {
-					if (cps1 instanceof HolonSwitch) {
-						if (((HolonSwitch) cps1).getActiveAt()[model.getCurIteration()]) {
-							((HolonSwitch) cps1).setAutoState(true);
-						} else {
-							((HolonSwitch) cps1).setAutoState(false);
-						}
-					}
-					// Highlighting
-					if ((cps1 == tempCps && model.getSelectedCpsObjects().size() == 0 && tempSelected.size() == 0)
-							|| model.getSelectedCpsObjects().contains(cps1) || tempSelected.contains(cps1)) {
-						g2.setColor(Color.BLUE);
-						g2.fillRect((int) (cps1.getPosition().x - model.getScaleDiv2() - scalediv20),
-								(int) (cps1.getPosition().y - model.getScaleDiv2() - scalediv20),
-								(int) (controller.getScale() + (scalediv20 * 2)),
-								(int) (controller.getScale() + (scalediv20 * 2)));
-						if (showedInformation[1] && cps1 instanceof HolonObject) {
-							g2.setColor(Color.BLACK);
-							float totalEnergy = ((HolonObject) cps1)
-									.getCurrentEnergyAtTimeStep(model.getCurIteration());
-							g2.drawString(Float.toString(totalEnergy), cps1.getPosition().x - model.getScaleDiv2(),
-									cps1.getPosition().y - model.getScaleDiv2() - 10);
-						}
-					} else if (cps1 instanceof HolonObject) {
-						g2.setColor(((HolonObject) cps1).getColor());
-
-						g2.fillRect((int) (cps1.getPosition().x - model.getScaleDiv2() - scalediv20),
-								(int) (cps1.getPosition().y - model.getScaleDiv2() - scalediv20),
-								(int) (controller.getScale() + (scalediv20 * 2)),
-								(int) (controller.getScale() + (scalediv20 * 2)));
-
-						if (showedInformation[1]) {
-							g2.setColor(Color.BLACK);
-							float totalEnergy = ((HolonObject) cps1)
-									.getCurrentEnergyAtTimeStep(model.getCurIteration());
-							g2.drawString(Float.toString(totalEnergy), cps1.getPosition().x - model.getScaleDiv2(),
-									cps1.getPosition().y - model.getScaleDiv2() - 10);
-						}
-					}
-					// draw image
-					File checkPath = new File(cps1.getImage());
-					if (checkPath.exists()) {
-						img = new ImageIcon(cps1.getImage()).getImage();
-					} else {
-						img = new ImageIcon(this.getClass().getResource(cps1.getImage())).getImage();
-					}
+					maxCap = String.valueOf(edgeHighlight.getCapacity());
+				}
+				if (showedInformation[0]) {
+					g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
+							(edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2,
+							(edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2);
 				}
-				g2.drawImage(img, cps1.getPosition().x - model.getScaleDiv2(),
-						cps1.getPosition().y - model.getScaleDiv2(), controller.getScale(), controller.getScale(),
-						null);
 			}
+		}
 
+		// Objects in upper node
+		for (AbstractCpsObject cps : upperNode.getNodes()) {
 			// Border Highlighting
 			if (showedInformation[3]) {
 				g2.setColor(cps.getBorderColor());
 				if (g2.getColor() != Color.WHITE) {
-					g2.fillRect((int) ((upperNode.getLeftBorder() >> 1) - 25 - scalediv20) - 3,
-							(int) (scalediv20 + 5 + (25 + scalediv20 + 10) * count - scalediv20) - 3,
-							(int) (50 + ((scalediv20 + 3) * 2)), (int) (50 + ((scalediv20 + 3) * 2)));
+					g2.fillRect((int) (cps.getPosition().x - controller.getScaleDiv2() - scalediv20 - 3),
+							(int) (cps.getPosition().y - model.getScaleDiv2() - scalediv20 - 3),
+							(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
+							(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
 				}
 			}
 
@@ -780,15 +761,30 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 				if ((cps == tempCps && model.getSelectedCpsObjects().size() == 0 && tempSelected.size() == 0)
 						|| model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps)) {
 					g2.setColor(Color.BLUE);
-					g2.fillRect((int) ((upperNode.getLeftBorder() >> 1) - 25 - scalediv20),
-							(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count - scalediv20),
-							(int) (50 + (scalediv20 * 2)), (int) (50 + (scalediv20 * 2)));
+					g2.fillRect((int) (cps.getPosition().x - model.getScaleDiv2() - scalediv20),
+							(int) (cps.getPosition().y - model.getScaleDiv2() - scalediv20),
+							(int) (controller.getScale() + (scalediv20 * 2)),
+							(int) (controller.getScale() + (scalediv20 * 2)));
+					if (showedInformation[1] && cps instanceof HolonObject) {
+						g2.setColor(Color.BLACK);
+						float totalEnergy = ((HolonObject) cps).getCurrentEnergyAtTimeStep(model.getCurIteration());
+						g2.drawString(Float.toString(totalEnergy), cps.getPosition().x - model.getScaleDiv2(),
+								cps.getPosition().y - model.getScaleDiv2() - 10);
+					}
 				} else if (cps instanceof HolonObject) {
 					g2.setColor(((HolonObject) cps).getColor());
 
-					g2.fillRect((int) ((upperNode.getLeftBorder() >> 1) - 25 - scalediv20),
-							(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count - scalediv20),
-							(int) (50 + (scalediv20 * 2)), (int) (50 + (scalediv20 * 2)));
+					g2.fillRect((int) (cps.getPosition().x - model.getScaleDiv2() - scalediv20),
+							(int) (cps.getPosition().y - model.getScaleDiv2() - scalediv20),
+							(int) (controller.getScale() + (scalediv20 * 2)),
+							(int) (controller.getScale() + (scalediv20 * 2)));
+
+					if (showedInformation[1]) {
+						g2.setColor(Color.BLACK);
+						float totalEnergy = ((HolonObject) cps).getCurrentEnergyAtTimeStep(model.getCurIteration());
+						g2.drawString(Float.toString(totalEnergy), cps.getPosition().x - model.getScaleDiv2(),
+								cps.getPosition().y - model.getScaleDiv2() - 10);
+					}
 				}
 				// draw image
 				File checkPath = new File(cps.getImage());
@@ -798,9 +794,8 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 					img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
 				}
 			}
-			g2.drawImage(img, (upperNode.getLeftBorder() >> 1) - 25,
-					(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count), 50, 50, null);
-			count++;
+			g2.drawImage(img, cps.getPosition().x - model.getScaleDiv2(), cps.getPosition().y - model.getScaleDiv2(),
+					controller.getScale(), controller.getScale(), null);
 		}
 
 		// Dragg Highlighting