12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package ui.model;
- import Interfaces.CategoryListener;
- import java.util.ArrayList;
- import java.util.LinkedList;
- import java.util.List;
- import ui.controller.*;
- public class Model {
-
- //eventuell wenn Canvasgröße gewählt werden kann
- private int HEIGHT;
- private int WIDTH;
-
-
- private ArrayList<Category> categories;
- private ArrayList<CpsObject> objectsOnCanvas;
- private List<CategoryListener> categoryListeners = new LinkedList<>();
-
-
- public Model(){
- setCategories(new ArrayList<Category>());
- setObjectsOnCanvas(new ArrayList<CpsObject>());
- }
-
- /**
- *
- * @param toAdd
- */
- public void addCategory(Category toAdd){
- categories.add(toAdd);
- notifyCatListeners();
- }
-
- /**
- *
- * @param catLis
- */
- public void addCatListener(CategoryListener catLis){
- categoryListeners.add(catLis);
- }
- /**
- *
- */
- private void notifyCatListeners() {
- for(CategoryListener l : categoryListeners){
- l.onChange(this.categories);
- }
-
- }
- /**
- * @return the categories
- */
- public ArrayList<Category> getCategories() {
- return categories;
- }
- /**
- * @param categories the categories to set
- */
- public void setCategories(ArrayList<Category> categories) {
- this.categories = categories;
- }
- /**
- * @return the objectsOnCanvas
- */
- public ArrayList<CpsObject> getObjectsOnCanvas() {
- return objectsOnCanvas;
- }
- /**
- * @param objectsOnCanvas the objectsOnCanvas to set
- */
- public void setObjectsOnCanvas(ArrayList<CpsObject> objectsOnCanvas) {
- this.objectsOnCanvas = objectsOnCanvas;
- }
-
-
-
-
- }
|