Teh-Hai Julian Zheng 8 tahun lalu
induk
melakukan
c6d3974017

+ 1 - 1
src/classes/HolonElement.java

@@ -31,7 +31,7 @@ public class HolonElement {
 	//Points on the UnitGraph
 	LinkedList<Point> graphPoints = new LinkedList<>();
 
-	public HolonElement(String eleName, float energy, int amount) {
+	public HolonElement(String eleName, int amount, float energy) {
 		setEleName(eleName);
 		setAmount(amount);
 		setEnergy(energy);

+ 38 - 1
src/ui/controller/LoadController.java

@@ -37,6 +37,7 @@ public class LoadController {
 	}
 
 	/**
+	 * Reads the the JSON File and load the state into the Model
 	 * 
 	 * @param path
 	 * @throws IOException
@@ -70,7 +71,7 @@ public class LoadController {
 				else
 					idCounter.setCounter(Integer.parseInt(json.get(key.toString()).toString()));
 			}
-			System.out.println(gp.get(0));
+
 			dispatch(obj, json);
 			dispatch(ele, json);
 			dispatch(edge, json);
@@ -83,6 +84,12 @@ public class LoadController {
 
 	}
 
+	/**
+	 * dispatch the Keys into the right processing
+	 * 
+	 * @param input
+	 * @param json
+	 */
 	public void dispatch(ArrayList<String> input, JSONObject json) {
 
 		for (String str : input) {
@@ -101,6 +108,11 @@ public class LoadController {
 
 	}
 
+	/**
+	 * Read all Categories from the JSON file
+	 * 
+	 * @param arr
+	 */
 	public void readCategory(JSONArray arr) {
 
 		Iterator<Object> i = arr.iterator();
@@ -110,6 +122,11 @@ public class LoadController {
 		}
 	}
 
+	/**
+	 * Read all Objects in Category from the JSON File
+	 * 
+	 * @param arr
+	 */
 	public void readCategoryObject(JSONArray arr) {
 		Iterator<Object> i = arr.iterator();
 
@@ -127,6 +144,11 @@ public class LoadController {
 
 	}
 
+	/**
+	 * Read all Objects in Canvas from JSON File
+	 * 
+	 * @param arr
+	 */
 	public void readCanvasObject(JSONArray arr) {
 		Iterator<Object> i = arr.iterator();
 		CpsObject cps = null;
@@ -151,10 +173,21 @@ public class LoadController {
 		cvsC.addObjectIntoCanvas(cps);
 	}
 
+	/**
+	 * Read all Elements in Category and Canvas from JSON File
+	 * 
+	 * @param arr
+	 */
 	public void readElement(JSONArray arr) {
 		Iterator<Object> i = arr.iterator();
 
 		String sav = i.next().toString();
+//		int id = Integer.parseInt(i.next().toString());
+//
+//		HolonElement ele = new HolonElement(i.next().toString(), Integer.parseInt(i.next().toString()),
+//				Float.parseFloat(i.next().toString()));
+//		ele.setActive(i.next().);
+
 		if (sav.equals("Canvas")) {
 			objC.addNewElementIntoCanvasObject(Integer.parseInt(i.next().toString()), i.next().toString(),
 					Integer.parseInt(i.next().toString()), Float.parseFloat(i.next().toString()));
@@ -163,6 +196,10 @@ public class LoadController {
 					Integer.parseInt(i.next().toString()), Float.parseFloat(i.next().toString()));
 	}
 
+	/**
+	 * 
+	 * @param arr
+	 */
 	public void readEdge(JSONArray arr) {
 		Iterator<Object> i = arr.iterator();
 

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

@@ -58,7 +58,7 @@ public class ObjectController {
 	 * @param type
 	 */
 	public void addNewElementIntoCanvasObject(int id, String eleName, int amount, float energy) {
-		addElementIntoCanvasObject((HolonObject) searchByID(id), new HolonElement(eleName, energy, amount));
+		addElementIntoCanvasObject((HolonObject) searchByID(id), new HolonElement(eleName, amount, energy));
 	}
 
 	/**
@@ -95,7 +95,7 @@ public class ObjectController {
 	 */
 	public void addNewElementIntoCategoryObject(String category, String object, String eleName, int amount,
 			float energy) {
-		addElementIntoCategoryObject(category, object, new HolonElement(eleName, energy, amount));
+		addElementIntoCategoryObject(category, object, new HolonElement(eleName, amount, energy));
 	}
 
 	/**

+ 1 - 0
src/ui/controller/StoreController.java

@@ -132,6 +132,7 @@ public class StoreController {
 					arr.add(ele.getEleName());
 					arr.add(ele.getAmount());
 					arr.add(ele.getEnergy());
+					arr.add(ele.getActive());
 					json.put("CVSE" + i++, arr);
 					arr = new JSONArray();
 				}

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

@@ -139,7 +139,7 @@ public class AddElementPopUp extends JDialog {
 								if (sign.getSelectedItem().toString().equals("-")) {
 									energy = energy * -1;
 								}
-								hl = new HolonElement(elementName.getText().toString(), energy, elementAmount);
+								hl = new HolonElement(elementName.getText().toString(), elementAmount, energy);
 								dispose();
 							} catch (NumberFormatException e) {
 								JOptionPane.showMessageDialog(new JFrame(),