|
@@ -4,27 +4,28 @@ import java.util.ArrayList;
|
|
|
|
|
|
import com.sun.glass.ui.View;
|
|
import com.sun.glass.ui.View;
|
|
|
|
|
|
|
|
+import sun.lwawt.macosx.CPrinterSurfaceData;
|
|
import ui.model.*;
|
|
import ui.model.*;
|
|
import ui.view.*;
|
|
import ui.view.*;
|
|
|
|
|
|
public class CategoryControl{
|
|
public class CategoryControl{
|
|
|
|
|
|
- private IdCounter id;
|
|
|
|
- private Model model;
|
|
|
|
- private GUI view;
|
|
|
|
|
|
+ private IdCounter ID;
|
|
|
|
+ private Model M;
|
|
|
|
+ private GUI V;
|
|
|
|
|
|
|
|
|
|
public CategoryControl(Model model, GUI view, IdCounter id){
|
|
public CategoryControl(Model model, GUI view, IdCounter id){
|
|
- this.id = id;
|
|
|
|
- this.model = model;
|
|
|
|
- this.view = view;
|
|
|
|
|
|
+ this.ID = id;
|
|
|
|
+ this.M = model;
|
|
|
|
+ this.V = view;
|
|
initCategories();
|
|
initCategories();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * initialisiert alle Standart Kategorien und Objekte
|
|
|
|
|
|
+ * init default category and objects
|
|
*/
|
|
*/
|
|
public void initCategories(){
|
|
public void initCategories(){
|
|
Category energy = new Category("Energy");
|
|
Category energy = new Category("Energy");
|
|
@@ -33,35 +34,80 @@ public class CategoryControl{
|
|
|
|
|
|
HolonObject powerp = new HolonObject("Power Plant");
|
|
HolonObject powerp = new HolonObject("Power Plant");
|
|
HolonObject house = new HolonObject("House");
|
|
HolonObject house = new HolonObject("House");
|
|
- HolonObject transformer = new HolonObject("Transformer");
|
|
|
|
- HolonObject sw = new HolonObject("Switch");
|
|
|
|
|
|
+ HolonTransformer transformer = new HolonTransformer("Transformer");
|
|
|
|
+ HolonSwitch sw = new HolonSwitch("Switch");
|
|
|
|
|
|
- energy.addObject(powerp);
|
|
|
|
- building.addObject(house);
|
|
|
|
- component.addObject(transformer);
|
|
|
|
- component.addObject(sw);
|
|
|
|
-
|
|
|
|
- model.addCategory(energy);
|
|
|
|
- model.addCategory(building);
|
|
|
|
- model.addCategory(component);
|
|
|
|
|
|
+ addObject(energy, powerp);
|
|
|
|
+ addObject(building, house);
|
|
|
|
+ addObject(component, transformer);
|
|
|
|
+ addObject(component, sw);
|
|
|
|
|
|
|
|
+ addCategory(energy);
|
|
|
|
+ addCategory(building);
|
|
|
|
+ addCategory(component);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * läd die Kategorien und Objekte in die View
|
|
|
|
|
|
+ * Adds Category into Model
|
|
|
|
+ * @param toAdd neue Kategorie
|
|
*/
|
|
*/
|
|
- public void loadCategories(){
|
|
|
|
- //ArrayList<Category> category = m.getCategories();
|
|
|
|
|
|
+ public void addCategory(Category toAdd){
|
|
|
|
+ M.getCategories().add(toAdd);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Adds New Category into Model
|
|
|
|
+ * @param name Bezeichnung der neuen Kategorie
|
|
|
|
+ */
|
|
|
|
+ public void addNewCategory(String name){
|
|
|
|
|
|
-
|
|
|
|
-// for (Category c : category) {
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
|
|
+ addCategory(new Category(name));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Add Object into a Category
|
|
|
|
+ * @param cat Category
|
|
|
|
+ * @param obj Object
|
|
|
|
+ */
|
|
|
|
+ public void addObject(Category cat,CpsObject obj){
|
|
|
|
+ cat.getObjects().add(obj);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Add new Holon Object
|
|
|
|
+ * @param cat Category
|
|
|
|
+ * @param obj New Object Name
|
|
|
|
+ */
|
|
|
|
+ public void addNewHolonObject(Category cat, String obj){
|
|
|
|
+ addObject(cat, new HolonObject(obj));
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Add new Holon Transformer
|
|
|
|
+ * @param cat Category
|
|
|
|
+ * @param obj New Object Name
|
|
|
|
+ */
|
|
|
|
+ public void addNewHolonTransformer(Category cat, String obj){
|
|
|
|
+ addObject(cat, new HolonTransformer(obj));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Add new Holon Switch
|
|
|
|
+ * @param cat Category
|
|
|
|
+ * @param obj New Object Name
|
|
|
|
+ */
|
|
|
|
+ public void addNewHolonSwitch(Category cat, String obj){
|
|
|
|
+ addObject(cat, new HolonSwitch(obj));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public void deleteCategory(int idx){
|
|
|
|
+ M.getCategories().remove(idx);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|