Przeglądaj źródła

Adds core.configuration Packet & NetworkTree Settings & Status

* NetworkTree Settings allows storing information about the different
nodes
* NetworkTreeStatus describes the Status of a single node
Andreas T. Meyer-Berg 5 lat temu
rodzic
commit
b8239c9778

+ 1 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/ImportController.java

@@ -12,12 +12,12 @@ import java.util.LinkedList;
 import javax.tools.JavaCompiler;
 import javax.tools.ToolProvider;
 
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ImportConfiguration;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration.ImportConfiguration;
 
 /**
  * Controller which manages Imported Classes of the

+ 15 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/ConfigurationManager.java

@@ -1,5 +1,11 @@
 package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
 
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration.ImportConfiguration;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration.NetworkTreeSettings;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration.SelectionModel;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration.VisualizationConfiguration;
+
+
 /**
  * Class which stores and returns the different configuration classes
  *
@@ -21,7 +27,10 @@ public class ConfigurationManager {
 	 * Selection model
 	 */
 	private SelectionModel selection;
-	
+	/**
+	 * Settings of the networkTree
+	 */
+	private NetworkTreeSettings networkTree;
 	/**
 	 * Initialize the Configuration Manager
 	 */
@@ -29,6 +38,7 @@ public class ConfigurationManager {
 		visual = new VisualizationConfiguration();
 		importConf = new ImportConfiguration();
 		selection = new SelectionModel();
+		networkTree = new NetworkTreeSettings();
 	}
 
 	/**
@@ -57,4 +67,8 @@ public class ConfigurationManager {
 	public SelectionModel getSelectionModel(){
 		return selection;
 	}
+	
+	public NetworkTreeSettings getNetworkTreeSettings(){
+		return networkTree;
+	}
 }

+ 8 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/ImportConfiguration.java → src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/configuration/ImportConfiguration.java

@@ -1,7 +1,14 @@
-package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration;
 
 import java.util.LinkedList;
 
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPerformance;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionPrecision;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PrecisionLink;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Protocol;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.MQTT_protocol;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.Ping_protocol;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleLink;

+ 76 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/configuration/NetworkTreeNodeStatus.java

@@ -0,0 +1,76 @@
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration;
+
+/**
+ * Status of node in the NetworkTree, stores information like if it is visible, expanded and which object is represented
+ *
+ * @author Andreas T. Meyer-Berg
+ */
+public class NetworkTreeNodeStatus {
+	
+	/**
+	 * Is the TreeNode expanded
+	 */
+	private boolean expanded;
+	
+	/**
+	 * Is the object visible or hidden
+	 */
+	private boolean visible;
+	
+	/**
+	 * Object which is represented
+	 */
+	private Object nodeObject;
+	
+	/**
+	 * Creates a new NetorkTreeNodeStatus for the object o, which is visible and not expanded 
+	 * @param o
+	 */
+	public NetworkTreeNodeStatus(Object o) {
+		nodeObject = o;
+		visible = true;
+		expanded = false;
+	}
+
+	/**
+	 * @return the expanded
+	 */
+	public boolean isExpanded() {
+		return expanded;
+	}
+
+	/**
+	 * @param expanded the expanded to set
+	 */
+	public void setExpanded(boolean expanded) {
+		this.expanded = expanded;
+	}
+
+	/**
+	 * @return the visible
+	 */
+	public boolean isVisible() {
+		return visible;
+	}
+
+	/**
+	 * @param visible the visible to set
+	 */
+	public void setVisible(boolean visible) {
+		this.visible = visible;
+	}
+
+	/**
+	 * @return the nodeObject
+	 */
+	public Object getNodeObject() {
+		return nodeObject;
+	}
+
+	/**
+	 * @param nodeObject the nodeObject to set
+	 */
+	public void setNodeObject(Object nodeObject) {
+		this.nodeObject = nodeObject;
+	}
+}

+ 46 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/configuration/NetworkTreeSettings.java

@@ -0,0 +1,46 @@
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration;
+
+import java.util.HashMap;
+
+/**
+ * Settings of the Network Tree and contains the settings for each node
+ *
+ * @author Andreas T. Meyer-Berg
+ */
+public class NetworkTreeSettings {
+	
+	/**
+	 * HashMap to access nodes
+	 */
+	private HashMap<Object, NetworkTreeNodeStatus> map; 
+	
+	/**
+	 * Initialize the NetworkTreeSettings
+	 */
+	public NetworkTreeSettings() {
+		map = new HashMap<Object, NetworkTreeNodeStatus>();
+	}
+	
+	/**
+	 * Returns the Status for the given Object
+	 * @param o Object, whose status should be returned
+	 * @return Status of the object
+	 */
+	public NetworkTreeNodeStatus getStatusOfObject(Object o){
+		NetworkTreeNodeStatus ret = map.get(o);
+		if(ret == null){
+			ret = new NetworkTreeNodeStatus(o);
+			map.put(o, ret);
+		}
+		return ret;
+	}
+	
+	/**
+	 * Adds an status for the given Object
+	 * @param o Object to be added
+	 * @param status Status of the object
+	 */
+	public void addStatusOfObject(Object o, NetworkTreeNodeStatus status){
+		map.put(o, status);
+	}
+}

+ 4 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/SelectionModel.java → src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/configuration/SelectionModel.java

@@ -1,7 +1,10 @@
-package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration;
 
 import java.util.LinkedList;
 
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.util.Pair;
 
 public class SelectionModel {

+ 1 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/VisualizationConfiguration.java → src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/configuration/VisualizationConfiguration.java

@@ -1,4 +1,4 @@
-package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration;
 
 /**
  * Stores the configuration details of the visualization

+ 5 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/configuration/package-info.java

@@ -0,0 +1,5 @@
+/**
+ * Package for configuration and setting classes of the model
+ * @author Andreas T. Meyer-Berg
+ */
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.core.configuration;