Explorar o código

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

# Conflicts:
#	src/ui/controller/LoadController.java
#	src/ui/model/Model.java
Teh-Hai Julian Zheng %!s(int64=7) %!d(string=hai) anos
pai
achega
c2ee037ea1

BIN=BIN
src/exampleAlgorithms/randomSwitchesAlgorithm.class


+ 10 - 2
src/ui/controller/Control.java

@@ -81,8 +81,8 @@ public class Control {
 				objectController, nodeController, multiPurposeController);
 		this.holonCanvasController = new HolonCanvasController(model);
 
-		autosaveDir = System.getProperty("user.home") + "/HolonGUI/Autosave/";
-		categoryDir = System.getProperty("user.home") + "/HolonGUI/Category/";
+		autosaveDir = System.getProperty("user.home") + "/.config/HolonGUI/Autosave/";
+		categoryDir = System.getProperty("user.home") + "/.config/HolonGUI/Category/";
 		File autoSave = new File(autosaveDir);
 		File category = new File(categoryDir);
 		// deleteDirectory(dest);
@@ -966,5 +966,13 @@ public class Control {
 	public void setIsSimRunning(boolean isRunning) {
 		globalController.setIsSimRunning(isRunning);
 	}
+	
+	/**
+	 * Sets showConsoleLog.
+	 * @param showConsoleLog
+	 */
+	public void setShowConsoleLog(boolean showConsoleLog) {
+		globalController.setShowConsoleLog(showConsoleLog);
+	}
 
 }

+ 8 - 0
src/ui/controller/GlobalController.java

@@ -156,4 +156,12 @@ public class GlobalController {
 			}
 		}
 	}
+	
+	/**
+	 * Sets showConsoleLog.
+	 * @param showConsoleLog
+	 */
+	public void setShowConsoleLog(boolean showConsoleLog) {
+		model.setShowConsoleLog(showConsoleLog);
+	}
 }

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

