|
@@ -33,20 +33,23 @@ public class StoreController {
|
|
*
|
|
*
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public void writeJSONFile(String path) throws IOException {
|
|
|
|
|
|
+ public void writeSaveFile(String path) throws IOException {
|
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
|
json.put("ID", idCounter.getCounter());
|
|
json.put("ID", idCounter.getCounter());
|
|
writeCategory(json);
|
|
writeCategory(json);
|
|
- writeObjects(json);
|
|
|
|
- writeElements(json);
|
|
|
|
|
|
+ writeCategoryObjects(json);
|
|
|
|
+ writeCanvasObjects(json);
|
|
|
|
+ writeCategoryElements(json);
|
|
|
|
+ writeCanvasElements(json);
|
|
writeEdges(json);
|
|
writeEdges(json);
|
|
writeElementGraph(json);
|
|
writeElementGraph(json);
|
|
|
|
|
|
FileWriter writer = new FileWriter(path);
|
|
FileWriter writer = new FileWriter(path);
|
|
- writer.write(json.toJSONString());getClass();
|
|
|
|
-
|
|
|
|
|
|
+ writer.write(json.toJSONString());
|
|
|
|
+ getClass();
|
|
|
|
+
|
|
writer.flush();
|
|
writer.flush();
|
|
writer.close();
|
|
writer.close();
|
|
}
|
|
}
|
|
@@ -71,7 +74,7 @@ public class StoreController {
|
|
*
|
|
*
|
|
* @param json
|
|
* @param json
|
|
*/
|
|
*/
|
|
- public void writeObjects(JSONObject json) {
|
|
|
|
|
|
+ public void writeCategoryObjects(JSONObject json) {
|
|
|
|
|
|
JSONArray arr = new JSONArray();
|
|
JSONArray arr = new JSONArray();
|
|
int i = 1;
|
|
int i = 1;
|
|
@@ -85,8 +88,12 @@ public class StoreController {
|
|
json.put("CGO" + i++, arr);
|
|
json.put("CGO" + i++, arr);
|
|
arr = new JSONArray();
|
|
arr = new JSONArray();
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- i = 1;
|
|
|
|
|
|
+ public void writeCanvasObjects(JSONObject json) {
|
|
|
|
+
|
|
|
|
+ JSONArray arr = new JSONArray();
|
|
|
|
+ int i = 1;
|
|
for (CpsObject cps : MODEL.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : MODEL.getObjectsOnCanvas()) {
|
|
arr.add(getObjectType(cps));
|
|
arr.add(getObjectType(cps));
|
|
arr.add(cps.getObjName());
|
|
arr.add(cps.getObjName());
|
|
@@ -97,8 +104,6 @@ public class StoreController {
|
|
arr.add(cps.getPosition().y);
|
|
arr.add(cps.getPosition().y);
|
|
json.put("CVSO" + i++, arr);
|
|
json.put("CVSO" + i++, arr);
|
|
arr = new JSONArray();
|
|
arr = new JSONArray();
|
|
- ;
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -107,7 +112,7 @@ public class StoreController {
|
|
*
|
|
*
|
|
* @param json
|
|
* @param json
|
|
*/
|
|
*/
|
|
- public void writeElements(JSONObject json) {
|
|
|
|
|
|
+ public void writeCategoryElements(JSONObject json) {
|
|
|
|
|
|
JSONArray arr = new JSONArray();
|
|
JSONArray arr = new JSONArray();
|
|
int i = 1;
|
|
int i = 1;
|
|
@@ -125,12 +130,18 @@ public class StoreController {
|
|
arr = new JSONArray();
|
|
arr = new JSONArray();
|
|
}
|
|
}
|
|
|
|
|
|
- i = 1;
|
|
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void writeCanvasElements(JSONObject json) {
|
|
|
|
+
|
|
|
|
+ JSONArray arr = new JSONArray();
|
|
|
|
+ int i = 1;
|
|
for (CpsObject cps : MODEL.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : MODEL.getObjectsOnCanvas()) {
|
|
if (cps instanceof HolonObject)
|
|
if (cps instanceof HolonObject)
|
|
for (HolonElement ele : ((HolonObject) cps).getElements()) {
|
|
for (HolonElement ele : ((HolonObject) cps).getElements()) {
|
|
arr.add(ele.getSav());
|
|
arr.add(ele.getSav());
|
|
- arr.add(cps.getID());
|
|
|
|
|
|
+ arr.add(ele.getObj());
|
|
arr.add(ele.getEleName());
|
|
arr.add(ele.getEleName());
|
|
arr.add(ele.getAmount());
|
|
arr.add(ele.getAmount());
|
|
arr.add(ele.getEnergy());
|
|
arr.add(ele.getEnergy());
|