|
@@ -0,0 +1,100 @@
|
|
|
+package de.tu_darmstadt.tk.SmartHomeNetworkSim.view;
|
|
|
+
|
|
|
+import java.awt.Dimension;
|
|
|
+import java.awt.Toolkit;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import javax.swing.JFrame;
|
|
|
+import javax.swing.JMenuBar;
|
|
|
+import javax.swing.JMenuItem;
|
|
|
+
|
|
|
+import java.awt.BorderLayout;
|
|
|
+
|
|
|
+import javax.swing.JPanel;
|
|
|
+import javax.swing.SwingConstants;
|
|
|
+
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Main class of the GUI, which combines the UserInterface and visualisation of the simulation.
|
|
|
+ *
|
|
|
+ * @author Andreas T. Meyer-Berg
|
|
|
+ */
|
|
|
+@SuppressWarnings("serial")
|
|
|
+public class MainFrame extends JFrame {
|
|
|
+
|
|
|
+ private final JPanel panel;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Model of the smart home
|
|
|
+ */
|
|
|
+ private Model model;
|
|
|
+ private Controller control;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates a new Frame for the program, which is the most outer frame of the application
|
|
|
+ * @param m Model which is represented
|
|
|
+ * @param c Controller which handles the user interaction
|
|
|
+ */
|
|
|
+ public MainFrame(Model m, Controller c) {
|
|
|
+
|
|
|
+ setTitle("Smart Home Network Simulator");
|
|
|
+
|
|
|
+ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
+ getContentPane().setLayout(new BorderLayout(0, 0));
|
|
|
+ panel = new VisualisationPanel(m);
|
|
|
+ getContentPane().add(panel, BorderLayout.CENTER);
|
|
|
+
|
|
|
+ try {
|
|
|
+ /**
|
|
|
+ * Icon of the MainFrame UI
|
|
|
+ */
|
|
|
+ this.setIconImage(ImageIO.read(new File("src/main/ressources/images/SmartHomeNetworkSim_icon.jpeg")));
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.err.println("WARNING: Failed to load Icon image in MainFrame.java");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ JMenuBar menuBar = new JMenuBar();
|
|
|
+ getContentPane().add(menuBar, BorderLayout.NORTH);
|
|
|
+
|
|
|
+ JMenuItem mntmOptions = new JMenuItem("Options");
|
|
|
+ mntmOptions.setHorizontalAlignment(SwingConstants.LEFT);
|
|
|
+ menuBar.add(mntmOptions);
|
|
|
+
|
|
|
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
|
|
+ int width = screenSize.width;
|
|
|
+ int height = screenSize.height;
|
|
|
+ this.setBounds(width/8, height/8, 6*width/8, 6*height/8);
|
|
|
+ this.setMinimumSize(new Dimension(640, 480));
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ public MainFrame() {
|
|
|
+ super();
|
|
|
+ this.setTitle("Smart Home Network Simulator");
|
|
|
+ this.setBackground(Color.WHITE);
|
|
|
+ try {
|
|
|
+ /**
|
|
|
+ * Icon of the MainFrame UI
|
|
|
+ *//*
|
|
|
+ this.setIconImage(ImageIO.read(new File("src/main/ressources/images/SmartHomeNetworkSim_icon.jpeg")));
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.err.println("WARNING: Failed to load Icon image in MainFrame.java");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ this.setBounds(0, 0, 1000, 1000);
|
|
|
+ this.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
|
|
+ JMenuBar menu = new JMenuBar();
|
|
|
+ menu.add(new JMenuItem("Test1"));
|
|
|
+ menu.add(new JMenuItem("Test2"));
|
|
|
+ menu.add(new JMenuItem("Test3"));
|
|
|
+ menu.setVisible(true);
|
|
|
+ this.add(menu);
|
|
|
+ this.add(new VisualisationPanel());
|
|
|
+
|
|
|
+ }*/
|
|
|
+}
|