|
@@ -27,12 +27,14 @@ public class LoadController {
|
|
|
private CategoryController cgC;
|
|
|
private CanvasController cvsC;
|
|
|
private ObjectController objC;
|
|
|
+ private SearchController sC;
|
|
|
|
|
|
- public LoadController(Model model, CategoryController cg, CanvasController cvs, ObjectController obj) {
|
|
|
+ public LoadController(Model model, CategoryController cg, CanvasController cvs, ObjectController obj, SearchController sC) {
|
|
|
this.MODEL = model;
|
|
|
this.cgC = cg;
|
|
|
this.cvsC = cvs;
|
|
|
this.objC = obj;
|
|
|
+ this.sC = sC;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -118,7 +120,7 @@ public class LoadController {
|
|
|
Iterator<Object> i = arr.iterator();
|
|
|
|
|
|
while (i.hasNext()) {
|
|
|
- cgC.addNewCategory(i.next().toString());
|
|
|
+ cgC.addNewCategory(next(i));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -130,16 +132,14 @@ public class LoadController {
|
|
|
public void readCategoryObject(JSONArray arr) {
|
|
|
Iterator<Object> i = arr.iterator();
|
|
|
|
|
|
- String type = i.next().toString();
|
|
|
+ String type = next(i);
|
|
|
|
|
|
if (type.equals("HolonObject")) {
|
|
|
- cgC.addNewHolonObject(cgC.searchCatNode(i.next().toString()), i.next().toString(), new ArrayList<>(),
|
|
|
- i.next().toString());
|
|
|
+ cgC.addNewHolonObject(sC.searchCategory(next(i)), next(i), new ArrayList<>(), next(i));
|
|
|
} else if (type.equals("HolonTransformer")) {
|
|
|
- cgC.addNewHolonTransformer(cgC.searchCatNode(i.next().toString()), i.next().toString(),
|
|
|
- i.next().toString());
|
|
|
+ cgC.addNewHolonTransformer(sC.searchCategory(next(i)), next(i), next(i));
|
|
|
} else if (type.equals("HolonSwitch")) {
|
|
|
- cgC.addNewHolonSwitch(cgC.searchCatNode(i.next().toString()), i.next().toString(), i.next().toString());
|
|
|
+ cgC.addNewHolonSwitch(sC.searchCategory(next(i)), next(i), next(i));
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -153,22 +153,22 @@ public class LoadController {
|
|
|
Iterator<Object> i = arr.iterator();
|
|
|
CpsObject cps = null;
|
|
|
|
|
|
- String type = i.next().toString();
|
|
|
+ String type = next(i);
|
|
|
|
|
|
if (type.equals("HolonObject")) {
|
|
|
- cps = new HolonObject(i.next().toString());
|
|
|
+ cps = new HolonObject(next(i));
|
|
|
} else if (type.equals("HolonTransformer")) {
|
|
|
- cps = new HolonTransformer(i.next().toString());
|
|
|
+ cps = new HolonTransformer(next(i));
|
|
|
} else if (type.equals("HolonSwitch")) {
|
|
|
- cps = new HolonSwitch(i.next().toString());
|
|
|
+ cps = new HolonSwitch(next(i));
|
|
|
} else if (type.equals("CpsNode")) {
|
|
|
- cps = new CpsNode(i.next().toString());
|
|
|
+ cps = new CpsNode(next(i));
|
|
|
}
|
|
|
|
|
|
- cps.setName(i.next().toString());
|
|
|
- cps.setID(Integer.parseInt(i.next().toString()));
|
|
|
- cps.setImage(i.next().toString());
|
|
|
- cps.setPosition(Integer.parseInt(i.next().toString()), Integer.parseInt(i.next().toString()));
|
|
|
+ cps.setName(next(i));
|
|
|
+ cps.setID(Integer.parseInt(next(i)));
|
|
|
+ cps.setImage(next(i));
|
|
|
+ cps.setPosition(Integer.parseInt(next(i)), Integer.parseInt(next(i)));
|
|
|
|
|
|
cvsC.addObjectIntoCanvas(cps);
|
|
|
}
|
|
@@ -181,19 +181,16 @@ public class LoadController {
|
|
|
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().);
|
|
|
+ String sav = next(i);
|
|
|
+ String obj = next(i);
|
|
|
+
|
|
|
+ HolonElement ele = new HolonElement(next(i), Integer.parseInt(next(i)), Float.parseFloat(next(i)));
|
|
|
|
|
|
if (sav.equals("Canvas")) {
|
|
|
- objC.addNewElementIntoCanvasObject(Integer.parseInt(i.next().toString()), i.next().toString(),
|
|
|
- Integer.parseInt(i.next().toString()), Float.parseFloat(i.next().toString()));
|
|
|
+ ele.setActive(compare(Integer.parseInt(next(i))));
|
|
|
+ objC.addElementIntoCanvasObject((HolonObject) sC.searchByID(Integer.parseInt(obj)), ele);
|
|
|
} else
|
|
|
- objC.addNewElementIntoCategoryObject(sav, i.next().toString(), i.next().toString(),
|
|
|
- Integer.parseInt(i.next().toString()), Float.parseFloat(i.next().toString()));
|
|
|
+ objC.addElementIntoCategoryObject(sav, obj, ele);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -203,10 +200,10 @@ public class LoadController {
|
|
|
public void readEdge(JSONArray arr) {
|
|
|
Iterator<Object> i = arr.iterator();
|
|
|
|
|
|
- CpsEdge edge = new CpsEdge(objC.searchByID(Integer.parseInt(i.next().toString())),
|
|
|
- objC.searchByID(Integer.parseInt(i.next().toString())));
|
|
|
- edge.setCapacity(Float.parseFloat(i.next().toString()));
|
|
|
- edge.setFlow(Float.parseFloat(i.next().toString()));
|
|
|
+ CpsEdge edge = new CpsEdge(sC.searchByID(Integer.parseInt(next(i))),
|
|
|
+ sC.searchByID(Integer.parseInt(next(i))));
|
|
|
+ edge.setCapacity(Float.parseFloat(next(i)));
|
|
|
+ edge.setFlow(Float.parseFloat(next(i)));
|
|
|
|
|
|
cvsC.addEdgeOnCanvas(edge);
|
|
|
}
|
|
@@ -214,24 +211,33 @@ public class LoadController {
|
|
|
public void readElementGraph(JSONArray arr) {
|
|
|
Iterator<Object> i = arr.iterator();
|
|
|
|
|
|
- String sav = i.next().toString();
|
|
|
+ String sav = next(i);
|
|
|
HolonElement ele;
|
|
|
|
|
|
if (sav.equals("Canvas")) {
|
|
|
- ele = objC.searchHolonElement((HolonObject) objC.searchByID(Integer.parseInt(i.next().toString())),
|
|
|
- i.next().toString());
|
|
|
+ ele = sC.searchHolonElement((HolonObject) sC.searchByID(Integer.parseInt(next(i))), next(i));
|
|
|
while (i.hasNext())
|
|
|
- ele.getGraphPoints()
|
|
|
- .add(new Point(Integer.parseInt(i.next().toString()), Integer.parseInt(i.next().toString())));
|
|
|
- System.out.println(ele.getGraphPoints().size());
|
|
|
+ ele.getGraphPoints().add(new Point(Integer.parseInt(next(i)), Integer.parseInt(next(i))));
|
|
|
} else {
|
|
|
- ele = objC.searchHolonElement(objC.searchHolonObject(i.next().toString(),
|
|
|
- objC.searchCategory(sav, MODEL.getCategories()).getObjects()), i.next().toString());
|
|
|
+ ele = sC.searchHolonElement(sC.searchHolonObject(next(i), objC.searchCategory(sav).getObjects()),
|
|
|
+ next(i));
|
|
|
while (i.hasNext())
|
|
|
- ele.getGraphPoints()
|
|
|
- .add(new Point(Integer.parseInt(i.next().toString()), Integer.parseInt(i.next().toString())));
|
|
|
+ ele.getGraphPoints().add(new Point(Integer.parseInt(next(i)), Integer.parseInt(next(i))));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param i
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String next(Iterator<Object> i) {
|
|
|
+ return i.next().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean compare(int x) {
|
|
|
+ return x == 1 ? true : false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|