Browse Source

fix und controll checkstyle

Kevin Trometer 7 years ago
parent
commit
c11acf0096

+ 3 - 0
src/ui/controller/AutoSaveController.java

@@ -14,6 +14,9 @@ public class AutoSaveController {
 		this.MODEL = model;
 	}
 
+	/**
+	 * Increase the Auto save number.
+	 */
 	public void increaseAutoSaveNr() {
 		currentSave = MODEL.getAutoSaveNr() + 1;
 		if (count < currentSave) {

+ 19 - 12
src/ui/controller/CanvasController.java

@@ -36,8 +36,9 @@ public class CanvasController {
 	}
 
 	/**
+	 * Add a new Object.
 	 * 
-	 * @param object
+	 * @param object the Object
 	 */
 	public void addNewObject(AbstractCpsObject object) {
 		object.setSav("CVS");
@@ -59,9 +60,9 @@ public class CanvasController {
 	}
 
 	/**
-	 * Deletes an CpsObject on the Canvas and its connections
+	 * Deletes an CpsObject on the Canvas and its connections.
 	 * 
-	 * @param AbstractCpsObject
+	 * @param obj AbstractCpsObject
 	 */
 	public void deleteObjectOnCanvas(AbstractCpsObject obj) {
 		CpsEdge e = null;
@@ -83,15 +84,19 @@ public class CanvasController {
 	}
 
 	/**
-	 * @param objectsOnCanvas
-	 *            the objectsOnCanvas to set
+	 * Add an edge to the Canvas.
+	 * 
+	 * @param edge
+	 *            the edge
 	 */
 	public void addEdgeOnCanvas(CpsEdge edge) {
 		MODEL.getEdgesOnCanvas().add(edge);
 	}
 
 	/**
-	 * @param edgesOnCanvas
+	 * Removes an Edge from the Canvas.
+	 * 
+	 * @param edge
 	 *            the edge to remove
 	 */
 	public void removeEdgesOnCanvas(CpsEdge edge) {
@@ -100,8 +105,10 @@ public class CanvasController {
 		MODEL.getEdgesOnCanvas().remove(edge);
 	}
 
+	
+	
 	/**
-	 * Copy all Selected Objects
+	 * Copy all Selected Objects.
 	 */
 	@SuppressWarnings("unchecked")
 	public void copyObjects() {
@@ -109,9 +116,9 @@ public class CanvasController {
 	}
 
 	/**
-	 * Paste all Selected Objects
+	 * Paste all Selected Objects.
 	 * 
-	 * @param Point
+	 * @param p
 	 *            the mouse Position
 	 */
 	public void pasteObjects(Point p) {
@@ -157,7 +164,7 @@ public class CanvasController {
 						&& MODEL.getClipboradObjects().indexOf(e.getB()) != -1) {
 					AbstractCpsObject A = tempList.get(MODEL.getClipboradObjects().indexOf(e.getA()));
 					AbstractCpsObject B = tempList.get(MODEL.getClipboradObjects().indexOf(e.getB()));
-					//was this Edge created or not?
+					// was this Edge created or not?
 					for (CpsEdge et : tempList.get(MODEL.getClipboradObjects().indexOf(cps)).getConnectedTo()) {
 						for (CpsEdge etA : et.getA().getConnectedTo()) {
 							if (et.getA() == A && et.getB() == B) {
@@ -187,12 +194,12 @@ public class CanvasController {
 	}
 
 	/**
-	 * Cut all Selected Objects
+	 * Cut all Selected Objects.
 	 */
 	@SuppressWarnings("unchecked")
 	public void cutObjects() {
 		MODEL.setClipboradObjects((ArrayList<AbstractCpsObject>) MODEL.getSelectedCpsObjects().clone());
-		
+
 		for (AbstractCpsObject cps : MODEL.getClipboradObjects()) {
 			deleteObjectOnCanvas(cps);
 		}

+ 34 - 14
src/ui/controller/CategoryController.java

@@ -22,7 +22,7 @@ public class CategoryController {
 	}
 
 	/**
-	 * init default category and objects
+	 * init default category and objects.
 	 */
 	public void initCategories() {
 
@@ -30,7 +30,8 @@ public class CategoryController {
 		addNewCategory("Building");
 		addNewCategory("Component");
 
-		addNewHolonObject(mpC.searchCat("Energy"), "Power Plant", new ArrayList<HolonElement>(), "/Images/power-plant.png");
+		addNewHolonObject(mpC.searchCat("Energy"), "Power Plant", new ArrayList<HolonElement>(),
+				"/Images/power-plant.png");
 		addNewHolonObject(mpC.searchCat("Building"), "House", new ArrayList<HolonElement>(), "/Images/home-2.png");
 		addNewHolonSwitch(mpC.searchCat("Component"), "Switch", "/Images/switch-on.png");
 
@@ -63,7 +64,7 @@ public class CategoryController {
 	}
 
 	/**
-	 * Adds New Category into Model
+	 * Adds New Category into Model.
 	 * 
 	 * @param name
 	 *            Bezeichnung der neuen Kategorie
@@ -74,7 +75,7 @@ public class CategoryController {
 	}
 
 	/**
-	 * remove a Category from Model
+	 * remove a Category from Model.
 	 */
 	public void removeCategory(Category c) {
 		mpC.decIdx(c.getName(), MODEL.getCgIdx());
@@ -85,16 +86,17 @@ public class CategoryController {
 	}
 
 	/**
-	 * delete a given Category
+	 * delete a given Category.
 	 * 
 	 * @param category
+	 *            the Category
 	 */
 	public void deleteCategory(String category) {
 		removeCategory(mpC.searchCat(category));
 	}
 
 	/**
-	 * Add Object into a Category
+	 * Add Object into a Category.
 	 * 
 	 * @param category
 	 *            Category
@@ -117,12 +119,16 @@ public class CategoryController {
 	}
 
 	/**
-	 * Add new Holon Object
+	 * Add new Holon Object to a Category.
 	 * 
-	 * @param cat
+	 * @param category
 	 *            Category
-	 * @param obj
+	 * @param object
 	 *            New Object Name
+	 * @param elements
+	 *            Array of Elements
+	 * @param image
+	 *            the image Path
 	 */
 	public void addNewHolonObject(Category category, String object, ArrayList<HolonElement> elements, String image) {
 		HolonObject obj = new HolonObject(object);
@@ -133,12 +139,14 @@ public class CategoryController {
 	}
 
 	/**
-	 * Add new Holon Transformer
+	 * Add new Holon Transformer.
 	 * 
 	 * @param cat
 	 *            Category
-	 * @param obj
+	 * @param objName
 	 *            New Object Name
+	 * @param image
+	 *            the image Path
 	 */
 	public void addNewHolonTransformer(Category cat, String objName, String image) {
 		HolonTransformer transformer = new HolonTransformer(objName);
@@ -148,12 +156,14 @@ public class CategoryController {
 	}
 
 	/**
-	 * Add new Holon Switch
+	 * Add new Holon Switch.
 	 * 
 	 * @param cat
 	 *            Category
-	 * @param obj
+	 * @param objName
 	 *            New Object Name
+	 * @param image
+	 *            the Image Path
 	 */
 	public void addNewHolonSwitch(Category cat, String objName, String image) {
 		HolonSwitch holonSwitch = new HolonSwitch(objName);
@@ -172,21 +182,31 @@ public class CategoryController {
 		notifyCatListeners();
 	}
 
+	/**
+	 * Delete an Object from a Category.
+	 * 
+	 * @param category
+	 *            the Category
+	 * @param obj
+	 *            the Object
+	 */
 	public void deleteObject(String category, String obj) {
 		Category cat = mpC.searchCat(category);
 		removeObject(cat, mpC.searchCatObj(cat, obj));
 	}
 
 	/**
+	 * Init the CategoryListener.
 	 * 
 	 * @param catLis
+	 *            the CategoryListener
 	 */
 	public void addCategoryListener(CategoryListener catLis) {
 		MODEL.getCategoryListeners().add(catLis);
 	}
 
 	/**
-	 * notifies all listeners about changes in the Categories
+	 * notifies all listeners about changes in the Categories.
 	 */
 	public void notifyCatListeners() {
 		for (CategoryListener l : MODEL.getCategoryListeners()) {

+ 323 - 39
src/ui/controller/Control.java

@@ -19,10 +19,15 @@ import ui.model.Model;
 import ui.view.MyCanvas;
 import ui.view.TimePanel;
 
-
+/**
+ * The Class represents the controller in the model, controller view Pattern.
+ * 
+ * @author Gruppe14
+ *
+ */
 public class Control {
 
-	private Model MODEL;
+	private Model model;
 
 	private ActionListener actionListener;
 
@@ -38,20 +43,26 @@ public class Control {
 	private SimulationManager simulationManager;
 	private String autoPath = "";
 
+	/**
+	 * Constructor.
+	 * 
+	 * @param model
+	 *            the Model
+	 */
 	public Control(Model model) {
-		this.MODEL = model;
-
-		this.multiPurposeController = new MultiPurposeController(MODEL);
-		this.categoryController = new CategoryController(MODEL, multiPurposeController);
-		this.objectController = new ObjectController(MODEL, multiPurposeController);
-		this.canvasController = new CanvasController(MODEL, multiPurposeController);
-		this.globalController = new GlobalController(MODEL);
-		this.storeController = new StoreController(MODEL);
-		this.loadController = new LoadController(MODEL, categoryController, canvasController, objectController,
+		this.model = model;
+
+		this.multiPurposeController = new MultiPurposeController(model);
+		this.categoryController = new CategoryController(model, multiPurposeController);
+		this.objectController = new ObjectController(model, multiPurposeController);
+		this.canvasController = new CanvasController(model, multiPurposeController);
+		this.globalController = new GlobalController(model);
+		this.storeController = new StoreController(model);
+		this.loadController = new LoadController(model, categoryController, canvasController, objectController,
 				multiPurposeController);
-		this.simulationManager = new SimulationManager(MODEL);
-		this.autoSaveController = new AutoSaveController(MODEL);
-		this.consoleController = new ConsoleController(MODEL);
+		this.simulationManager = new SimulationManager(model);
+		this.autoSaveController = new AutoSaveController(model);
+		this.consoleController = new ConsoleController(model);
 		autoPath = System.getProperty("user.home") + "/HolonGUI/Autosave/";
 		File dest = new File(autoPath);
 		deleteDirectory(dest);
@@ -64,6 +75,12 @@ public class Control {
 		}
 	}
 
+	/**
+	 * Delete a Directory.
+	 * 
+	 * @param path
+	 *            to delete
+	 */
 	public void deleteDirectory(File path) {
 		if (path.exists()) {
 			File[] files = path.listFiles();
@@ -80,58 +97,148 @@ public class Control {
 
 	/* Operations for searching */
 
-	public AbstractCpsObject searchByID(int ID) {
-		return multiPurposeController.searchByID(ID);
+	/**
+	 * Search for Object by ID.
+	 * 
+	 * @param id the id of the Object
+	 * @return the CpsObject
+	 */
+	public AbstractCpsObject searchByID(int id) {
+		return multiPurposeController.searchByID(id);
 	}
 
+	/**
+	 * Search for Object in a Category.
+	 * 
+	 * @param category
+	 *            name of the Category
+	 * @param object
+	 *            Name of the Object
+	 * @return The Object
+	 */
 	public AbstractCpsObject searchCategoryObject(String category, String object) {
 		return multiPurposeController.searchCatObj(multiPurposeController.searchCat(category), object);
 	}
 
+	/**
+	 * search for category.
+	 * 
+	 * @param cat name of the Category
+	 * @return the Category
+	 */
 	public Category searchCategory(String cat) {
 		return multiPurposeController.searchCat(cat);
 	}
 
 	/* Operations for Categories and Objects */
+	
+	/**
+	 * init default category and objects.
+	 */
 	public void resetCategorys() {
 		categoryController.initCategories();
 	}
 
+	/**
+	 * Adds New Category into Model.
+	 * 
+	 * @param cat
+	 *            name of the new Category
+	 */
 	public void addCategory(String cat) {
 		categoryController.addNewCategory(cat);
 	}
 
+	/**
+	 * Add new Holon Object to a Category.
+	 * 
+	 * @param cat
+	 *            Category
+	 * @param obj
+	 *            New Object Name
+	 *            @param ele Array of Elements
+	 * @param img
+	 *            the image Path
+	 */
 	public void addObject(Category cat, String obj, ArrayList<HolonElement> ele, String img) {
 		categoryController.addNewHolonObject(cat, obj, ele, img);
 	}
 
+	/**
+	 * Add new Holon Transformer to a Category.
+	 * 
+	 * @param cat
+	 *            Category
+	 * @param obj
+	 *            New Object Name
+	 */
 	public void addTransformer(Category cat, String obj) {
 		categoryController.addNewHolonTransformer(cat, obj, "/Images/transformer-1.png");
 	}
 
+	/**
+	 * Add new Holon Switch to a Category.
+	 * 
+	 * @param cat
+	 *            Category
+	 * @param obj
+	 *            New Object Name
+	 */
 	public void addSwitch(Category cat, String obj) {
 		categoryController.addNewHolonSwitch(cat, obj, "/Images/switch-on.png");
 	}
 
+	/**
+	 * delete a given Category.
+	 * 
+	 * @param cat
+	 *            the Category
+	 */
 	public void deleteCategory(String cat) {
 		categoryController.deleteCategory(cat);
 	}
 
+	/**
+	 * Delete an Object from a Category.
+	 * 
+	 * @param cat
+	 *            the Category
+	 * @param obj
+	 *            the Object
+	 */
 	public void delObjectCategory(String cat, String obj) {
 		categoryController.deleteObject(cat, obj);
 	}
 
+	/**
+	 * deletes a selectedObject.
+	 * 
+	 * @param obj
+	 *            Cpsobject
+	 */
 	public void deleteSelectedObject(AbstractCpsObject obj) {
 		objectController.deleteSelectedObject(obj);
 	}
 
+	/**
+	 * add an Object to selectedObject.
+	 * 
+	 * @param obj
+	 *            AbstractCpsobject
+	 */
 	public void addSelectedObject(AbstractCpsObject obj) {
 		objectController.addSelectedObject(obj);
 	}
 
 	/* Operations for Canvas */
 
-	public void AddEdgeOnCanvas(CpsEdge edge) {
+	/**
+	 * Add an edge to the Canvas.
+	 * 
+	 * @param edge
+	 *            the edge
+	 */
+	public void addEdgeOnCanvas(CpsEdge edge) {
 		canvasController.addEdgeOnCanvas(edge);
 		try {
 			autoSave();
@@ -141,6 +248,12 @@ public class Control {
 		}
 	}
 
+	/**
+	 * Removes an Edge from the Canvas.
+	 * 
+	 * @param edge
+	 *            the edge to remove
+	 */
 	public void removeEdgesOnCanvas(CpsEdge edge) {
 		canvasController.removeEdgesOnCanvas(edge);
 		try {
@@ -151,10 +264,22 @@ public class Control {
 		}
 	}
 
+	/**
+	 * Set the selected Edge.
+	 * 
+	 * @param edge
+	 *            that is selected
+	 */
 	public void setSelecteEdge(CpsEdge edge) {
-		MODEL.setSelectedEdge(edge);
+		model.setSelectedEdge(edge);
 	}
 
+	/**
+	 * Add a new Object.
+	 * 
+	 * @param object
+	 *            the Object
+	 */
 	public void addObjectCanvas(AbstractCpsObject object) {
 		canvasController.addNewObject(object);
 		if (!(object instanceof CpsNode)) {
@@ -167,10 +292,22 @@ public class Control {
 		}
 	}
 
+	/**
+	 * Returns the ID of the selected Object 0 = no Object is selected.
+	 * 
+	 * @param id
+	 *            the ID of the selected Object
+	 */
 	public void setSelectedObjectID(int id) {
 		objectController.setSelectedObjectID(id);
 	}
 
+	/**
+	 * Deletes an CpsObject on the Canvas and its connections.
+	 * 
+	 * @param obj
+	 *            AbstractCpsObject
+	 */
 	public void delCanvasObject(AbstractCpsObject obj) {
 		canvasController.deleteObjectOnCanvas(obj);
 		try {
@@ -182,71 +319,187 @@ public class Control {
 	}
 
 	/* Operations for Objects and Elements */
-	public void addElementCanvasObject(int ID, String ele, int amount, float energy) {
-		objectController.addNewElementIntoCanvasObject(ID, ele, amount, energy);
+
+	/**
+	 * Add a new Element into a Object on the Canvas.
+	 * 
+	 * @param id
+	 *            the Object ID
+	 * @param ele
+	 *            the Name of the Element
+	 * @param amount
+	 *            the Amount
+	 * @param energy
+	 *            the Energy
+	 */
+	public void addElementCanvasObject(int id, String ele, int amount, float energy) {
+		objectController.addNewElementIntoCanvasObject(id, ele, amount, energy);
 	}
 
+	/**
+	 * Add a new Element into a Object in Category.
+	 * 
+	 * @param catName
+	 *            the Category
+	 * @param objName
+	 *            the Object
+	 * @param eleName
+	 *            the Element Name
+	 * @param amount
+	 *            the amount
+	 * @param energy
+	 *            the Energy
+	 */
 	public void addElementCategoryObject(String catName, String objName, String eleName, int amount, float energy) {
 		objectController.addNewElementIntoCategoryObject(catName, objName, eleName, amount, energy);
 	}
 
-	public void deleteElementCanvas(int id, int elementId) {
-		objectController.deleteElementInCanvas(id, elementId);
+	/**
+	 * deletes a Element from a given Canvas Object.
+	 * 
+	 * @param id
+	 *            the ID
+	 * @param elementid
+	 *            the Element ID
+	 */
+	public void deleteElementCanvas(int id, int elementid) {
+		objectController.deleteElementInCanvas(id, elementid);
 	}
 
+	/**
+	 * deletes a Element from a given Object.
+	 * 
+	 * @param obj
+	 *            the Oject
+	 * @param ele
+	 *            the Element
+	 */
 	public void deleteElementCanvas(HolonObject obj, HolonElement ele) {
 		objectController.deleteElement(obj, ele);
 	}
 
+	/**
+	 * Sets the ClipboardObjects.
+	 * 
+	 * @param list
+	 *            Array of Objects
+	 */
 	public void setClipboardObjects(ArrayList<AbstractCpsObject> list) {
-		MODEL.setClipboradObjects(list);
+		model.setClipboradObjects(list);
 	}
 
 	/* Global Operations */
+
+	/**
+	 * Returns SCALE.
+	 * 
+	 * @return SCALE
+	 */
 	public int getScale() {
 		return globalController.getScale();
 	}
 
+	/**
+	 * Returns SCALE Divided by 2.
+	 * 
+	 * @return SCALE Divided by 2
+	 */
 	public int getScaleDiv2() {
 		return globalController.getScaleDiv2();
 	}
 
+	/**
+	 * Changes the value of SCALE and SCALEDIV2.
+	 * 
+	 * @param s
+	 *            Scale
+	 */
 	public void setScale(int s) {
 		globalController.setScale(s);
 	}
 
-	public void setCurIteration(int cur_it) {
-		globalController.setCurIteration(cur_it);
+	/**
+	 * sets the current Iteration.
+	 * 
+	 * @param curit
+	 *            the current Iteration
+	 */
+	public void setCurIteration(int curit) {
+		globalController.setCurIteration(curit);
 	}
 
-	/* Operations for Loading and Storing */
+	/**
+	 * Writes the current State of the Modelling into a JSON File which can be
+	 * loaded.
+	 * 
+	 * @param path
+	 *            the Path
+	 * 
+	 * @throws IOException
+	 *             exception
+	 */
 	public void saveFile(String path) throws IOException {
 		storeController.writeSaveFile(path);
 	}
 
+	/**
+	 * Reads the the JSON File and load the state into the Model.
+	 * 
+	 * @param path
+	 *            the Path
+	 * @throws IOException
+	 *             exception
+	 */
 	public void loadFile(String path) throws IOException {
 		loadController.readJSON(path);
 	}
 
-	////////// etc
+	/**
+	 * Init the CategoryListener.
+	 * 
+	 * @param catLis
+	 *            the CategoryListener
+	 */
 	public void initListener(CategoryListener catLis) {
 		categoryController.addCategoryListener(catLis);
 	}
 
+	/**
+	 * calculates the flow of the edges and the supply for objects for the
+	 * current Timestep.
+	 */
 	public void calculateStateForCurrentTimeStep() {
 		simulationManager.reset();
-		simulationManager.calculateStateForTimeStep(MODEL.getCurIteration());
+		simulationManager.calculateStateForTimeStep(model.getCurIteration());
 	}
 
+	/**
+	 * calculates the flow of the edges and the supply for objects.
+	 * 
+	 * @param x
+	 *            current Iteration
+	 */
 	public void calculateStateForTimeStep(int x) {
 		simulationManager.reset();
 		simulationManager.calculateStateForTimeStep(x);
 	}
 
+	/**
+	 * Set the Canvas.
+	 * 
+	 * @param can
+	 *            the Canvas
+	 */
 	public void setCanvas(MyCanvas can) {
 		simulationManager.setCanvas(can);
 	}
 
+	/**
+	 * make an autosave.
+	 * 
+	 * @throws IOException
+	 *             Exception
+	 */
 	public void autoSave() throws IOException {
 		autoSaveController.increaseAutoSaveNr();
 		storeController.writeCanvasFile(autoPath + autoSaveController.getAutoSaveNr());
@@ -255,6 +508,11 @@ public class Control {
 		}
 	}
 
+	/**
+	 * Returns the undo save.
+	 * 
+	 * @return the undo save
+	 */
 	public String getUndoSave() {
 		autoSaveController.decreaseAutoSaveNr();
 		if (!new File(autoPath + (autoSaveController.getAutoSaveNr())).exists()) {
@@ -263,6 +521,11 @@ public class Control {
 		return autoPath + (autoSaveController.getAutoSaveNr());
 	}
 
+	/**
+	 * Returns the redo save.
+	 * 
+	 * @return the redo save
+	 */
 	public String getRedoSave() {
 		autoSaveController.increaseAutoSaveNr();
 		if (!new File(autoPath + (autoSaveController.getAutoSaveNr())).exists()) {
@@ -271,10 +534,19 @@ public class Control {
 		return autoPath + (autoSaveController.getAutoSaveNr());
 	}
 
+	/**
+	 * Copy all Selected Objects.
+	 */
 	public void copyObjects() {
 		canvasController.copyObjects();
 	}
 
+	/**
+	 * Paste all Selected Objects.
+	 * 
+	 * @param point
+	 *            the mouse Position
+	 */
 	public void pasteObjects(Point point) {
 		canvasController.pasteObjects(point);
 		try {
@@ -285,6 +557,9 @@ public class Control {
 		}
 	}
 
+	/**
+	 * Cut all Selected Objects.
+	 */
 	public void cutObjects() {
 		canvasController.cutObjects();
 		try {
@@ -296,20 +571,25 @@ public class Control {
 	}
 
 	/**
-	 * Getter for Model
+	 * Getter for Model.
 	 * 
-	 * @return
+	 * @return the Model
 	 */
 	public Model getModel() {
-		return MODEL;
+		return model;
 	}
 
+	/**
+	 * get the Simulation Manager.
+	 * 
+	 * @return the Simulation Manager
+	 */
 	public SimulationManager getSimManager() {
 		return simulationManager;
 	}
 
 	/**
-	 * Getter for selected CpsObject
+	 * Getter for selected CpsObject.
 	 *
 	 * @param text
 	 *            String the Text
@@ -321,17 +601,16 @@ public class Control {
 	 *            bold or not
 	 * @param italic
 	 *            italic or not
-	 * @param ln
+	 * @param nl
 	 *            new line or not
 	 * 
-	 * @return selected CpsObject
 	 */
 	public void addTextToConsole(String text, Color color, int p, boolean bold, boolean italic, boolean nl) {
 		consoleController.addTextToConsole(text, color, p, bold, italic, nl);
 	}
 
 	/**
-	 * Print Text on the console in black and font size 12
+	 * Print Text on the console in black and font size 12.
 	 *
 	 * @param text
 	 *            String the Text
@@ -341,22 +620,27 @@ public class Control {
 	}
 
 	/**
-	 * Clears the console
+	 * Clears the console.
 	 */
 	public void clearConsole() {
 		consoleController.clearConsole();
 	}
 
 	/**
-	 * @return sets the timerSpeed
+	 * Set the timerSpeed.
+	 * 
+	 * @param t
+	 *            interval in ms
 	 */
 	public void setTimerSpeed(int t) {
 		globalController.setTimerSpeed(t);
 	}
 
 	/**
-	 * @param isSimulation
-	 *            boolean for for isSimulation
+	 * Set if its simulating or not.
+	 * 
+	 * @param b
+	 *            isSimulation
 	 */
 	public void setIsSimulation(boolean b) {
 		globalController.setIsSimulation(b);

+ 8 - 8
src/ui/controller/GlobalController.java

@@ -11,7 +11,7 @@ public class GlobalController {
 	}
 
 	/**
-	 * Returns SCALE
+	 * Returns SCALE.
 	 * 
 	 * @return SCALE
 	 */
@@ -20,7 +20,7 @@ public class GlobalController {
 	}
 
 	/**
-	 * Returns SCALE Divided by 2
+	 * Returns SCALE Divided by 2.
 	 * 
 	 * @return SCALE Divided by 2
 	 */
@@ -29,9 +29,9 @@ public class GlobalController {
 	}
 
 	/**
-	 * Changes the value of SCALE and SCALEDIV2
+	 * Changes the value of SCALE and SCALEDIV2.
 	 * 
-	 * @param int
+	 * @param s
 	 *            Scale
 	 */
 	public void setScale(int s) {
@@ -39,13 +39,13 @@ public class GlobalController {
 	}
 
 	/**
-	 * sets the current Iteration
+	 * sets the current Iteration.
 	 * 
-	 * @param cur_it,
+	 * @param curit
 	 *            the current Iteration
 	 */
-	public void setCurIteration(int cur_it) {
-		MODEL.setCurIteration(cur_it);
+	public void setCurIteration(int curit) {
+		MODEL.setCurIteration(curit);
 	}
 
 	/**

+ 3 - 3
src/ui/controller/LoadController.java

@@ -47,10 +47,10 @@ public class LoadController {
 	}
 
 	/**
-	 * Reads the the JSON File and load the state into the Model
+	 * Reads the the JSON File and load the state into the Model.
 	 * 
-	 * @param path
-	 * @throws IOException
+	 * @param path the Path
+	 * @throws IOException exception
 	 */
 	public void readJSON(String path) throws IOException {
 		JSONParser parser = new JSONParser();

+ 14 - 12
src/ui/controller/MultiPurposeController.java

@@ -20,10 +20,11 @@ public class MultiPurposeController {
 	}
 
 	/**
-	 * search for category
+	 * search for category.
 	 * 
-	 * @param name
-	 * @return
+	 * @param category
+	 *            name of the Category
+	 * @return the Category
 	 */
 	public Category searchCat(String category) {
 
@@ -36,11 +37,13 @@ public class MultiPurposeController {
 	}
 
 	/**
-	 * Search for Object
+	 * Search for Object in a Category.
 	 * 
+	 * @param category
+	 *            name of the Category
 	 * @param object
-	 * @param list
-	 * @return
+	 *            Name of the Object
+	 * @return The Object
 	 */
 	public AbstractCpsObject searchCatObj(Category category, String object) {
 
@@ -53,17 +56,16 @@ public class MultiPurposeController {
 	}
 
 	/**
-	 * Search for Object by ID
+	 * Search for Object by ID.
 	 * 
-	 * @param ID
-	 * @param list
-	 * @return
+	 * @param id the ID of the Object
+	 * @return the CpsObject
 	 */
-	public AbstractCpsObject searchByID(int ID) {
+	public AbstractCpsObject searchByID(int id) {
 
 		Integer idx;
 
-		if ((idx = MODEL.getCvsObjIdx().get(ID)) == null || MODEL.getCvsObjIdx().size() < 1)
+		if ((idx = MODEL.getCvsObjIdx().get(id)) == null || MODEL.getCvsObjIdx().size() < 1)
 			return null;
 		else
 			return MODEL.getObjectsOnCanvas().get(idx);

+ 33 - 26
src/ui/controller/ObjectController.java

@@ -54,13 +54,12 @@ public class ObjectController {
 	}
 
 	/**
-	 * Add a new Element into a Object on the Canvas
+	 * Add a new Element into a Object on the Canvas.
 	 * 
-	 * @param object
-	 * @param eleName
-	 * @param amount
-	 * @param energy
-	 * @param type
+	 * @param id the Object ID
+	 * @param element the Name of the Element
+	 * @param amount the Amount
+	 * @param energy the Energy
 	 */
 	public void addNewElementIntoCanvasObject(int id, String element, int amount, float energy) {
 		HolonElement ele = new HolonElement(element, amount, energy);
@@ -68,7 +67,7 @@ public class ObjectController {
 	}
 
 	/**
-	 * Add Element into a Object in Category
+	 * Add Element into a Object in Category.
 	 * 
 	 * @param object
 	 * @param element
@@ -80,13 +79,18 @@ public class ObjectController {
 	}
 
 	/**
-	 * Add a new Element into a Object in Category
+	 * Add a new Element into a Object in Category.
 	 * 
 	 * @param category
+	 *            the Category
 	 * @param object
-	 * @param eleName
-	 * @param amount
+	 *            the Object
+	 * @param element
+	 *            the Element Name
 	 * @param energy
+	 *            the Energy
+	 * @param amount
+	 *            the amount
 	 */
 	public void addNewElementIntoCategoryObject(String category, String object, String element, int amount,
 			float energy) {
@@ -96,10 +100,12 @@ public class ObjectController {
 	}
 
 	/**
-	 * deletes a Element from a given Object
+	 * deletes a Element from a given Object.
 	 * 
 	 * @param obj
+	 *            the Oject
 	 * @param ele
+	 *            the Element
 	 */
 	public void deleteElement(HolonObject obj, HolonElement ele) {
 		System.out.println(ele.getEleName() + " and " + obj.getEleIdx());
@@ -109,33 +115,34 @@ public class ObjectController {
 	}
 
 	/**
-	 * deletes a selectedObject
+	 * deletes a selectedObject.
 	 * 
-	 * @param Cpsobject
+	 * @param obj Cpsobject
 	 */
 	public void deleteSelectedObject(AbstractCpsObject obj) {
 		MODEL.getSelectedCpsObjects().remove(obj);
 	}
 
 	/**
-	 * 	s a selectedObject
+	 * add an Object to selectedObject.
 	 * 
-	 * @param Cpsobject
+	 * @param obj AbstractCpsobject
 	 */
 	public void addSelectedObject(AbstractCpsObject obj) {
 		MODEL.getSelectedCpsObjects().add(obj);
 	}
 
 	/**
-	 * deletes a Element from a given Canvas Object
+	 * deletes a Element from a given Canvas Object.
 	 * 
-	 * @param ID
-	 * @param ele
-	 * @param amount
+	 * @param id
+	 *            the ID
+	 * @param eleid
+	 *            the Element ID
 	 */
-	public void deleteElementInCanvas(int ID, int eleId) {
-		HolonObject object = (HolonObject) mpC.searchByID(ID);
-		HolonElement element = mpC.searchEleById(object, eleId);
+	public void deleteElementInCanvas(int id, int eleid) {
+		HolonObject object = (HolonObject) mpC.searchByID(id);
+		HolonElement element = mpC.searchEleById(object, eleid);
 		// mpC.searchEle(object, ele);
 		System.out.println(object.getName() + " and " + element.getEleName());
 		deleteElement(object, element);
@@ -158,18 +165,18 @@ public class ObjectController {
 	}
 
 	/**
-	 * Returns the ID of the selected Object 0 = no Object is selected
+	 * Returns the ID of the selected Object 0 = no Object is selected.
 	 * 
-	 * @return ID
+	 * @param id the ID of the selected Object
 	 */
 	public void setSelectedObjectID(int id) {
 		MODEL.setSelectedObjectID(id);
 	}
 
 	/**
-	 * sets clipBoardObjects
+	 * sets clipBoardObjects.
 	 * 
-	 * @param ArrayList
+	 * @param list
 	 *            of CpsObjects
 	 */
 	public void setClipboardObjects(ArrayList<AbstractCpsObject> list) {

+ 16 - 2
src/ui/controller/SimulationManager.java

@@ -31,9 +31,9 @@ public class SimulationManager {
 	}
 
 	/**
-	 * calculates the flow of the edges and the supply for objects
+	 * calculates the flow of the edges and the supply for objects.
 	 * 
-	 * @param x
+	 * @param x current Iteration
 	 */
 	public void calculateStateForTimeStep(int x) {
 		simMode = model.getIsSimulation();
@@ -422,14 +422,28 @@ public class SimulationManager {
 		}
 	}
 
+	/**
+	 * Set the Canvas.
+	 * 
+	 * @param can
+	 *            the Canvas
+	 */
 	public void setCanvas(MyCanvas can) {
 		canvas = can;
 	}
 
+	/**
+	 * Reset all Data to the current state of the Model.
+	 */
 	public void reset() {
 		copyObjects(model.getObjectsOnCanvas());
 	}
 
+	/**
+	 * Get all Subnets.
+	 * 
+	 * @return all Subnets
+	 */
 	public ArrayList<SubNet> getSubNets() {
 		return subNets;
 	}

+ 3 - 2
src/ui/controller/StoreController.java

@@ -29,9 +29,10 @@ public class StoreController {
 
 	/**
 	 * Writes the current State of the Modelling into a JSON File which can be
-	 * loaded
+	 * loaded.
+	 * @param path the Path
 	 * 
-	 * @throws IOException
+	 * @throws IOException exception
 	 */
 	public void writeSaveFile(String path) throws IOException {
 

+ 7 - 15
src/ui/view/MyCanvas.java

@@ -368,6 +368,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
 				controller.addTextToConsole("" + cps.getID(), Color.RED, 12, true, false, true);
 				dragging = true;
+				controller.setSelectedObjectID(tempCps.getID());
 				// If drawing an Edge (CTRL down)
 				if (tempCps.getClass() == HolonObject.class) {
 					HolonObject tempObj = ((HolonObject) tempCps);
@@ -411,16 +412,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			model.getSelectedCpsObjects().clear();
 			controller.addSelectedObject(tempCps);
 		}
-		if (e.isControlDown()) {
-			if (model.getSelectedCpsObjects().contains(tempCps)) {
-				model.getSelectedCpsObjects().remove(tempCps);
-				if (model.getSelectedCpsObjects().isEmpty()) {
-					tempCps = null;
-				}
-			} else {
-				controller.addSelectedObject(tempCps);
-			}
-		}
+		
 		if (dragged == true) {
 			try {
 				controller.autoSave();
@@ -620,7 +612,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				}
 				if (newEdge) {
 					e = new CpsEdge(cps, tempCps, edgeCapacity);
-					controller.AddEdgeOnCanvas(e);
+					controller.addEdgeOnCanvas(e);
 				}
 			}
 		}
@@ -649,9 +641,9 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				e2 = new CpsEdge(n, k, edgeCapacity);
 
 				controller.removeEdgesOnCanvas(p);
-				controller.AddEdgeOnCanvas(e);
-				controller.AddEdgeOnCanvas(e1);
-				controller.AddEdgeOnCanvas(e2);
+				controller.addEdgeOnCanvas(e);
+				controller.addEdgeOnCanvas(e1);
+				controller.addEdgeOnCanvas(e2);
 			}
 		}
 
@@ -664,7 +656,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 
 			e = new CpsEdge(n, tempCps, edgeCapacity);
 
-			controller.AddEdgeOnCanvas(e);
+			controller.addEdgeOnCanvas(e);
 		}
 
 		// Wenn ein Node ohne Connections da ist