123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- package ui.controller;
- import java.util.ArrayList;
- import com.sun.glass.ui.View;
- import sun.lwawt.macosx.CPrinterSurfaceData;
- import ui.model.*;
- import ui.view.*;
- public class CategoryControl{
- private IdCounter ID;
- private Model M;
- private GUI V;
-
-
- public CategoryControl(Model model, GUI view, IdCounter id){
- this.ID = id;
- this.M = model;
- this.V = view;
- initCategories();
- }
-
-
-
- /**
- * init default category and objects
- */
- public void initCategories(){
- Category energy = new Category("Energy");
- Category building = new Category("Building");
- Category component = new Category("Component");
-
- HolonObject powerp = new HolonObject("Power Plant");
- HolonObject house = new HolonObject("House");
- HolonTransformer transformer = new HolonTransformer("Transformer");
- HolonSwitch sw = new HolonSwitch("Switch");
-
- addObject(energy, powerp);
- addObject(building, house);
- addObject(component, transformer);
- addObject(component, sw);
-
- addCategory(energy);
- addCategory(building);
- addCategory(component);
-
- }
-
-
- /**
- * Adds Category into Model
- * @param toAdd neue Kategorie
- */
- 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){
-
- 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);
- }
-
-
- }
|