Browse Source

Merge branch 'Ohne_Drag_and_Drop' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons into Ohne_Drag_and_Drop

Edgardo Palza 8 years ago
parent
commit
b10797c027

+ 1 - 0
.gradle/2.14/taskArtifacts/cache.properties

@@ -0,0 +1 @@
+#Tue Jul 05 09:50:14 CEST 2016

BIN
.gradle/2.14/taskArtifacts/cache.properties.lock


BIN
.gradle/2.14/taskArtifacts/fileHashes.bin


BIN
.gradle/2.14/taskArtifacts/fileSnapshots.bin


BIN
.gradle/2.14/taskArtifacts/fileSnapshotsToTreeSnapshotsIndex.bin


BIN
.gradle/2.14/taskArtifacts/taskArtifacts.bin


BIN
.gradle/2.14/taskArtifacts/treeSnapshotUsage.bin


BIN
.gradle/2.14/taskArtifacts/treeSnapshots.bin


+ 2 - 2
src/ui/controller/Control.java

@@ -93,8 +93,8 @@ public class Control {
 	}
 
 	/* Operations for Objects and Elements */
-	public void addElementCanvasObject(String objName, String eleName, int amount, float energy) {
-		objectController.addNewElementIntoCanvasObject(objName, eleName, amount, energy);
+	public void addElementCanvasObject(int ID, String eleName, int amount, float energy) {
+		objectController.addNewElementIntoCanvasObject(ID, eleName, amount, energy);
 	}
 
 	public void addElementCategoryObject(String catName, String objName, String eleName, int amount, float energy) {

+ 35 - 17
src/ui/controller/LoadStoreController.java

@@ -1,10 +1,10 @@
 package ui.controller;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.ArrayList;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import classes.Category;
@@ -12,43 +12,60 @@ import classes.CpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import ui.model.Model;
+
 public class LoadStoreController {
 	private Model MODEL;
+
 	public LoadStoreController(Model model) {
 		this.MODEL = model;
 	}
+
+	
+	
 	public void writeJSONFile() throws IOException {
-		JSONObject jsonObj = new JSONObject();
-		writeCategory(jsonObj);
-		writeCategoryObjects(jsonObj);
-		writeCategoryElements(jsonObj);
-		FileWriter file = new FileWriter("C:/Users/krabs/Desktop/Tesst.json");
-		file.write(jsonObj.toJSONString());
-		file.flush();
-		file.close();
+
+		JSONObject json = new JSONObject();
+
+		
+		writeCategory(json);
+		writeCategoryObjects(json);
+		writeCategoryElements(json);
+
+		FileWriter writer = new FileWriter("//Users//zheng//Desktop//Tesst.json");
+		writer.flush();
+		writer.close();
 	}
-	public void writeCategory(JSONObject jsonObj) throws IOException {
+
+	public void writeCategory(JSONObject json) throws IOException {
 		JSONArray arr = new JSONArray();
+		
 		for (Category cat : MODEL.getCategories())
 			arr.add(cat.getName());
-		jsonObj.put("Category", arr);
+		json.put("Category", arr);
 	}
-	public void writeCategoryObjects(JSONObject jsonObj) {
-		int i = 1;
+
+	public void writeCategoryObjects(JSONObject json) throws IOException {
+		
 		JSONArray arr = new JSONArray();
+		int i = 1;
+		
 		for (Category cats : MODEL.getCategories())
 			for (CpsObject cps : cats.getObjects()) {
 				arr.add(cps.getStored());
 				arr.add(cps.getObjName());
 				arr.add(cps.getName());
 				arr.add(cps.getImage());
-				jsonObj.put("CategoryObject." + i++, arr);
+				json.put("CategoryObject." + i++, arr);
 				arr = new JSONArray();
 			}
 	}
-	public void writeCategoryElements(JSONObject jsonObj) {
-		int i = 1;
+
+	public void writeCategoryElements(JSONObject json) throws IOException {
+		
+
 		JSONArray arr = new JSONArray();
+		int i = 1;
+		
 		for (Category cats : MODEL.getCategories())
 			for (CpsObject cps : cats.getObjects())
 				if (cps instanceof HolonObject)
@@ -57,10 +74,11 @@ public class LoadStoreController {
 						arr.add(ele.getEleName());
 						arr.add(ele.getAmount());
 						arr.add(ele.getEnergy());
-						jsonObj.put("CategoryElement." + i++, arr);
+						json.put("CategoryElement." + i++, arr);
 						arr = new JSONArray();
 					}
 	}
+
 	public void readFromJSON(File jsonFile) throws IOException {
 		String line;
 		BufferedReader reader = new BufferedReader(new FileReader("textfile"));

+ 5 - 4
src/ui/controller/ObjectController.java

@@ -42,8 +42,8 @@ public class ObjectController {
 	 * @param element
 	 * @param type
 	 */
-	public void addElementIntoCanvasObject(String object, HolonElement element) {
-		addElement(searchHolonObject(object, MODEL.getObjectsOnCanvas()), element);
+	public void addElementIntoCanvasObject(HolonObject object, HolonElement element) {
+		addElement(object, element);
 	}
 
 	/**
@@ -55,8 +55,8 @@ public class ObjectController {
 	 * @param energy
 	 * @param type
 	 */
-	public void addNewElementIntoCanvasObject(String object, String eleName, int amount, float energy) {
-		addElementIntoCanvasObject(object, new HolonElement(eleName, energy, amount));
+	public void addNewElementIntoCanvasObject(int id, String eleName, int amount, float energy) {
+		addElementIntoCanvasObject((HolonObject) searchByID(id), new HolonElement(eleName, energy, amount));
 	}
 
 	/**
@@ -75,6 +75,7 @@ public class ObjectController {
 				break;
 			}
 		}
+		element.setStored(object);
 		addElement(searchHolonObject(object, cat.getObjects()), element);
 	}
 

+ 4 - 0
src/ui/view/AboutUsPopUp.java

@@ -2,7 +2,9 @@ package ui.view;
 
 import java.awt.BorderLayout;
 import java.awt.Font;
+import java.awt.Image;
 
+import javax.swing.ImageIcon;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
@@ -20,6 +22,8 @@ public class AboutUsPopUp extends JFrame {
 
 	public AboutUsPopUp() {
 		super("About Us");
+		this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
+				.getScaledInstance(30, 30, Image.SCALE_SMOOTH));
 		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
 		setBounds(100, 100, 500, 800);
 		getContentPane().setLayout(new BorderLayout());

+ 4 - 0
src/ui/view/AddElementPopUp.java

@@ -3,6 +3,7 @@ package ui.view;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.FlowLayout;
+import java.awt.Image;
 import java.util.ArrayList;
 
 import javax.swing.JButton;
@@ -15,6 +16,7 @@ import javax.swing.JOptionPane;
 import javax.swing.JTextField;
 import javax.swing.JComboBox;
 import javax.swing.DefaultComboBoxModel;
+import javax.swing.ImageIcon;
 
 import classes.HolonElement;
 
@@ -49,6 +51,8 @@ public class AddElementPopUp extends JDialog {
 	 */
 	public AddElementPopUp() {
 		super((java.awt.Frame) null, true);
+		this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
+				.getScaledInstance(30, 30, Image.SCALE_SMOOTH));
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		setBounds(100, 100, 400, 190);
 		getContentPane().setLayout(new BorderLayout());

+ 2 - 0
src/ui/view/AddObjectPopUp.java

@@ -70,6 +70,8 @@ public class AddObjectPopUp extends JDialog {
 	 * Create the dialog.
 	 */
 	public AddObjectPopUp() {
+		this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
+				.getScaledInstance(30, 30, Image.SCALE_SMOOTH));
 		setBounds(100, 100, 450, 342);
 		getContentPane().setLayout(new BorderLayout());
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

+ 7 - 0
src/ui/view/GUI.java

@@ -9,6 +9,7 @@ import javax.swing.JMenu;
 import javax.swing.JMenuItem;
 import javax.swing.JOptionPane;
 import javax.swing.JTree;
+import javax.swing.border.LineBorder;
 import javax.swing.BoxLayout;
 import javax.swing.JSplitPane;
 import javax.swing.JScrollPane;
@@ -168,6 +169,7 @@ public class GUI implements CategoryListener {
 		this.testgraph = new UnitGraph(model, control); // for testing, remove
 
 		timePanel = new TimePanel(model, controller);
+		timePanel.setBorder(null);
 
 		// later
 		control.initListener(this);
@@ -230,6 +232,7 @@ public class GUI implements CategoryListener {
 		canvas.setBackground(Color.WHITE);
 		canvas.setPreferredSize(new Dimension(10000, 10000));
 		JScrollPane canvasSP = new JScrollPane(canvas);
+		canvasSP.setBorder(null);
 
 		tabbedPane.addTab("Modeling", new ImageIcon(new ImageIcon(this.getClass().getResource("/Images/home.png"))
 				.getImage().getScaledInstance(30, 30, Image.SCALE_SMOOTH)), canvasSP, "Model a CPS");
@@ -249,6 +252,7 @@ public class GUI implements CategoryListener {
 		// Set up of the HolonElements section
 		Object[] columnNames = { "Device", "Energy", "Quantity" };
 		tableModelHolonElement.setColumnIdentifiers(columnNames);
+		tableHolonElement.setBorder(null);
 		tableHolonElement.setModel(tableModelHolonElement);
 		tableHolonElement.setFillsViewportHeight(true);
 		tableHolonElement.setCellSelectionEnabled(true);
@@ -704,6 +708,9 @@ public class GUI implements CategoryListener {
 		splitPane_1.setBorder(null);
 		split_HolonEl_Pro.setBorder(null);
 		split_Graph_HolonEl.setBorder(null);
+		scrollPane_2.setBorder(null);
+		panel_HolonEl.setBorder(null);
+		tableHolonElementScrollPane.setBorder(null);
 
 		frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
 	}

+ 3 - 1
src/ui/view/MyCanvas.java

@@ -343,7 +343,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
 					controller.removeEdgesOnCanvas(e);
 					tempCps.getConnections().remove(e);
 					cps.getConnections().remove(e);
-					// Node ohne Edge
+					// Node ohne Edge?
 					if (e.getA().getClass() == CpsNode.class && e.getA().getConnections().isEmpty()) {
 						tempCps = e.getA();
 						deleteNode = true;
@@ -361,6 +361,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
 				}
 			}
 		}
+		//Auf eine Edge gezoggen?
 		if (onEdge) {
 			CpsEdge p = mousePositionOnEdge(x, y);
 			if (p != null) {
@@ -415,6 +416,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
 			System.out.println("node ID: " + n.getID());
 		}
 		
+		//Wenn ein Node ohne Connections da ist
 		if(deleteNode){
 			controller.deleteObjectOnCanvas(tempCps);
 			controller.deleteObjectOnCanvas(tempCPS);