浏览代码

Removes remaining deprecated calls and legacy methods

Andreas T. Meyer-Berg 6 年之前
父节点
当前提交
228910b5f9

+ 2 - 355
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/Controller.java

@@ -1,13 +1,10 @@
 package de.tu_darmstadt.tk.SmartHomeNetworkSim.control;
 
-import java.util.Collection;
 import java.util.Observer;
 
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
+
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SimulationManager;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
 
@@ -76,135 +73,6 @@ public class Controller {
 		return networkController;
 	}
 	
-	/**
-	 * Moves the SmartDevice device to the specified location, if it exists
-	 * 
-	 * @param device
-	 *            the device to move
-	 * @param x
-	 *            new x position
-	 * @param y
-	 *            new y position
-	 * @param z
-	 *            new z position
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#moveSmartDevice(SmartDevice,int,int,int)} instead
-	 */
-	public void moveSmartDevice(SmartDevice device, int x, int y, int z) {
-		networkController.moveSmartDevice(device, x, y, z);
-	}
-
-	/**
-	 * Changes the dimension of the model, without scaling the SmartDevice
-	 * positions
-	 * 
-	 * @param width
-	 *            the new width to set
-	 * @param height
-	 *            the new height to set
-	 * @param depth
-	 *            the new depth to set
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setDimension(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int,int,int)} instead
-	 */
-	public void setDimension(int width, int height, int depth) {
-		settingsController.setDimension(width, height, depth);
-	}
-
-	/**
-	 * Changes the dimension of the model and moves SmartDevices to new relative
-	 * positions if {@code stretchModel} is true
-	 * 
-	 * @param width
-	 *            the new width to set
-	 * @param height
-	 *            the new height to set
-	 * @param depth
-	 *            the new depth to set
-	 * @param stretchModel
-	 *            true, if smartDevice positions should be stretched
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setDimension(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int,int,int,boolean)} instead
-	 */
-	public void setDimension(int width, int height, int depth, boolean stretchModel) {
-		settingsController.setDimension(width, height, depth, stretchModel);
-	}
-	
-	/**
-	 * Validate all device positions, move all devices into the bounds, if they are outside the visualization
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#validateDevicePosition(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
-	 */
-	public void validateDevicePosition() {
-		networkController.validateDevicePosition();
-	}
-	/**
-	 * Calculates the new scaled position, which should be in Bounds:
-	 * {@code radius < newPosition <
-	 * (upperBound - radius)}
-	 * 
-	 * @param oldPosition
-	 *            previous position that should be scaled
-	 * @param factor
-	 *            how much it is stretched/shrunk
-	 * @param upperBound
-	 *            upper bound of the frame, which should not be exceeded
-	 * @return new position that was calculated
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#scalePos(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int,double,int)} instead
-	 */
-	int scalePos(int oldPosition, double factor, int upperBound) {
-		return settingsController.scalePos(oldPosition, factor, upperBound);
-	}
-
-	/**
-	 * Adds SmartDevice to the Model and verifies that it is inside the model
-	 * bounds
-	 * 
-	 * @param sd
-	 *            SmartDevice which should be added to the model
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addSmartDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,SmartDevice)} instead
-	 */
-	public void addSmartDevice(SmartDevice sd) {
-		networkController.addSmartDevice(sd);
-	}
-
-	/**
-	 * Creates a new SmartDevice at the given Position. The Device is moved
-	 * into the model bounds, if the position is outside the bounds
-	 * 
-	 * @param name
-	 *            name of the smartDevice
-	 * @param x_pos
-	 *            position on the x-Axis
-	 * @param y_pos
-	 *            position on the y-Axis
-	 * @param z_pos
-	 *            position on the z-Axis
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#createSmartDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,String,int,int,int)} instead
-	 */
-	public void createSmartDevice(String name, int x_pos, int y_pos, int z_pos) {
-		networkController.createSmartDevice(name, x_pos, y_pos, z_pos);
-	}
-
-	/**
-	 * Deletes the given SmartDevice toDelete, removes it from its links and
-	 * connections.
-	 * 
-	 * @param toDelete
-	 *            the SmartDevice to delete
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#deleteSmartDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,SmartDevice)} instead
-	 */
-	public void deleteSmartDevice(SmartDevice toDelete) {
-		networkController.deleteSmartDevice(toDelete);
-	}
-
-	/**
-	 * Removes the SmartDevice from the given Link
-	 * 
-	 * @param toRemove the Device that should be removed from the link
-	 * @param link the Link, which contains the SmartDevice
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeSmartDeviceFromLink(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,SmartDevice,Link)} instead
-	 */
-	public void removeSmartDeviceFromLink(SmartDevice toRemove, Link link) {
-		networkController.removeSmartDeviceFromLink(toRemove, link);
-	}
-	
 	/**
 	 * Notifies Observer, which may update their visualization/state
 	 */