@@ -148,7 +148,7 @@ public class LoadController {
 	private void forwardFiles(File folder, String trim) throws IOException {
 		// TODO Auto-generated method stub
 		for (File file : folder.listFiles()) {
-			File dst = new File(System.getProperty("user.home") + "/HolonGUI/" + file.getPath().replace(trim, ""));
+			File dst = new File(System.getProperty("user.home") + "/.config/HolonGUI/" + file.getPath().replace(trim, ""));
 
 			if (file.getName().contains(".json"))
 				readJson(file.getPath());
@@ -526,18 +526,18 @@ public class LoadController {
 
 		if (os.contains("windows")) {
 			ret = ret.replace("/", "\\");
-			ret = System.getProperty("user.home") + ret.substring(ret.indexOf("\\HolonGUI\\"), ret.length());
+			ret = System.getProperty("user.home") + "\\.config" + ret.substring(ret.indexOf("\\HolonGUI\\"), ret.length());
 
 		}
 		if (os.contains("mac")) {
 			// dosmth
 			ret = ret.replace("\\", "/");
-			ret = System.getProperty("user.home") + ret.substring(ret.indexOf("/HolonGUI/"), ret.length());
+			ret = System.getProperty("user.home") + "/.config" + ret.substring(ret.indexOf("/HolonGUI/"), ret.length());
 		}
 		if (os.contains("linux")) {
 			// dosmth
 			ret = ret.replace("\\", "/");
-			ret = System.getProperty("user.home") + ret.substring(ret.indexOf("/HolonGUI/"), ret.length());
+			ret = System.getProperty("user.home") + "/.config" + ret.substring(ret.indexOf("/HolonGUI/"), ret.length());
 		}
 		if (os.contains("solaris")) {
 			// dosmth

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

@@ -285,8 +285,8 @@ public class SaveController {
 	 */
 	private void storeData(ArchiveOutputStream stream) throws IOException {
 		// TODO Auto-generated method stub
-		File images = new File(System.getProperty("user.home") + "/HolonGUI/Images");
-		File background = new File(System.getProperty("user.home") + "/HolonGUI/BackgroundImages");
+		File images = new File(System.getProperty("user.home") + "/.config/HolonGUI/Images");
+		File background = new File(System.getProperty("user.home") + "/.config/HolonGUI/BackgroundImages");
 		addFilesToSave(images, stream);
 		addFilesToSave(background, stream);
 
@@ -498,16 +498,16 @@ public class SaveController {
 
 		if (os.contains("windows")) {
 			partition = ret.substring(0, ret.indexOf(":") + 1);
-			ret = ret.replace(System.getProperty("user.home") + "\\HolonGUI\\", "");
+			ret = ret.replace(System.getProperty("user.home") + "\\.config\\HolonGUI\\", "");
 			ret = ret.replace(partition, "");
 		}
 		if (os.contains("mac")) {
 			// dosmth
-			ret = ret.replace(System.getProperty("user.home") + "/HolonGUI/", "");
+			ret = ret.replace(System.getProperty("user.home") + "/.config/HolonGUI/", "");
 		}
 		if (os.contains("linux")) {
 			// dosmth
-			ret = ret.replace(System.getProperty("user.home") + "/HolonGUI/", "");
+			ret = ret.replace(System.getProperty("user.home") + "/.config/HolonGUI/", "");
 		}
 		if (os.contains("solaris")) {
 			// dosmth

+ 40 - 19
src/ui/model/Model.java

@@ -33,8 +33,6 @@ import ui.view.StatisticGraphPanel;
  *
  */
 public class Model {
-	
-
 
 	// Canvas Attributes
 	private String imgPath = "";
@@ -76,6 +74,8 @@ public class Model {
 	private int numberOfSaves = 35;
 	// if the simulation is running and has not been reseted
 	private boolean isSimRunning = false;
+	// if the console log of the program should be displayed
+	private boolean showConsoleLog = true;
 	/*
 	 * Array of all categories in the model. It is set by default with the
 	 * categories ENERGY, BUILDINGS and COMPONENTS
@@ -119,11 +119,10 @@ public class Model {
 	private Object algorithm = null;
 	private int selectedHolonBody;
 
-
-	
 	// Statistic Graph Data
 	private Hashtable<String, StatisticGraphPanel> statisticGraphTable = new Hashtable<String, StatisticGraphPanel>();
 	private ArrayList<JsonObject> statisticData = new ArrayList<>();
+
 	/**
 	 * Constructor for the model. It initializes the categories and
 	 * objectsOnCanvas by default values. Listeners are also initialized by
@@ -826,7 +825,7 @@ public class Model {
 	public int getCanvasImageWidth() {
 		return backgroundWidth;
 	}
-	
+
 	/**
 	 * Returns the Custom height of the background Image of the Canvas.
 	 * 
@@ -835,11 +834,12 @@ public class Model {
 	public int getCanvasImageHeight() {
 		return backgroundHeight;
 	}
-	
+
 	/**
 	 * Set the Path for the background Image of the Canvas.
 	 * 
-	 * @param paththe Path
+	 * @param paththe
+	 *            Path
 	 */
 	public void setCanvasImagePath(String path) {
 		imgPath = path;
@@ -850,7 +850,8 @@ public class Model {
 	 * 
 	 * 0 take size of the Image, 1 stretch the Image, 2 Custom Image size
 	 * 
-	 * @param backgroundMode the mode
+	 * @param backgroundMode
+	 *            the mode
 	 */
 	public void setCanvasImageMode(int mode) {
 		backgroundMode = mode;
@@ -859,44 +860,47 @@ public class Model {
 	/**
 	 * Set the Custom width of the background Image of the Canvas.
 	 * 
-	 * @param width the Width
+	 * @param width
+	 *            the Width
 	 */
 	public void setCanvasImageWidth(int width) {
 		backgroundWidth = width;
 	}
-	
+
 	/**
 	 * Set the Custom height of the background Image of the Canvas.
 	 * 
-	 * @param height the height
+	 * @param height
+	 *            the height
 	 */
 	public void setCanvasImageHeight(int height) {
 		backgroundHeight = height;
 	}
-	
+
 	/**
 	 * Set the graphtable for Statistic Graphs
 	 */
-	public void setGraphTable(Hashtable<String, StatisticGraphPanel> gT){
+	public void setGraphTable(Hashtable<String, StatisticGraphPanel> gT) {
 		statisticGraphTable = gT;
 	}
-	
+
 	/**
 	 * Returns the graphtable for Statistic Graphs.
 	 */
-	public Hashtable<String, StatisticGraphPanel> getGraphTable(){
+	public Hashtable<String, StatisticGraphPanel> getGraphTable() {
 		return statisticGraphTable;
 	}
-	
+
 	/**
 	 * Returns if the Simulation is running.
 	 */
-	public boolean getIsSimRunning(){
+	public boolean getIsSimRunning() {
 		return isSimRunning;
 	}
 
 	/**
 	 * Sets isSimRunning.
+	 * 
 	 * @param isRunning
 	 */
 	public void setIsSimRunning(boolean isRunning) {
@@ -911,10 +915,27 @@ public class Model {
 	}
 
 	/**
-	 * @param statisticData the statisticData to set
+	 * @param statisticData
+	 *            the statisticData to set
 	 */
 	public void setStatisticData(ArrayList<JsonObject> statisticData) {
 		this.statisticData = statisticData;
 	}
-}
 
+	/**
+	 * Returns showConsoleLog.
+	 */
+	public boolean getShowConsoleLog() {
+		return this.showConsoleLog;
+	}
+
+	/**
+	 * Sets showConsoleLog.
+	 * 
+	 * @param showConsoleLog
+	 */
+	public void setShowConsoleLog(boolean showConsoleLog) {
+		this.showConsoleLog = showConsoleLog;
+
+	}
+}

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

@@ -356,7 +356,7 @@ public class AddObjectPopUp extends JDialog {
 		OutputStream outStream = null;
 		try {
 			File source = new File(filePath);
-			File dest = new File(System.getProperty("user.home") + "/HolonGUI/Images/");
+			File dest = new File(System.getProperty("user.home") + "/.config/HolonGUI/Images/");
 			dest.mkdirs();
 			dest = new File(dest, selectedFile.getName());
 			imagePath = "" + dest;

+ 13 - 5
src/ui/view/AlgorithmMenu.java

@@ -32,7 +32,7 @@ public class AlgorithmMenu extends JMenu {
 	JMenuItem algoFolderButton = new JMenuItem("Select Algorithm Folder");
 	private JMenu mnSelectAlgorithm = new JMenu("Select Algorithm");
 	private HashMap<String, File> algosHash = new HashMap<>();
-	private JMenuItem noneItem= new JMenuItem("none");
+	private JMenuItem noneItem = new JMenuItem("none");
 
 	// root Directory
 	File root = null;
@@ -55,7 +55,6 @@ public class AlgorithmMenu extends JMenu {
 		this.controller = cont;
 		this.setText("Algorithm");
 
-
 		// algoFolderButton Action
 		algoFolderButton.addActionListener(new ActionListener() {
 
@@ -71,7 +70,7 @@ public class AlgorithmMenu extends JMenu {
 				fileChooser.setAcceptAllFileFilterUsed(false);
 
 				if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
-					//empty everything and reset the selected algorithm
+					// empty everything and reset the selected algorithm
 					controller.setAlgorithm(null);
 					mnSelectAlgorithm.removeAll();
 					mnSelectAlgorithm.add(noneItem);
@@ -93,7 +92,7 @@ public class AlgorithmMenu extends JMenu {
 							algosHash.put(name, files[i]);
 							JMenuItem tempItem = new JMenuItem(name);
 							tempItem.addActionListener(new ActionListener() {
-								
+
 								@Override
 								public void actionPerformed(ActionEvent e) {
 									for (int i = 0; i < mnSelectAlgorithm.getItemCount(); i++) {
@@ -130,6 +129,7 @@ public class AlgorithmMenu extends JMenu {
 	}
 
 	public void setAlgorithm(File file, String name) {
+		boolean missinConsole = false;
 		try {
 			BufferedReader br = new BufferedReader(new FileReader(file.getPath()));
 			String line = br.readLine();
@@ -154,6 +154,10 @@ public class AlgorithmMenu extends JMenu {
 			// Compile source file.
 			JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
 
+			if (ToolProvider.getSystemJavaCompiler() == null) {
+				missinConsole = true;
+			}
+
 			compiler.run(null, null, null, file.getPath());
 
 			// Load and instantiate compiled class.
@@ -171,7 +175,11 @@ public class AlgorithmMenu extends JMenu {
 			controller.setAlgorithm(t);
 
 		} catch (Exception e) {
-			controller.addTextToConsole(e.toString());
+			if (missinConsole) {
+				controller.addTextToConsole("missing Compiiler! Please install JDK");
+			} else {
+				controller.addTextToConsole(e.toString());
+			}
 		}
 	}
 }

+ 15 - 5
src/ui/view/GUI.java

@@ -34,6 +34,7 @@ import javax.swing.DefaultComboBoxModel;
 import javax.swing.ImageIcon;
 import javax.swing.InputMap;
 import javax.swing.JButton;
+import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
@@ -112,7 +113,7 @@ public class GUI<E> implements CategoryListener {
 	private final JMenu mnNewMenuOptions = new JMenu("Options");
 	private final JMenu mnNewMenuView = new JMenu("View");
 	private final JMenu mnHelp = new JMenu("Help");
-	private final JMenu mnAlgorithm = new JMenu("Algorithm");
+	private JCheckBox consoleLogCheckBox = new JCheckBox("Show program console log");
 	private final JMenuItem mntmOpen = new JMenuItem("Open");
 	private final JMenuItem mntmNew = new JMenuItem("New");
 	private final JMenuItem mntmSave = new JMenuItem("Save");
@@ -321,13 +322,14 @@ public class GUI<E> implements CategoryListener {
 		frmCyberPhysical.setTitle("Cyber Physical Systems Model");
 		frmCyberPhysical.setBounds(100, 100, 1000, 800);
 		frmCyberPhysical.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+		frmCyberPhysical.setExtendedState(JFrame.MAXIMIZED_BOTH);
 		frmCyberPhysical.addWindowListener(new java.awt.event.WindowAdapter() {
 			@Override
 			public void windowClosing(java.awt.event.WindowEvent windowEvent) {
 				if (JOptionPane.showConfirmDialog(frmCyberPhysical, Languages.getLanguage()[88],
 						"Cyber Physical Systems Model", JOptionPane.YES_NO_OPTION,
 						JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
-					controller.deleteDirectory(new File(System.getProperty("user.home") + "/HolonGUI/Autosave"));
+					controller.deleteDirectory(new File(System.getProperty("user.home") + "/.config/HolonGUI/Autosave"));
 					System.exit(0);
 				}
 			}
@@ -704,7 +706,15 @@ public class GUI<E> implements CategoryListener {
 				tree.repaint();
 			}
 		});
-
+		mnNewMenuOptions.add(consoleLogCheckBox);
+		consoleLogCheckBox.setSelected(true);
+		consoleLogCheckBox.addActionListener(new ActionListener() {
+			@Override
+			public void actionPerformed(ActionEvent arg0) {
+				controller.setShowConsoleLog(consoleLogCheckBox.isSelected());
+			}
+		});
+		
 		menuBar.add(mnNewMenuView);
 
 		mnNewMenuView.add(mntmCanvasSize);
@@ -1951,12 +1961,12 @@ public class GUI<E> implements CategoryListener {
 		frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
 
 		try {
-			controller.loadAutoSave(System.getProperty("user.home") + "/HolonGUI/Category/Category.json");
+			controller.loadAutoSave(System.getProperty("user.home") + "/.config/HolonGUI/Category/Category.json");
 		} catch (IOException e1) {
 			// TODO Auto-generated catch block
 		}
 
-		String autoPath = System.getProperty("user.home") + "/HolonGUI/Autosave/";
+		String autoPath = System.getProperty("user.home") + "/.config/HolonGUI/Autosave/";
 		File dest = new File(autoPath);
 		if (dest.listFiles().length > 1) {
 			int dialogButton = JOptionPane.YES_NO_OPTION;

+ 22 - 16
src/ui/view/MyCanvas.java

@@ -290,10 +290,12 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							((HolonObject) o).updateTrackingInfo();
 						}
 					}
-					controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
-					controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+					if (model.getShowConsoleLog()) {
+						controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
+						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+					}
 				}
 			}
 		});
@@ -321,10 +323,12 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							((HolonObject) o).setTrackingProd(new float[100]);
 							((HolonObject) o).setTrackingCons(new float[100]);
 						}
-						controller.addTextToConsole("Untracking: ", Color.BLACK, 12, false, false, false);
-						controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
-						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-						controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+						if (model.getShowConsoleLog()) {
+							controller.addTextToConsole("Untracking: ", Color.BLACK, 12, false, false, false);
+							controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
+							controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+							controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+						}
 					}
 				}
 			}
@@ -358,7 +362,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							tabbedPane = (JTabbedPane) tempSplit.getLeftComponent();
 							tabbedPane2 = null;
 						}
-						//Look if the uppernode is open in a Tab
+						// Look if the uppernode is open in a Tab
 						for (int i = 4; i < tabbedPane.getTabCount(); i++) {
 							if (tabbedPane.getComponentAt(i) == null) {
 							} else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
@@ -373,8 +377,8 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							if (tabbedPane2 != null
 									&& ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
 											.getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
-								((ButtonTabComponent) tabbedPane
-										.getTabComponentAt(tabbedPane2.getSelectedIndex())).removeTabs();
+								((ButtonTabComponent) tabbedPane.getTabComponentAt(tabbedPane2.getSelectedIndex()))
+										.removeTabs();
 							}
 						} catch (Exception e2) {
 						}
@@ -457,7 +461,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			}
 		}
 
-		//SubNet Coloring
+		// SubNet Coloring
 		int i = 0;
 		for (SubNet s : controller.getSimManager().getSubNets()) {
 
@@ -723,10 +727,12 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			cy = cps.getPosition().y - controller.getScaleDiv2();
 			if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
 				tempCps = cps;
-				controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
-				controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
-				controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-				controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+				if (model.getShowConsoleLog()) {
+					controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
+					controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
+					controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+					controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+				}
 				dragging = true;
 				if (e.isControlDown() && tempCps != null) {
 					if (model.getSelectedCpsObjects().contains(tempCps)) {

+ 0 - 3
src/ui/view/StatisticGraphPanel.java

@@ -237,9 +237,6 @@ public class StatisticGraphPanel extends JPanel {
 		//b.setBackground(set.getColor());
 		b.setBorder(BorderFactory.createLineBorder(set.getColor()));
 		int color = Math.max(Math.max(set.getColor().getRed(), set.getColor().getGreen()), set.getColor().getBlue());
-		if (color <= 128) {
-			b.setForeground(Color.WHITE);
-		}
 
 		b.setOpaque(true);
 		b.addMouseListener(new MouseAdapter() {

+ 38 - 12
src/ui/view/TimePanel.java

@@ -38,6 +38,7 @@ public class TimePanel extends JPanel {
 
 	private Model model;
 	private Control controller;
+	private int dragResetIteration = 0;
 
 	JSlider timeSlider = new JSlider() {
 		/**
@@ -136,19 +137,18 @@ public class TimePanel extends JPanel {
 		timeSlider.addMouseListener(new MouseAdapter() {
 			@Override
 			public void mousePressed(MouseEvent e) {
-				controller.resetSimulation();
-				if (running) {
-					playBtn.doClick();
-				}
+				dragResetIteration = model.getCurIteration();
 			}
 		});
 
 		timeSlider.addMouseMotionListener(new MouseAdapter() {
 			@Override
 			public void mouseDragged(MouseEvent e) {
-				controller.resetSimulation();
-				if (running) {
-					playBtn.doClick();
+				if (dragResetIteration != model.getCurIteration()) {
+					controller.resetSimulation();
+					if (running) {
+						playBtn.doClick();
+					}
 				}
 			}
 		});
@@ -209,6 +209,9 @@ public class TimePanel extends JPanel {
 				.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)));
 		timeForwardBtn.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
+				if (!model.getIsSimRunning()) {
+					controller.setIsSimRunning(true);
+				}
 				timeSlider.setValue(timeSlider.getValue() + 1);
 				controller.setCurIteration(timeSlider.getValue());
 			}
@@ -226,10 +229,10 @@ public class TimePanel extends JPanel {
 		});
 
 		timeBtnPanel.add(playBtn);
-		timeBtnPanel.add(Box.createRigidArea(new Dimension(10,0)));
+		timeBtnPanel.add(Box.createRigidArea(new Dimension(10, 0)));
 		timeBtnPanel.add(timeResetBtn);
-		timeBtnPanel.add(Box.createRigidArea(new Dimension(10,0)));
-		timeBtnPanel.add(timeForwardBtn);	
+		timeBtnPanel.add(Box.createRigidArea(new Dimension(10, 0)));
+		timeBtnPanel.add(timeForwardBtn);
 
 		// Speed Panel
 		speedPanel.add(simSpeedLabel);
@@ -256,17 +259,40 @@ public class TimePanel extends JPanel {
 
 		this.add(btnAndSpeedPanel, BorderLayout.WEST);
 		this.add(timeSlider);
+
+		//Disable Keys
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, false), "UP_ARROW");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, false), "DOWN_ARROW");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0, false), "PAGE_DOWN");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0, false), "PAGE_UP");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0, false), "END");
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0, false), "HOME");
 		
-		//Left arrow Key
+		// Left arrow Key
 		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), "LEFT_ARROW");
 		timeSlider.getActionMap().put("LEFT_ARROW", new AbstractAction() {
 			private static final long serialVersionUID = 1L;
+
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				timeSlider.setValue(timeSlider.getValue()-1);
+				timeSlider.setValue(timeSlider.getValue() - 1);
 				controller.resetSimulation();
 			}
 		});
+		
+		//Right arrow Key
+		timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), "Right_ARROW");
+		timeSlider.getActionMap().put("Right_ARROW", new AbstractAction() {
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public void actionPerformed(ActionEvent e) {
+				if (!model.getIsSimRunning()) {
+					controller.setIsSimRunning(true);
+				}
+				timeSlider.setValue(timeSlider.getValue() + 1);
+			}
+		});
 	}
 
 	/**

+ 114 - 64
src/ui/view/UnitGraph.java

@@ -76,6 +76,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	private double x = 0, y = 0;
 	private int x1, x2, y1, y2, ctrlx1, ctrly1, ctrlx2, ctrly2;
 
+	private int border = 4;
+	private int textWidth = 0;
+
 	/**
 	 * Constructor.
 	 * 
@@ -113,15 +116,18 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 
 		graphCurve.reset();
 
+		border = (int) recSize.getX() >> 1;
 		// Draw the Vertical Lines
 		g2.setColor(Color.BLACK);
-		for (int i = 0; i < this.getWidth(); i += 7) {
-			g2.drawLine(i, 0, i, this.getHeight());
+		for (int i = border; i < this.getWidth() - border; i += border * 2) {
+			g2.drawLine(i, border, i, this.getHeight() - border);
 		}
+		g2.drawLine(this.getWidth() - border, border, this.getWidth() - border, this.getHeight() - border);
 
-		for (int i = 0; i < this.getHeight(); i += 7) {
-			g2.drawLine(0, i, this.getWidth(), i);
+		for (int i = border; i < this.getHeight() - border; i += border * 2) {
+			g2.drawLine(border, i, this.getWidth() - border, i);
 		}
+		g2.drawLine(border, this.getHeight() - border, this.getWidth() - border, this.getHeight() - border);
 
 		if (isElement) {
 			// array fillen
@@ -133,6 +139,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				g2.setColor(Color.BLACK);
 				for (int i = 0; i < pointList.size() - 1; i++) {
 					c = buildCurve(pointList.get(i), pointList.get(i + 1));
+					c.setCurve((x1 * scaleX) + border, (y1 * scaleY) + border, (ctrlx1 * scaleX) + border,
+							(ctrly1 * scaleY) + border, (ctrlx2 * scaleX) + border, (ctrly2 * scaleY) + border,
+							(x2 * scaleX) + border, (y2 * scaleY) + border);
 					graphCurve.append(c, true);
 				}
 				g2.draw(graphCurve);
@@ -140,32 +149,49 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				// Draw the Points
 				g2.setColor(Color.BLUE);
 				for (int i = 0; i < pointList.size() - 0; i++) {
-					g2.fillOval((int) (pointList.get(i).getX() * scaleX - recSize.getX() / 2),
-							(int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2), (int) recSize.getX(),
-							(int) recSize.getY());
+					g2.fillOval((int) (pointList.get(i).getX() * scaleX - recSize.getX() / 2) + border,
+							(int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2) + border,
+							(int) recSize.getX(), (int) recSize.getY());
 				}
 
 				// Iteration Value
-				if (arrayOfFloats != null) {
+				textWidth = g.getFontMetrics().stringWidth("" + arrayOfFloats[model.getCurIteration()]) + 2;
+				if (textWidth
+						+ (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1) + 2
+						+ border <= this.getWidth()) {
 					g2.drawString("" + arrayOfFloats[model.getCurIteration()],
-							(model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
+							(model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+									+ 2 + border,
+							this.getHeight() - 10);
+				} else {
+					g2.drawString("" + arrayOfFloats[model.getCurIteration()],
+							(model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+									+ border - textWidth,
 							this.getHeight() - 10);
 				}
+
 			}
 			// drag Information
-			if (tempP != null) {
+			if (tempP != null && pointDrag) {
 				dragInformation = "" + convertToValueY(getYValueAt((int) tempP.getX()));
-				g2.drawString(dragInformation, (int) (tempP.getX() * scaleX) + 10, (int) (tempP.getY() * scaleY) + 10);
+				textWidth = g.getFontMetrics().stringWidth("" + convertToValueY(getYValueAt((int) tempP.getX()))) + 2;
+				if (textWidth + (tempP.getX() * scaleX) + 10 + border <= this.getWidth()) {
+					g2.drawString(dragInformation, (int) (tempP.getX() * scaleX) + 10 + border,
+							(int) (tempP.getY() * scaleY) + 10);
+				} else {
+					g2.drawString(dragInformation, (int) (tempP.getX() * scaleX) - textWidth,
+							(int) (tempP.getY() * scaleY) + 10);
+				}
 			}
 
 			/*
 			 * // Actual Iteration Point Visualization g2.setColor(Color.RED);
 			 * if (arrayOfFloats != null) { for (int i = 0; i <
 			 * arrayOfFloats.length; i++) { g2.fillOval((int) (i * width /
-			 * (model.getIterations() - 1) * scaleX - recSize.getX() / 2), (int)
-			 * (convertToCanvasY((int) arrayOfFloats[i]) * scaleY -
-			 * recSize.getY() / 2), (int) recSize.getX(), (int) recSize.getY());
-			 * } }
+			 * (model.getIterations() - 1) * scaleX - recSize.getX() /
+			 * 2)+border, (int) (convertToCanvasY((int) arrayOfFloats[i]) *
+			 * scaleY - recSize.getY() / 2)+border, (int) recSize.getX(), (int)
+			 * recSize.getY()); } }
 			 */
 
 		} else if (isSwitch) {
@@ -177,8 +203,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				g2.setStroke(new BasicStroke(2));
 				g2.setColor(Color.BLACK);
 				for (int i = 0; i < pointList.size() - 1; i++) {
-					line = new Line2D.Double(pointList.get(i).getX() * scaleX, pointList.get(i).getY() * scaleY,
-							pointList.get(i + 1).getX() * scaleX, pointList.get(i + 1).getY() * scaleY);
+					line = new Line2D.Double(pointList.get(i).getX() * scaleX + border,
+							pointList.get(i).getY() * scaleY, pointList.get(i + 1).getX() * scaleX + border,
+							pointList.get(i + 1).getY() * scaleY);
 					graphCurve.append(line, true);
 				}
 				g2.draw(graphCurve);
@@ -186,27 +213,47 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				/*
 				 * // Draw the Points g2.setColor(Color.BLUE); for (int i = 0; i
 				 * < pointList.size() - 0; i++) { g2.fillOval((int)
-				 * (pointList.get(i).getX() * scaleX - recSize.getX() / 2),
-				 * (int) (pointList.get(i).getY() * scaleY - recSize.getY() /
-				 * 2), (int) recSize.getX(), (int) recSize.getY()); }
+				 * (pointList.get(i).getX() * scaleX - recSize.getX() / 2) +
+				 * border, (int) (pointList.get(i).getY() * scaleY -
+				 * recSize.getY() / 2), (int) recSize.getX(), (int)
+				 * recSize.getY()); }
 				 */
 
 				// Iteration Value
-				if (arrayOfBooleans != null) {
+				g2.setColor(Color.BLUE);
+				textWidth = g.getFontMetrics().stringWidth("" + arrayOfBooleans[model.getCurIteration()]) + 2;
+				if (textWidth
+						+ (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1) + 2
+						+ border <= this.getWidth()) {
+					g2.drawString("" + arrayOfBooleans[model.getCurIteration()],
+							(model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+									+ 2 + border,
+							this.getHeight() - 10);
+				} else {
 					g2.drawString("" + arrayOfBooleans[model.getCurIteration()],
-							(model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
+							(model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+									+ border - textWidth,
 							this.getHeight() - 10);
 				}
+
 			}
-			if (tempP != null) {
+			// When the switch graph is dragged
+			if (tempP != null && pointDrag) {
 				try {
 					int i;
-					for (i = 0; (i * this.getWidth() / (model.getIterations() - 1) < getMousePosition().getX()); i++) {
-
+					for (i = 0; (i * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
+							+ border < getMousePosition().getX()); i++) {
 					}
 					dragInformation = "" + i;
-					g2.drawString(dragInformation, (int) (getMousePosition().getX()) + 10,
-							(int) (getMousePosition().getY()) + 10);
+					textWidth = g.getFontMetrics().stringWidth("" + convertToValueY(getYValueAt((int) tempP.getX())))
+							+ 2;
+					if (textWidth + (tempP.getX() * scaleX) + 10 + border <= this.getWidth()) {
+						g2.drawString(dragInformation, (int) (getMousePosition().getX()) + 10 + border,
+								(int) (getMousePosition().getY() * scaleY) + 10);
+					} else {
+						g2.drawString(dragInformation, (int) (getMousePosition().getX()) - textWidth,
+								(int) (getMousePosition().getY() * scaleY) + 10);
+					}
 				} catch (Exception e) {
 				}
 			}
@@ -215,8 +262,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		// Iteration Line
 		g2.setColor(Color.BLUE);
 		g2.setStroke(new BasicStroke(1));
-		g2.drawLine((model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), 0,
-				(model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), this.getHeight());
+		g2.drawLine(border + (model.getCurIteration()) * (this.getWidth() - border * 2) / (model.getIterations() - 1),
+				0, border + (model.getCurIteration()) * (this.getWidth() - border * 2) / (model.getIterations() - 1),
+				this.getHeight());
 
 		// algorithmus
 		controller.calculateStateForTimeStep(model.getCurIteration());
@@ -241,17 +289,18 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		if (pointDrag && tempP != null) {
 			// Out of Bounds verhindern
 			int i = pointList.indexOf(tempP);
-			x = e.getX() / scaleX;
-			y = e.getY() / scaleY;
+			x = (e.getX() - border) / scaleX;
+			y = (e.getY() - border) / scaleY;
 			// y
-			if (e.getY() <= 0) {
+			if (e.getY() <= border) {
 				y = 0;
-			} else if (this.getHeight() <= e.getY()) {
-				y = this.getHeight() / scaleY;
+			} else if (this.getHeight() - border <= e.getY()) {
+				y = (this.getHeight() - border * 2) / scaleY;
 			}
 			// x
-			if (tempP == pointList.getFirst() || tempP == pointList.getLast() || pointList.get(i + 1).getX() < x+3
-					|| pointList.get(i - 1).getX() > x-3 || pointList.getFirst().getX() > x-3 || pointList.getLast().getX() < x+3) {
+			if (tempP == pointList.getFirst() || tempP == pointList.getLast() || pointList.get(i + 1).getX() < x + 2
+					|| pointList.get(i - 1).getX() > x - 2 || pointList.getFirst().getX() > x - 2
+					|| pointList.getLast().getX() < x + 2) {
 				x = tempP.getX();
 			}
 			tempP.setLocation(x, y);
@@ -269,7 +318,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	public void switchDragged(MouseEvent e) {
 		if (pointDrag && tempP != null && tempP != pointList.getFirst() && tempP != pointList.getLast()) {
 			int i = pointList.indexOf(tempP);
-			x = e.getX() / scaleX;
+			x = (e.getX() - border) / scaleX;
 
 			if (pointList.get(i + 1).getY() == tempP.getY()) {
 				// x
@@ -325,8 +374,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		boolean added = false;
 		boolean deletePoint = false;
 
-		int x = (int) (e.getX() / scaleX);
-		double y = e.getY() / scaleY;
+		int x = (int) ((e.getX() - border) / scaleX);
+		double y = (e.getY() - border) / scaleY;
 
 		// Click on Point
 		tempP = null;
@@ -353,7 +402,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 						break;
 					}
 					if (x < pointList.get(i).getX() && !added) {
-						if (e.getY() <= 0) {
+						if (e.getY() <= border) {
 							pointList.add(i, new Point((int) (x), 0));
 						} else {
 							pointList.add(i, new Point((int) (x), (int) y));
@@ -384,7 +433,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		boolean added = false;
 		boolean deletePoint = false;
 
-		double x = e.getX() / scaleX;
+		double x = (e.getX() - border) / scaleX;
 		e.getY();
 
 		// Halbe Iterations Distanz
@@ -411,7 +460,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 						// double p1, p2 um location der points zu bestimmen
 						double p1 = pointList.get(i - 1).getX();
 						double p2 = pointList.get(i).getX();
-						// Punkte hinzufgen, je nachdem ob true oder false
+						// Punkte hinzufügen, je nachdem ob true oder false
 						if (pointList.get(i - 1).getY() != (int) (height / 6)
 								&& pointList.get(i).getY() != (int) (height / 6)) {
 							pointList.add(i, new Point((int) ((x + p2) / 2 + dist), (int) (height - height / 6)));
@@ -435,13 +484,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 			if (deletePoint && tempP.getX() != 0
 					&& (tempP.getX() != this.getWidth() / scaleX || tempP != pointList.getLast())) {
 				int i = pointList.indexOf(tempP);
-				if (tempP.getY() == (int) (height / 6)) {
+				//If Right, else if Left
+				if (tempP.getY() == (int) (height / 6) && i < pointList.size() - 1 && i>0) {
 					pointList.remove(i);
 					pointList.remove(i - 1);
 					pointList.remove(i - 2);
 					pointList.remove(i - 3);
-				}
-				if (tempP.getY() == (int) (height - height / 6)) {
+				} else if (tempP.getY() == (int) (height - height / 6)) {
 					pointList.remove(i + 2);
 					pointList.remove(i + 1);
 					pointList.remove(i);
@@ -478,17 +527,17 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 			init = false;
 			// for scale on the first initialisation
 			if (width == -1 && height == -1) {
-				width = this.getWidth();
-				height = this.getHeight();
+				width = this.getWidth() - (border * 2);
+				height = this.getHeight() - (border * 2);
 			}
-
-			scaleX = this.getWidth() / width;
-			scaleY = this.getHeight() / height;
+			// Scale
+			scaleX = (this.getWidth() - (border * 2)) / width;
+			scaleY = (this.getHeight() - (border * 2)) / height;
 		}
 
 		// Scale
-		scaleX = this.getWidth() / width;
-		scaleY = this.getHeight() / height;
+		scaleX = (this.getWidth() - (border * 2)) / width;
+		scaleY = (this.getHeight() - (border * 2)) / height;
 		repaint();
 	}
 
@@ -524,11 +573,11 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	public void reset() {
 		pointList.removeAll(pointList);
 		if (isSwitch) {
-			pointList.addFirst(new Point(-4, (int) (height / 6)));
+			pointList.addFirst(new Point(-border, (int) (height / 6)));
 			pointList.addLast(new Point((int) (width) + 4, (int) (height / 6)));
 		} else {
 			pointList.addFirst(new Point(0, 0));
-			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
+			pointList.addLast(new Point((int) ((this.getWidth() - (border * 2)) / scaleX), 0));
 		}
 		repaint();
 	}
@@ -571,7 +620,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		// First time clicked on the Element
 		if (pointList.isEmpty()) {
 			pointList.addFirst(new Point(0, 0));
-			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
+			pointList.addLast(new Point((int) ((this.getWidth() - (border * 2)) / scaleX), 0));
 		}
 		repaint();
 	}
@@ -589,8 +638,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		isElement = false;
 		// First time clicked on the Element
 		if (pointList.isEmpty()) {
-			pointList.addFirst(new Point(-4, (int) (height / 6)));
-			pointList.addLast(new Point((int) (width) + 4, (int) (height / 6)));
+			pointList.addFirst(new Point(-border, (int) (height / 6)));
+			pointList.addLast(new Point((int) ((this.getWidth() - border) / scaleX), (int) (height / 6)));
 		}
 		repaint();
 	}
@@ -612,14 +661,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		y2 = (int) p2.getY();
 
 		// calculate the controllpoints
-		ctrlx1 = (int) p1.getX() + ((int) p2.getX() - (int) p1.getX()) / 2;
-		ctrlx2 = (int) p2.getX() - ((int) p2.getX() - (int) p1.getX()) / 2;
+		ctrlx1 = x1 + (x2 - x1) / 2;
+		ctrlx2 = x2 - (x2 - x1) / 2;
 		if (y1 < y2) {
-			ctrly1 = (int) p1.getY() + ((int) p2.getY() - (int) p1.getY()) / 10;
-			ctrly2 = (int) p2.getY() - ((int) p2.getY() - (int) p1.getY()) / 10;
+			ctrly1 = y1 + (y2 - y1) / 10;
+			ctrly2 = y2 - (y2 - y1) / 10;
 		} else {
-			ctrly1 = (int) p1.getY() - ((int) p1.getY() - (int) p2.getY()) / 10;
-			ctrly2 = (int) p2.getY() + ((int) p1.getY() - (int) p2.getY()) / 10;
+			ctrly1 = y1 - (y1 - y2) / 10;
+			ctrly2 = y2 + (y1 - y2) / 10;
 		}
 
 		// set the curve
@@ -634,7 +683,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	public void fillArrayofBooleans() {
 		for (int i = 0; i < arrayOfBooleans.length; i++) {
 			int t = (int) getYValueAt2((int) (i * width / (model.getIterations() - 1)));
-			if (t == (int) (height / 6)) {
+			if (t <= height / 2) {
 				arrayOfBooleans[i] = true;
 			} else {
 				arrayOfBooleans[i] = false;
@@ -729,6 +778,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				}
 			}
 		}
+		// else
 		return getYValueAt(xVal);
 	}
 

+ 161 - 144
src/ui/view/UpperNodeCanvas.java

@@ -305,10 +305,12 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 							controller.addTrackingObj((HolonObject) o);
 							((HolonObject) o).updateTrackingInfo();
 						}
-						controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
-						controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
-						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-						controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+						if (model.getShowConsoleLog()) {
+							controller.addTextToConsole("Tracking: ", Color.BLACK, 12, false, false, false);
+							controller.addTextToConsole("" + o.getName(), Color.BLUE, 12, true, false, false);
+							controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+							controller.addTextToConsole("" + o.getId(), Color.RED, 12, true, false, true);
+						}
 					}
 				}
 			}
@@ -555,136 +557,6 @@ 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)));
-				} 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);
-						}
-					}
-				}
-			}
-		} 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);
-
-				if (edgeHighlight.getCapacity() == -1) {
-					maxCap = Character.toString('\u221e');
-				} else if (edgeHighlight.getCapacity() == -2) {
-					maxCap = "???";
-				} else {
-					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);
-				}
-			}
-		}
-
-		// 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) (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)));
-				}
-			}
-
-			// 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 {
-						((HolonSwitch) cps).setAutoState(false);
-					}
-				}
-				// 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) (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) (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());
-				if (checkPath.exists()) {
-					img = new ImageIcon(cps.getImage()).getImage();
-				} else {
-					img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
-				}
-			}
-			g2.drawImage(img, cps.getPosition().x - model.getScaleDiv2(), cps.getPosition().y - model.getScaleDiv2(),
-					controller.getScale(), controller.getScale(), null);
-		}
-
 		// Objects connected to upperNode
 		int count = 0;
 		for (CpsEdge e : upperNode.getConnections()) {
@@ -725,8 +597,15 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 						g2.drawLine(obj.getPosition().x, obj.getPosition().y, (upperNode.getLeftBorder() >> 1),
 								(int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + 25);
 						if (showedInformation[0]) {
+							if (ed.getCapacity() == -1) {
+								maxCap = Character.toString('\u221e');
+							} else if (ed.getCapacity() == -2) {
+								maxCap = "???";
+							} else {
+								maxCap = String.valueOf(ed.getCapacity());
+							}
 							if (ed.getConnected() == 0 || ed.getConnected() == 1) {
-								g2.drawString(ed.getFlow() + "/" + ed.getCapacity(),
+								g2.drawString(ed.getFlow() + "/" + maxCap,
 										(obj.getPosition().x + (upperNode.getLeftBorder() >> 1)) / 2,
 										(obj.getPosition().y + (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count)
 												+ 25) / 2);
@@ -741,6 +620,140 @@ 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)));
+					} 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);
+							}
+						}
+					}
+				}
+			} 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);
+
+					if (edgeHighlight.getCapacity() == -1) {
+						maxCap = Character.toString('\u221e');
+					} else if (edgeHighlight.getCapacity() == -2) {
+						maxCap = "???";
+					} else {
+						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);
+					}
+				}
+			}
+
+			// 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();
+				} 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();
+					}
+				}
+				g2.drawImage(img, cps1.getPosition().x - model.getScaleDiv2(),
+						cps1.getPosition().y - model.getScaleDiv2(), controller.getScale(), controller.getScale(),
+						null);
+			}
+
 			// Border Highlighting
 			if (showedInformation[3]) {
 				g2.setColor(cps.getBorderColor());
@@ -874,10 +887,12 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 				cy = cps.getPosition().y - model.getScaleDiv2();
 				if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
 					tempCps = cps;
-					controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
-					controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+					if (model.getShowConsoleLog()) {
+						controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
+						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+					}
 					dragging = true;
 					if (e.isControlDown() && tempCps != null) {
 						if (model.getSelectedCpsObjects().contains(tempCps)) {
@@ -914,11 +929,13 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 						&& x >= (upperNode.getLeftBorder() >> 1) - model.getScaleDiv2()
 						&& y >= (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)) {
 					tempCps = cps;
-					controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
-					controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
-					controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
-					controller.setSelectedObjectID(tempCps.getId());
+					if (model.getShowConsoleLog()) {
+						controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
+						controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
+						controller.addTextToConsole("" + cps.getId(), Color.RED, 12, true, false, true);
+						controller.setSelectedObjectID(tempCps.getId());
+					}
 					// If drawing an Edge (CTRL down)
 					if (tempCps.getClass() == HolonObject.class) {
 						HolonObject tempObj = ((HolonObject) tempCps);