|
@@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|
import Interfaces.CategoryListener;
|
|
import Interfaces.CategoryListener;
|
|
import classes.Category;
|
|
import classes.Category;
|
|
import classes.CpsEdge;
|
|
import classes.CpsEdge;
|
|
|
|
+import classes.CpsNode;
|
|
import classes.CpsObject;
|
|
import classes.CpsObject;
|
|
import classes.HolonElement;
|
|
import classes.HolonElement;
|
|
import classes.HolonObject;
|
|
import classes.HolonObject;
|
|
@@ -30,7 +31,7 @@ public class Control {
|
|
private final AutoSaveController autoSaveController;
|
|
private final AutoSaveController autoSaveController;
|
|
private SimulationManager simulationManager;
|
|
private SimulationManager simulationManager;
|
|
private String autoPath = "";
|
|
private String autoPath = "";
|
|
-
|
|
|
|
|
|
+
|
|
public Control(Model model) {
|
|
public Control(Model model) {
|
|
this.MODEL = model;
|
|
this.MODEL = model;
|
|
|
|
|
|
@@ -72,12 +73,6 @@ public class Control {
|
|
|
|
|
|
public void addObject(Category cat, String obj, ArrayList<HolonElement> ele, String img) {
|
|
public void addObject(Category cat, String obj, ArrayList<HolonElement> ele, String img) {
|
|
categoryController.addNewHolonObject(cat, obj, ele, img);
|
|
categoryController.addNewHolonObject(cat, obj, ele, img);
|
|
- try {
|
|
|
|
- autoSave();
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- // TODO Auto-generated catch block
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public void addTransformer(Category cat, String obj) {
|
|
public void addTransformer(Category cat, String obj) {
|
|
@@ -99,19 +94,18 @@ public class Control {
|
|
public void delObjectCategory(String cat, String obj) {
|
|
public void delObjectCategory(String cat, String obj) {
|
|
categoryController.deleteObject(cat, obj);
|
|
categoryController.deleteObject(cat, obj);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
public void deleteSelectedObject(CpsObject obj) {
|
|
public void deleteSelectedObject(CpsObject obj) {
|
|
objectController.deleteSelectedObject(obj);
|
|
objectController.deleteSelectedObject(obj);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void addSelectedObject(CpsObject obj) {
|
|
public void addSelectedObject(CpsObject obj) {
|
|
objectController.addSelectedObject(obj);
|
|
objectController.addSelectedObject(obj);
|
|
}
|
|
}
|
|
|
|
|
|
/* Operations for Canvas */
|
|
/* Operations for Canvas */
|
|
|
|
|
|
- public void AddEdgeOnCanvas(CpsEdge edge){
|
|
|
|
|
|
+ public void AddEdgeOnCanvas(CpsEdge edge) {
|
|
canvasController.addEdgeOnCanvas(edge);
|
|
canvasController.addEdgeOnCanvas(edge);
|
|
try {
|
|
try {
|
|
autoSave();
|
|
autoSave();
|
|
@@ -137,11 +131,13 @@ public class Control {
|
|
|
|
|
|
public void addObjectCanvas(CpsObject object) {
|
|
public void addObjectCanvas(CpsObject object) {
|
|
canvasController.addNewObject(object);
|
|
canvasController.addNewObject(object);
|
|
- try {
|
|
|
|
- autoSave();
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- // TODO Auto-generated catch block
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ if (!(object instanceof CpsNode)) {
|
|
|
|
+ try {
|
|
|
|
+ autoSave();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -168,11 +164,11 @@ public class Control {
|
|
objectController.addNewElementIntoCategoryObject(catName, objName, eleName, amount, energy);
|
|
objectController.addNewElementIntoCategoryObject(catName, objName, eleName, amount, energy);
|
|
}
|
|
}
|
|
|
|
|
|
- public void deleteElementCanvas(int id, String element){
|
|
|
|
|
|
+ public void deleteElementCanvas(int id, String element) {
|
|
objectController.deleteElementInCanvas(id, element);
|
|
objectController.deleteElementInCanvas(id, element);
|
|
}
|
|
}
|
|
|
|
|
|
- public void deleteElementCanvas(HolonObject obj, HolonElement ele){
|
|
|
|
|
|
+ public void deleteElementCanvas(HolonObject obj, HolonElement ele) {
|
|
objectController.deleteElement(obj, ele);
|
|
objectController.deleteElement(obj, ele);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -206,45 +202,36 @@ public class Control {
|
|
public void initListener(CategoryListener catLis) {
|
|
public void initListener(CategoryListener catLis) {
|
|
categoryController.addCategoryListener(catLis);
|
|
categoryController.addCategoryListener(catLis);
|
|
}
|
|
}
|
|
-
|
|
|
|
- public void calculateStateForTimeStep(int x){
|
|
|
|
|
|
+
|
|
|
|
+ public void calculateStateForTimeStep(int x) {
|
|
simulationManager.reset();
|
|
simulationManager.reset();
|
|
simulationManager.calculateStateForTimeStep(x);
|
|
simulationManager.calculateStateForTimeStep(x);
|
|
}
|
|
}
|
|
-
|
|
|
|
- public void setCanvas(MyCanvas can){
|
|
|
|
|
|
+
|
|
|
|
+ public void setCanvas(MyCanvas can) {
|
|
simulationManager.setCanvas(can);
|
|
simulationManager.setCanvas(can);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
private void autoSave() throws IOException {
|
|
private void autoSave() throws IOException {
|
|
autoSaveController.increaseAutoSaveNr();
|
|
autoSaveController.increaseAutoSaveNr();
|
|
- storeController.writeSaveFile(autoPath+autoSaveController.getAutoSaveNr());
|
|
|
|
|
|
+ storeController.writeSaveFile(autoPath + autoSaveController.getAutoSaveNr());
|
|
}
|
|
}
|
|
-
|
|
|
|
- public String getUndoSave(){
|
|
|
|
|
|
+
|
|
|
|
+ public String getUndoSave() {
|
|
autoSaveController.decreaseAutoSaveNr();
|
|
autoSaveController.decreaseAutoSaveNr();
|
|
- if(!new File(autoPath + (autoSaveController.getAutoSaveNr())).exists()){
|
|
|
|
|
|
+ if (!new File(autoPath + (autoSaveController.getAutoSaveNr())).exists()) {
|
|
autoSaveController.increaseAutoSaveNr();
|
|
autoSaveController.increaseAutoSaveNr();
|
|
}
|
|
}
|
|
- return autoPath+(autoSaveController.getAutoSaveNr());
|
|
|
|
|
|
+ return autoPath + (autoSaveController.getAutoSaveNr());
|
|
}
|
|
}
|
|
-
|
|
|
|
- public String getRedoSave(){
|
|
|
|
|
|
+
|
|
|
|
+ public String getRedoSave() {
|
|
autoSaveController.increaseAutoSaveNr();
|
|
autoSaveController.increaseAutoSaveNr();
|
|
- if(!new File(autoPath+(autoSaveController.getAutoSaveNr())).exists()){
|
|
|
|
|
|
+ if (!new File(autoPath + (autoSaveController.getAutoSaveNr())).exists()) {
|
|
autoSaveController.decreaseAutoSaveNr();
|
|
autoSaveController.decreaseAutoSaveNr();
|
|
}
|
|
}
|
|
- return autoPath+(autoSaveController.getAutoSaveNr());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// public void increaseAutoSaveNr(){
|
|
|
|
-// autoSaveController.increaseAutoSaveNr();
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// public void decreaseAutoSaveNr(){
|
|
|
|
-// autoSaveController.decreaseAutoSaveNr();
|
|
|
|
-// }
|
|
|
|
|
|
+ return autoPath + (autoSaveController.getAutoSaveNr());
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Getter for Model
|
|
* Getter for Model
|