@@ -230,228 +98,7 @@ public class Controller {
 	public void removeObserver(Observer observer){
 		model.deleteObserver(observer);
 	}
-	
-	/**
-	 * @return the width
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#getWidth(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
-	 */
-	public int getWidth() {
-		return settingsController.getWidth();
-	}
-
-	/**
-	 * @param width the width to set
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setWidth(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int)} instead
-	 */
-	public void setWidth(int width) {
-		settingsController.setWidth(width);
-	}
-
-	/**
-	 * @return the height
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#getHeight(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
-	 */
-	public int getHeight() {
-		return settingsController.getHeight();
-	}
-
-	/**
-	 * @param height the height to set
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setHeight(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int)} instead
-	 */
-	public void setHeight(int height) {
-		settingsController.setHeight(height);
-	}
-
-	/**
-	 * @return the depth
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.ImportController#getDepth(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
-	 */
-	public int getDepth() {
-		return settingsController.getDepth();
-	}
-
-	/**
-	 * @param depth the depth to set
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController#setDepth(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,int)} instead
-	 */
-	public void setDepth(int depth) {
-		settingsController.setDepth(depth);
-	}
-	
-	/**
-	 * @return the device_visualization_radius
-	 * @deprecated 
-	 */
-	int getDevice_visualization_radius() {
-		return settingsController.getDeviceVisualizationRadius();
-	}
-	
-	/**
-	 * Adds Link to the model
-	 * @param link link to add
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addLink(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link)} instead
-	 */
-	public void addLink(Link link){
-		networkController.addLink(link);
-	}
-	
-	/**
-	 * Removes Link from the Model
-	 * @param link link to remove
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeLink(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link)} instead
-	 */
-	public void removeLink(Link link){
-		networkController.removeLink(link);
-	}
-	
-	/**
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#getLinks(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
-	 */
-	public Collection<Link> getLinks(){
-		return networkController.getLinks();
-	}
-	
-	/**
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection)} instead
-	 */
-	public void addConnection(Connection connection){
-		networkController.addConnection(connection);
-	}
-	
-	/**
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection)} instead
-	 */
-	public void removeConnection(Connection connection){
-		networkController.removeConnection(connection);
-	}
-	
-	/**
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#getConnections(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
-	 */
-	public Collection<Connection> getConnections(){
-		return networkController.getConnections();
-	}
-
-	/**
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addLinkToDevice(Link,SmartDevice)} instead
-	 */
-	public void addLinkToDevice(Link newLink, SmartDevice smartDevice) {
-		networkController.addLinkToDevice(newLink, smartDevice);
-	}
-
-	/**
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeLinkFromDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link,SmartDevice)} instead
-	 */
-	public void removeLinkFromDevice(Link link, SmartDevice smartDevice) {
-		networkController.removeLinkFromDevice(link, smartDevice);
-	}
-	
-	/**
-	 * Changes Roles of the device to the newRole, returns true, if the role was successfully changed, false if not.
-	 * If false is returned, the device will no longer be part of this connection.
-	 * 
-	 * @param protocol protocol which should be edited
-	 * @param device device which should be added
-	 * @param newRole new role of the device
-	 * @return true if new role was set, false if not
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#changeRoleOfDevice(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Protocol,Connection,Port,int)} instead
-	 */
-	public boolean changeRoleOfDevice(Protocol protocol, Connection con, Port device, int newRole){
-		return networkController.changeRoleOfDevice(protocol, con, device, newRole);
-	}
-	
-	/**
-	 * Removes Device p from the Connection
-	 * @param p Port/Device to remove
-	 * @param connection connection, which should remove the device
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeDeviceFromConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Port,Connection)} instead
-	 */
-	public void removeDeviceFromConnection(Port p, Connection connection){
-		networkController.removeDeviceFromConnection(p, connection);
-	}
-	
-	/**
-	 * Adds Device p to the connection with the specified role
-	 * @param p Port/Device to be added
-	 * @param connection Connection
-	 * @param role new role of the device (See {@link Protocol} Roles)
-	 * @return true, if the device was added
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#addDeviceToConnection(Port,Connection,int)} instead
-	 */
-	public boolean addDeviceToConnection(Port p, Connection connection, int role){
-		return networkController.addDeviceToConnection(p, connection, role);
-	}
-
-	/**
-	 * Changes the link of the given connection to the new link. Returns true if it was successfully changed, false if it could not be changed.
-	 * @param connection
-	 * @param newLink
-	 * @return true on successful change, false on failure & restore
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#changeLinkOfConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection,Link)} instead
-	 */
-	public boolean changeLinkOfConnection(Connection connection, Link newLink) {
-		return networkController.changeLinkOfConnection(connection, newLink);
-	}
-	
-	/**
-	 * Changes the type of the connection to the new Type and updates all references
-	 * @param connection connection to be updated
-	 * @param newConnectionClass class of new type
-	 * @return newly created connection
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#changeConnectionType(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection,Class<? extends Connection>)} instead
-	 */
-	public Connection changeConnectionType(Connection connection, Class<? extends Connection> newConnectionClass) {
-		return networkController.changeConnectionType(connection, newConnectionClass);
-	}
-	
-	/**
-	 * Deletes the network model, removes all Devices, Connections and Links
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#deleteNetworkModel(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller)} instead
-	 */
-	public void deleteNetworkModel(){
-		networkController.deleteNetworkModel();
-	}
-
-	/**
-	 * Deletes the Connection c and all references
-	 * @param c Connection to be deleted
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#deleteConnection(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Connection)} instead
-	 */
-	public void deleteConnection(Connection c) {
-		networkController.deleteConnection(c);
-	}
-
-	/**
-	 * Deletes Link l and all references
-	 * @param l Link to be deleted
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#deleteLink(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link)} instead
-	 */
-	public void deleteLink(Link l) {
-		networkController.deleteLink(l);
-	}
-	
-	/**
-	 * Removes Connection from Link
-	 * @param c Connection to be removed
-	 * @param l Link to be removed
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#removeConnectionFromLink(Connection,Link)} instead
-	 */
-	public void removeConnectionFromLink(Connection c, Link l) {
-		networkController.removeConnectionFromLink(c, l);
-	}
-
-	/**
-	 * Changes the type of the link to new type, specified by the given Link-class
-	 * @param oldLink oldLink, whose attributes will b copied to the new Link 
-	 * @param newType Type/Class of the new Link
-	 * @return newly created Link, null on failure/error
-	 * @deprecated Use {@link de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController#changeLinkType(de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller,Link,Class<? extends Link>)} instead
-	 */
-	public Link changeLinkType(Link oldLink, Class<? extends Link> newType) {
-		return networkController.changeLinkType(oldLink, newType);
-	}
-	
+		
 	// TODO: Maybe Settings controller ? 
 	/**
 	 * Reset Simulation 

+ 25 - 19
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/popups/ConnectionCreationPanel.java

@@ -12,6 +12,7 @@ import java.util.concurrent.ThreadLocalRandom;
 import java.util.stream.Collectors;
 
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPerformance;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
@@ -123,10 +124,13 @@ public class ConnectionCreationPanel extends JScrollPane {
 	 */
 	private boolean protocolChange = false;
 	/**
-	 * Controller to
+	 * Controller to manipulate the model
 	 */
 	private Controller controller;
-
+	/**
+	 * Network Controller
+	 */
+	private NetworkController network;
 	/**
 	 * List of available protocols -> should be moved to the Model and accessed
 	 * via controller
@@ -152,6 +156,7 @@ public class ConnectionCreationPanel extends JScrollPane {
 	public ConnectionCreationPanel(Connection connection, Controller controller) {
 		this.controller = controller;
 		this.connection = connection;
+		this.network = controller.getNetworkController();
 		ports = new Port[connection.getParticipants().size()];
 		int i = 0;
 		for (Port d : connection.getParticipants()) {
@@ -165,6 +170,7 @@ public class ConnectionCreationPanel extends JScrollPane {
 	public ConnectionCreationPanel(Collection<Port> ports, Link l,
 			Controller controller) {
 		this.controller = controller;
+		this.network = controller.getNetworkController();
 		connection = new ConnectionPerformance(l, new MQTT_protocol());
 		this.ports = new Port[ports.size()];
 		int i = 0;
@@ -223,8 +229,8 @@ public class ConnectionCreationPanel extends JScrollPane {
 
 		// Check if model contains link
 		if (connection.getLink() != null
-				&& !controller.getLinks().contains(connection.getLink()))
-			controller.addLink(connection.getLink());
+				&& !network.getLinks().contains(connection.getLink()))
+			network.addLink(connection.getLink());
 
 		cmbSelectedLink = new JComboBox<String>();
 		cmbSelectedLink.setBounds(155, 40, 125, 20);
@@ -240,7 +246,7 @@ public class ConnectionCreationPanel extends JScrollPane {
 					if (cmbSelectedLinkIndex == -1)
 						return;
 					Link newLink = null;
-					Iterator<Link> linkIterator = controller.getLinks()
+					Iterator<Link> linkIterator = network.getLinks()
 							.iterator();
 					for (int i = 0; i < cmbSelectedLinkIndex
 							&& linkIterator.hasNext(); i++) {
@@ -248,7 +254,7 @@ public class ConnectionCreationPanel extends JScrollPane {
 					}
 					if (linkIterator.hasNext())
 						newLink = linkIterator.next();
-					if (!controller.changeLinkOfConnection(connection, newLink)) {
+					if (!network.changeLinkOfConnection(connection, newLink)) {
 						// if LinkChange failed: Restore
 						cmbSelectedLink.setSelectedIndex(lastLinkIndex);
 					} else {
@@ -283,7 +289,7 @@ public class ConnectionCreationPanel extends JScrollPane {
 			cmbConnection.getSelectedIndex();
 			int selectedIndex = cmbConnection.getSelectedIndex();
 			if (lastConnectionIndex != selectedIndex && selectedIndex != -1) {
-				Connection newConnection = controller.changeConnectionType(
+				Connection newConnection = network.changeConnectionType(
 						connection, availableConnection.get(selectedIndex));
 				if (newConnection == null) {
 					System.out.println("Warning invalidConnection changed");
@@ -389,17 +395,17 @@ public class ConnectionCreationPanel extends JScrollPane {
 						if (oldSelected < 0 || oldSelected >= disconnectedIndex
 								|| oldSelected == oldDisconnected) {
 							// Invalid Index -> Disconnected
-							controller.removeDeviceFromConnection(ports[i],
+							network.removeDeviceFromConnection(ports[i],
 									connection);
 							boxes[i].setSelectedIndex(disconnectedIndex);
 						} else {
-							if (controller.addDeviceToConnection(ports[i],
+							if (network.addDeviceToConnection(ports[i],
 									connection, oldSelected)) {
 								// Set to Box to display role
 								boxes[i].setSelectedIndex(oldSelected);
 							} else {
 								// Could not be added -> Disconnected
-								controller.removeDeviceFromConnection(ports[i],
+								network.removeDeviceFromConnection(ports[i],
 										connection);
 								boxes[i].setSelectedIndex(disconnectedIndex);
 							}
@@ -551,10 +557,10 @@ public class ConnectionCreationPanel extends JScrollPane {
 
 						}
 					}
-					if (!controller.getLinks().contains(connection.getLink()))
-						controller.addLink(connection.getLink());
-					if (!controller.getConnections().contains(connection))
-						controller.addConnection(connection);
+					if (!network.getLinks().contains(connection.getLink()))
+						network.addLink(connection.getLink());
+					if (!network.getConnections().contains(connection))
+						network.addConnection(connection);
 				}
 
 				connection.setName(tfName.getText());
@@ -606,20 +612,20 @@ public class ConnectionCreationPanel extends JScrollPane {
 				int n = 5;
 				for (int j = 0; j <= n; j++) {
 					if (j == 0) {// Try to add Router first
-						if (controller.addDeviceToConnection(currentPort,
+						if (network.addDeviceToConnection(currentPort,
 								connection, 0)) {
 							boxes[pos].setSelectedIndex(0);
 							break;
 						}
 					} else if (j == n) {// If it could not be added
 						boxes[pos].setSelectedIndex(disconnectedIndex);
-						controller.removeDeviceFromConnection(currentPort,
+						network.removeDeviceFromConnection(currentPort,
 								connection);
 						break;
 					} else {
 						int randomRole = ThreadLocalRandom.current().nextInt(0,
 								disconnectedIndex);
-						if (controller.addDeviceToConnection(currentPort,
+						if (network.addDeviceToConnection(currentPort,
 								connection, randomRole)) {
 							boxes[pos].setSelectedIndex(randomRole);
 							break;
@@ -642,7 +648,7 @@ public class ConnectionCreationPanel extends JScrollPane {
 					/**
 					 * True if role was successfully changed
 					 */
-					boolean successfullChange = controller.changeRoleOfDevice(
+					boolean successfullChange = network.changeRoleOfDevice(
 							connection.getProtocol(), connection, ports[pos],
 							selected);
 					/**
@@ -701,7 +707,7 @@ public class ConnectionCreationPanel extends JScrollPane {
 
 		// Update selected Link
 		int linkIndex = 0;
-		for (Link l : controller.getLinks()) {
+		for (Link l : network.getLinks()) {
 			cmbSelectedLink.addItem(l.getName());
 			if (l.equals(connection.getLink())) {
 				lastLinkIndex = linkIndex;

+ 9 - 5
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/popups/LinkCreationPanel.java

@@ -12,6 +12,7 @@ import javax.swing.JFrame;
 
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.ImportController;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
@@ -42,8 +43,10 @@ public class LinkCreationPanel extends JScrollPane{
 	private int lastIndex = -1;
 	
 	private Controller controller;
+	private NetworkController network;
 	public LinkCreationPanel(Link link, Controller controller) {
 		this.controller = controller;
+		this.network = controller.getNetworkController();
 		newLink = link;
 		this.devices = new SmartDevice[link.getDevices().size()];
 		int i=0;
@@ -56,11 +59,12 @@ public class LinkCreationPanel extends JScrollPane{
 	
 	public LinkCreationPanel(Collection<SmartDevice> devices, Controller controller) {
 		this.controller = controller;
+		this.network = controller.getNetworkController();
 		newLink = new SimpleLink("LinkName");
 		this.devices = new SmartDevice[devices.size()];
 		int i=0;
 		for(SmartDevice d: devices){
-			controller.addLinkToDevice(newLink, d);
+			network.addLinkToDevice(newLink, d);
 			this.devices[i++] = d;
 		}
 		edit = false;
@@ -127,7 +131,7 @@ public class LinkCreationPanel extends JScrollPane{
 				/**
 				 * Imported Link which should be created and configured
 				 */
-				Link importedLink = controller.changeLinkType(newLink, availableLinks.get(
+				Link importedLink = network.changeLinkType(newLink, availableLinks.get(
 							cmbLinkType.getSelectedIndex()));
 				if (importedLink == null) {
 					System.out
@@ -218,7 +222,7 @@ public class LinkCreationPanel extends JScrollPane{
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				if(!edit){
-					controller.addLink(newLink);
+					network.addLink(newLink);
 				}
 				newLink.setName(tfName.getText());
 				content.setVisible(false);
@@ -249,9 +253,9 @@ public class LinkCreationPanel extends JScrollPane{
 				@Override
 				public void actionPerformed(ActionEvent e) {
 					if(cmbDev.getSelectedIndex()==0 && !newLink.getDevices().contains(devices[pos])){
-						controller.addLinkToDevice(newLink, devices[pos]);
+						network.addLinkToDevice(newLink, devices[pos]);
 					}else if(cmbDev.getSelectedIndex()==1&&newLink.getDevices().contains(devices[pos])){
-						controller.removeLinkFromDevice(newLink, devices[pos]);
+						network.removeLinkFromDevice(newLink, devices[pos]);
 					}
 				}
 			});

+ 4 - 3
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/popups/NetworkTreePanel.java

@@ -6,6 +6,7 @@ import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.DefaultMutableTreeNode;
 
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.NetworkController;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
@@ -19,14 +20,14 @@ public class NetworkTreePanel extends JPanel {
 	private static final long serialVersionUID = 6946547116132845220L;
 
 	public NetworkTreePanel(Controller c) {
-		
+		NetworkController network = c.getNetworkController();
 		JTree tree = new JTree();
 		tree.setPreferredSize(new Dimension(400, 600));
 		tree.setMaximumSize(new Dimension(600, 1000));
 		DefaultMutableTreeNode root = new DefaultMutableTreeNode("Network");
-		for(Link l: c.getLinks()){
+		for(Link l: network.getLinks()){
 			DefaultMutableTreeNode link = new DefaultMutableTreeNode(l.getName());
-			for(Connection con: c.getConnections()){
+			for(Connection con: network.getConnections()){
 				if(!l.getConnections().contains(con))continue;
 				DefaultMutableTreeNode connection = new DefaultMutableTreeNode(con.getName());
 				for(Port p:con.getParticipants()){

+ 3 - 3
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/popups/SmartDeviceCreationPopUp.java

@@ -78,8 +78,8 @@ public class SmartDeviceCreationPopUp extends JDialog {
 		setModal(true);
 		// setType(Type.POPUP); -> Crashes on Linux
 		this.c = control;
-		this.maxX = c.getWidth();
-		this.maxY = c.getHeight();
+		this.maxX = c.getControllerConfiguration().getWidth();
+		this.maxY = c.getControllerConfiguration().getHeight();
 		this.visualisationRadius = c.getControllerConfiguration().getDeviceVisualizationRadius();
 		this.edit = edit;
 		newDevice = deviceToEdit;
@@ -231,7 +231,7 @@ public class SmartDeviceCreationPopUp extends JDialog {
 		if (valid) {
 			if (edit == false) {
 				// Add new Device, update Visualization and dispose the PopUp
-				c.addSmartDevice(newDevice);
+				c.getNetworkController().addSmartDevice(newDevice);
 
 			}
 			c.notifyObservers();