Procházet zdrojové kódy

Merge remote-tracking branch 'origin/LWR-Util-debug' into BP_master

Conflicts:
	src/ui/view/Util.java
Andreas T. Meyer-Berg před 7 roky
rodič
revize
378303610c
3 změnil soubory, kde provedl 262 přidání a 262 odebrání
  1. 85 85
      src/ui/view/AboutUsPopUp.java
  2. 176 176
      src/ui/view/AddElementPopUp.java
  3. 1 1
      src/ui/view/Util.java

+ 85 - 85
src/ui/view/AboutUsPopUp.java

@@ -1,86 +1,86 @@
-package ui.view;
-
-import javax.swing.*;
-import java.awt.*;
-
-/**
- * AboutUs Pop Up Window.
- *
- * @author Gruppe14
- */
-public class AboutUsPopUp extends JFrame {
-    /**
-     * Serial.
-     */
-    private static final long serialVersionUID = 1L;
-    private final JPanel contentPanel = new JPanel();
-    private final JPanel contentPanel2 = new JPanel();
-    private final JPanel contentPanel3 = new JPanel();
-    private JLabel titel = new JLabel("Cyber Physical Systems");
-    private JLabel h1 = new JLabel("Project Management & Architect");
-    private JLabel h2 = new JLabel("Software Developers");
-    private JLabel h3 = new JLabel("Documentation");
-    private JLabel h4 = new JLabel("Additional Collaborators");
-    private JLabel description = new JLabel("A discrete-time simulator for modeling Smart Grids that follow a Holon-based model.");
-    private JLabel namesManagement = new JLabel("C. Garcia Cordero");
-    private JLabel namesDevelopers = new JLabel("K. Trometer, D. Rieder, T. Zheng, J. Widhalm, E. Palza and I. Dix");
-    private JLabel namesDocumentation = new JLabel("E. Palza, C. Garcia Cordero");
-    private JLabel namesCollaborators = new JLabel("R. Egert and F. Volk");
-    private JLabel credits = new JLabel();
-
-    /**
-     * Constructor
-     */
-    public AboutUsPopUp(JFrame parentFrame) {
-        super(Languages.getLanguage()[14]);
-
-        // Set fonts
-        Font fontTitle = new Font("Titel", 2, 35);
-        titel.setFont(fontTitle);
-        titel.setBounds(150, 30, 100, 20);
-        Font headerFont = new Font("Header", 2, 20);
-        h1.setFont(headerFont);
-        h2.setFont(headerFont);
-        h3.setFont(headerFont);
-        h4.setFont(headerFont);
-
-        // Set labels
-        titel.setHorizontalAlignment(JLabel.CENTER);
-
-        // Set layout
-        contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
-        contentPanel2.setLayout(new BoxLayout(contentPanel2, BoxLayout.Y_AXIS));
-        contentPanel3.setLayout(new BoxLayout(contentPanel3, BoxLayout.Y_AXIS));
-        
-        this.setIconImage(Util.loadImage(this,"/Images/Dummy_House.png",30,30));
-        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-        setBounds(100, 100, 500, 800);
-        setLocationRelativeTo(parentFrame);
-
-        contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-        contentPanel.add(titel);
-        contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-        contentPanel.add(description);
-        contentPanel.add(Box.createRigidArea(new Dimension(0, 60)));
-        getContentPane().add(contentPanel, BorderLayout.NORTH);
-
-        contentPanel2.add(h1);
-        contentPanel2.add(namesManagement);
-        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
-        contentPanel2.add(h2);
-        contentPanel2.add(namesDevelopers);
-        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
-        contentPanel2.add(h3);
-        contentPanel2.add(namesDocumentation);
-        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
-        contentPanel2.add(h4);
-        contentPanel2.add(namesCollaborators);
-        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
-        contentPanel2.add(credits);
-        getContentPane().add(contentPanel2, BorderLayout.CENTER);
-
-        contentPanel3.add(Box.createRigidArea(new Dimension(0, 50)));
-        //contentPanel3.add(namesDevelopers);
-        getContentPane().add(contentPanel3, BorderLayout.SOUTH);
-    }
+package ui.view;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * AboutUs Pop Up Window.
+ *
+ * @author Gruppe14
+ */
+public class AboutUsPopUp extends JFrame {
+    /**
+     * Serial.
+     */
+    private static final long serialVersionUID = 1L;
+    private final JPanel contentPanel = new JPanel();
+    private final JPanel contentPanel2 = new JPanel();
+    private final JPanel contentPanel3 = new JPanel();
+    private JLabel titel = new JLabel("Cyber Physical Systems");
+    private JLabel h1 = new JLabel("Project Management & Architect");
+    private JLabel h2 = new JLabel("Software Developers");
+    private JLabel h3 = new JLabel("Documentation");
+    private JLabel h4 = new JLabel("Additional Collaborators");
+    private JLabel description = new JLabel("A discrete-time simulator for modeling Smart Grids that follow a Holon-based model.");
+    private JLabel namesManagement = new JLabel("C. Garcia Cordero");
+    private JLabel namesDevelopers = new JLabel("K. Trometer, D. Rieder, T. Zheng, J. Widhalm, E. Palza and I. Dix");
+    private JLabel namesDocumentation = new JLabel("E. Palza, C. Garcia Cordero");
+    private JLabel namesCollaborators = new JLabel("R. Egert and F. Volk");
+    private JLabel credits = new JLabel();
+
+    /**
+     * Constructor
+     */
+    public AboutUsPopUp(JFrame parentFrame) {
+        super(Languages.getLanguage()[14]);
+
+        // Set fonts
+        Font fontTitle = new Font("Titel", 2, 35);
+        titel.setFont(fontTitle);
+        titel.setBounds(150, 30, 100, 20);
+        Font headerFont = new Font("Header", 2, 20);
+        h1.setFont(headerFont);
+        h2.setFont(headerFont);
+        h3.setFont(headerFont);
+        h4.setFont(headerFont);
+
+        // Set labels
+        titel.setHorizontalAlignment(JLabel.CENTER);
+
+        // Set layout
+        contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
+        contentPanel2.setLayout(new BoxLayout(contentPanel2, BoxLayout.Y_AXIS));
+        contentPanel3.setLayout(new BoxLayout(contentPanel3, BoxLayout.Y_AXIS));
+        
+        this.setIconImage(Util.loadImage(this,"/Images/Dummy_House.png",30,30));
+        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+        setBounds(100, 100, 500, 800);
+        setLocationRelativeTo(parentFrame);
+
+        contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+        contentPanel.add(titel);
+        contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
+        contentPanel.add(description);
+        contentPanel.add(Box.createRigidArea(new Dimension(0, 60)));
+        getContentPane().add(contentPanel, BorderLayout.NORTH);
+
+        contentPanel2.add(h1);
+        contentPanel2.add(namesManagement);
+        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
+        contentPanel2.add(h2);
+        contentPanel2.add(namesDevelopers);
+        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
+        contentPanel2.add(h3);
+        contentPanel2.add(namesDocumentation);
+        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
+        contentPanel2.add(h4);
+        contentPanel2.add(namesCollaborators);
+        contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
+        contentPanel2.add(credits);
+        getContentPane().add(contentPanel2, BorderLayout.CENTER);
+
+        contentPanel3.add(Box.createRigidArea(new Dimension(0, 50)));
+        //contentPanel3.add(namesDevelopers);
+        getContentPane().add(contentPanel3, BorderLayout.SOUTH);
+    }
 }

+ 176 - 176
src/ui/view/AddElementPopUp.java

@@ -1,177 +1,177 @@
-package ui.view;
-
-import classes.AbstractCpsObject;
-import classes.HolonElement;
-import classes.HolonObject;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-
-/**
- * popup for adding an Holon Element to a holon Object.
- * 
- * @author Gruppe14
- */
-public class AddElementPopUp extends JDialog {
-
-	/**
-	 * Serial.
-	 */
-	private static final long serialVersionUID = 1L;
-	private final JPanel contentPanel = new JPanel();
-	private JTextField elementName;
-	private JTextField providedEnergy;
-	private JTextField amount;
-	private HolonElement hl;
-	private AbstractCpsObject tempCps;
-
-//	/**
-//	 * Launch the application.
-//	 *
-//	 * @param args
-//	 *            standard
-//	 */
-//	public static void main(String[] args) {
-//		try {
-//
-//			AddElementPopUp dialog = new AddElementPopUp();
-//			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
-//			dialog.setVisible(true);
-//		} catch (Exception e) {
-//			e.printStackTrace();
-//		}
-//	}
-
-	/**
-	 * Create the dialog.
-	 */
-	AddElementPopUp(JFrame parentFrame) {
-		super((java.awt.Frame) null, true);
-		this.setIconImage(Util.loadImage(this,"/Images/Dummy_House.png",30,30));
-		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
-		setBounds(100, 100, 400, 190);
-		setLocationRelativeTo(parentFrame);
-		getContentPane().setLayout(new BorderLayout());
-		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
-		getContentPane().add(contentPanel, BorderLayout.CENTER);
-		contentPanel.setLayout(null);
-		this.setTitle(Languages.getLanguage()[64]);
-
-		JLabel lblElementName = new JLabel(Languages.getLanguage()[65]);
-		lblElementName.setBounds(10, 11, 100, 14);
-		contentPanel.add(lblElementName);
-
-		JLabel lblProvidedEnergy = new JLabel(Languages.getLanguage()[66]);
-		lblProvidedEnergy.setBounds(10, 49, 120, 14);
-		contentPanel.add(lblProvidedEnergy);
-
-		JLabel lblAmount = new JLabel(Languages.getLanguage()[67]);
-		lblAmount.setBounds(10, 84, 100, 14);
-		contentPanel.add(lblAmount);
-
-		elementName = new JTextField();
-		elementName.addKeyListener(new KeyListener() {
-			@Override
-			public void keyPressed(KeyEvent arg0) {
-			}
-
-			@Override
-			public void keyReleased(KeyEvent e) {
-			}
-
-			@Override
-			public void keyTyped(KeyEvent e) {
-				elementName.setBackground(Color.WHITE);
-			}
-		});
-		elementName.setBounds(130, 8, 110, 20);
-		contentPanel.add(elementName);
-		elementName.setColumns(10);
-
-		providedEnergy = new JTextField();
-		providedEnergy.setBounds(130, 46, 110, 20);
-		contentPanel.add(providedEnergy);
-		providedEnergy.setColumns(10);
-		providedEnergy.setText("0");
-
-		amount = new JTextField();
-		amount.setBounds(130, 81, 110, 20);
-		contentPanel.add(amount);
-		amount.setColumns(10);
-		amount.setText("1");
-		{
-			JPanel buttonPane = new JPanel();
-			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
-			getContentPane().add(buttonPane, BorderLayout.SOUTH);
-			{
-				JButton okButton = new JButton("OK");
-                okButton.addActionListener(arg0 -> {
-                    boolean repeated = false;
-                    for (HolonElement e : ((HolonObject) tempCps).getElements()) {
-                        if (elementName.getText().equals(e.getEleName())) {
-                            repeated = true;
-                            break;
-                        }
-                    }
-                    if (elementName.getText().length() != 0 && !repeated) {
-                        try {
-                            float energy = Float.parseFloat(providedEnergy.getText());
-                            int elementAmount = Integer.parseInt(amount.getText());
-                            hl = new HolonElement(elementName.getText(), elementAmount, energy);
-
-                            dispose();
-                        } catch (NumberFormatException e) {
-                            JOptionPane.showMessageDialog(new JFrame(), Languages.getLanguage()[68]);
-                        }
-                    } else {
-                        // JOptionPane.showMessageDialog(new JFrame(),
-                        // "Please enter a Name");
-
-                        if (elementName.getText().length() == 0) {
-                            JLabel errorString = new JLabel(Languages.getLanguage()[69]);
-                            errorString.setBounds(240, 8, 100, 20);
-                            contentPanel.add(errorString);
-                        } else if (repeated) {
-                            JLabel errorString = new JLabel(Languages.getLanguage()[70]);
-                            errorString.setBounds(250, 8, 100, 20);
-                            contentPanel.add(errorString);
-                        }
-                        elementName.setBackground(new Color(255, 50, 50));
-                    }
-                });
-                okButton.setActionCommand("OK");
-				buttonPane.add(okButton);
-				getRootPane().setDefaultButton(okButton);
-			}
-			{
-				JButton cancelButton = new JButton(Languages.getLanguage()[71]);
-				cancelButton.setActionCommand("Cancel");
-				buttonPane.add(cancelButton);
-                cancelButton.addActionListener(e -> dispose());
-            }
-		}
-
-	}
-
-	/**
-	 * Sets the actual Cps.
-	 * 
-	 * @param cps
-	 *            actual Cps
-	 */
-    void setActualCps(AbstractCpsObject cps) {
-        this.tempCps = cps;
-	}
-
-	/**
-	 * Returns the created Element.
-	 * 
-	 * @return the Element
-	 */
-	public HolonElement getElement() {
-		return hl;
-	}
+package ui.view;
+
+import classes.AbstractCpsObject;
+import classes.HolonElement;
+import classes.HolonObject;
+
+import javax.swing.*;
+import javax.swing.border.EmptyBorder;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+/**
+ * popup for adding an Holon Element to a holon Object.
+ * 
+ * @author Gruppe14
+ */
+public class AddElementPopUp extends JDialog {
+
+	/**
+	 * Serial.
+	 */
+	private static final long serialVersionUID = 1L;
+	private final JPanel contentPanel = new JPanel();
+	private JTextField elementName;
+	private JTextField providedEnergy;
+	private JTextField amount;
+	private HolonElement hl;
+	private AbstractCpsObject tempCps;
+
+//	/**
+//	 * Launch the application.
+//	 *
+//	 * @param args
+//	 *            standard
+//	 */
+//	public static void main(String[] args) {
+//		try {
+//
+//			AddElementPopUp dialog = new AddElementPopUp();
+//			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+//			dialog.setVisible(true);
+//		} catch (Exception e) {
+//			e.printStackTrace();
+//		}
+//	}
+
+	/**
+	 * Create the dialog.
+	 */
+	AddElementPopUp(JFrame parentFrame) {
+		super((java.awt.Frame) null, true);
+		this.setIconImage(Util.loadImage(this,"/Images/Dummy_House.png",30,30));
+		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
+		setBounds(100, 100, 400, 190);
+		setLocationRelativeTo(parentFrame);
+		getContentPane().setLayout(new BorderLayout());
+		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
+		getContentPane().add(contentPanel, BorderLayout.CENTER);
+		contentPanel.setLayout(null);
+		this.setTitle(Languages.getLanguage()[64]);
+
+		JLabel lblElementName = new JLabel(Languages.getLanguage()[65]);
+		lblElementName.setBounds(10, 11, 100, 14);
+		contentPanel.add(lblElementName);
+
+		JLabel lblProvidedEnergy = new JLabel(Languages.getLanguage()[66]);
+		lblProvidedEnergy.setBounds(10, 49, 120, 14);
+		contentPanel.add(lblProvidedEnergy);
+
+		JLabel lblAmount = new JLabel(Languages.getLanguage()[67]);
+		lblAmount.setBounds(10, 84, 100, 14);
+		contentPanel.add(lblAmount);
+
+		elementName = new JTextField();
+		elementName.addKeyListener(new KeyListener() {
+			@Override
+			public void keyPressed(KeyEvent arg0) {
+			}
+
+			@Override
+			public void keyReleased(KeyEvent e) {
+			}
+
+			@Override
+			public void keyTyped(KeyEvent e) {
+				elementName.setBackground(Color.WHITE);
+			}
+		});
+		elementName.setBounds(130, 8, 110, 20);
+		contentPanel.add(elementName);
+		elementName.setColumns(10);
+
+		providedEnergy = new JTextField();
+		providedEnergy.setBounds(130, 46, 110, 20);
+		contentPanel.add(providedEnergy);
+		providedEnergy.setColumns(10);
+		providedEnergy.setText("0");
+
+		amount = new JTextField();
+		amount.setBounds(130, 81, 110, 20);
+		contentPanel.add(amount);
+		amount.setColumns(10);
+		amount.setText("1");
+		{
+			JPanel buttonPane = new JPanel();
+			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
+			getContentPane().add(buttonPane, BorderLayout.SOUTH);
+			{
+				JButton okButton = new JButton("OK");
+                okButton.addActionListener(arg0 -> {
+                    boolean repeated = false;
+                    for (HolonElement e : ((HolonObject) tempCps).getElements()) {
+                        if (elementName.getText().equals(e.getEleName())) {
+                            repeated = true;
+                            break;
+                        }
+                    }
+                    if (elementName.getText().length() != 0 && !repeated) {
+                        try {
+                            float energy = Float.parseFloat(providedEnergy.getText());
+                            int elementAmount = Integer.parseInt(amount.getText());
+                            hl = new HolonElement(elementName.getText(), elementAmount, energy);
+
+                            dispose();
+                        } catch (NumberFormatException e) {
+                            JOptionPane.showMessageDialog(new JFrame(), Languages.getLanguage()[68]);
+                        }
+                    } else {
+                        // JOptionPane.showMessageDialog(new JFrame(),
+                        // "Please enter a Name");
+
+                        if (elementName.getText().length() == 0) {
+                            JLabel errorString = new JLabel(Languages.getLanguage()[69]);
+                            errorString.setBounds(240, 8, 100, 20);
+                            contentPanel.add(errorString);
+                        } else if (repeated) {
+                            JLabel errorString = new JLabel(Languages.getLanguage()[70]);
+                            errorString.setBounds(250, 8, 100, 20);
+                            contentPanel.add(errorString);
+                        }
+                        elementName.setBackground(new Color(255, 50, 50));
+                    }
+                });
+                okButton.setActionCommand("OK");
+				buttonPane.add(okButton);
+				getRootPane().setDefaultButton(okButton);
+			}
+			{
+				JButton cancelButton = new JButton(Languages.getLanguage()[71]);
+				cancelButton.setActionCommand("Cancel");
+				buttonPane.add(cancelButton);
+                cancelButton.addActionListener(e -> dispose());
+            }
+		}
+
+	}
+
+	/**
+	 * Sets the actual Cps.
+	 * 
+	 * @param cps
+	 *            actual Cps
+	 */
+    void setActualCps(AbstractCpsObject cps) {
+        this.tempCps = cps;
+	}
+
+	/**
+	 * Returns the created Element.
+	 * 
+	 * @return the Element
+	 */
+	public HolonElement getElement() {
+		return hl;
+	}
 }

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

@@ -80,5 +80,5 @@ public class Util {
 			}
 			return null;
 		}
-	}
+	}
 }