|
@@ -10,6 +10,7 @@ import javax.swing.JMenuItem;
|
|
|
import javax.swing.JOptionPane;
|
|
|
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.SettingsController;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.AboutPopUp;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.popups.ConnectionCreationDialog;
|
|
@@ -33,6 +34,11 @@ public class MenuBar extends JMenuBar {
|
|
|
* Controller to manipulate the model
|
|
|
*/
|
|
|
private Controller controller;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Settings Controller
|
|
|
+ */
|
|
|
+ private SettingsController config;
|
|
|
|
|
|
/**
|
|
|
* JMenu for the Simulation
|
|
@@ -64,6 +70,9 @@ public class MenuBar extends JMenuBar {
|
|
|
*/
|
|
|
private JMenu mnHelp;
|
|
|
|
|
|
+ /**
|
|
|
+ * JMenu for examples
|
|
|
+ */
|
|
|
private JMenu mnExamples;
|
|
|
|
|
|
/**
|
|
@@ -79,9 +88,12 @@ public class MenuBar extends JMenuBar {
|
|
|
*/
|
|
|
public MenuBar(Controller controller) {
|
|
|
this.controller = controller;
|
|
|
+ this.config = controller.getSettingsController();
|
|
|
|
|
|
+
|
|
|
this.setLayout(new FlowLayout(FlowLayout.LEADING));
|
|
|
|
|
|
+
|
|
|
initializeSimulationMenu();
|
|
|
this.add(mnSimulation);
|
|
|
initializeCreateMenu();
|
|
@@ -121,7 +133,14 @@ public class MenuBar extends JMenuBar {
|
|
|
|
|
|
mntmCreateDevice.addActionListener(e -> {
|
|
|
SmartDevice newDevice = new SmartDevice();
|
|
|
- controller.getNetworkController().validateDevicePosition();
|
|
|
+ /**
|
|
|
+ * Device radius,
|
|
|
+ */
|
|
|
+ int rad = config.getDeviceVisualizationRadius();
|
|
|
+ int x = (int)Math.round(Math.random()*(config.getWidth()-2*rad))+rad;
|
|
|
+ int y = (int)Math.round(Math.random()*(config.getHeight()-2*rad))+rad;
|
|
|
+ int z = (int)Math.round(Math.random()*(config.getDepth()-2*rad))+rad;
|
|
|
+ controller.getNetworkController().moveSmartDevice(newDevice, x, y, z);
|
|
|
|
|
|
SmartDeviceCreationPopUp popUp = new SmartDeviceCreationPopUp(newDevice, false, controller);
|
|
|
popUp.setLocationRelativeTo(this.getParent());
|