Browse Source

model checkstyled

Kevin Trometer 7 years ago
parent
commit
256a067035
1 changed files with 136 additions and 38 deletions
  1. 136 38
      src/ui/model/Model.java

+ 136 - 38
src/ui/model/Model.java

@@ -12,16 +12,22 @@ import classes.Category;
 import classes.CpsEdge;
 import classes.AbstractCpsObject;
 import classes.HolonElement;
-import ui.controller.*;
 import ui.view.Console;
 
+/**
+ * The Class Model is the class where everything is saved. All changes made to
+ * the Data is managed via a controller.
+ * 
+ * @author Gruppe14
+ *
+ */
 public class Model {
 
 	// Global Variables
-	private static int SCALE = 50; // Picture Scale
-	private static int SCALE_DIV2 = SCALE / 2;
+	private static int sCALE = 50; // Picture Scale
+	private static int sCALEdIV2 = sCALE / 2;
 	private static final int ITERATIONS = 100;
-	private int CUR_ITERATION = 0;
+	private int curIteration = 0;
 	// ID of the Selected Object
 	private AbstractCpsObject selectedCpsObject = null;
 	private HolonElement selectedHolonElement;
@@ -41,9 +47,6 @@ public class Model {
 	private int autoSaveNr = -1;
 	// number of max simultaneous autosaves
 	private int numberOfSaves = 35;
-	// eventuell wenn Canvasgröße gewählt werden kann
-	private int HEIGHT;
-	private int WIDTH;
 	/*
 	 * Array of all categories in the model. It is set by default with the
 	 * categories ENERGY, BUILDINGS and COMPONENTS
@@ -71,7 +74,7 @@ public class Model {
 	private List<CategoryListener> categoryListeners;
 	private List<ObjectListener> objectListeners;
 
-	/*
+	/**
 	 * Constructor for the model. It initializes the categories and
 	 * objectsOnCanvas by default values. Listeners are also initialized by
 	 * default values.
@@ -88,6 +91,8 @@ public class Model {
 	}
 
 	/**
+	 * Returns all Categories.
+	 * 
 	 * @return the categories
 	 */
 	public ArrayList<Category> getCategories() {
@@ -95,6 +100,8 @@ public class Model {
 	}
 
 	/**
+	 * Sets all Categories.
+	 * 
 	 * @param categories
 	 *            the categories to set
 	 */
@@ -104,7 +111,7 @@ public class Model {
 
 	/**
 	 * Transform the Arraylist of categories into a string of all objectName
-	 * with a separation (',') between each name
+	 * with a separation (',') between each name.
 	 * 
 	 * @return String of all names separeted by ','
 	 */
@@ -121,6 +128,8 @@ public class Model {
 	}
 
 	/**
+	 * Returns all Objects on the Canvas.
+	 * 
 	 * @return the objectsOnCanvas
 	 */
 	public ArrayList<AbstractCpsObject> getObjectsOnCanvas() {
@@ -128,6 +137,8 @@ public class Model {
 	}
 
 	/**
+	 * Sets all Objects on the Canvas.
+	 * 
 	 * @param objectsOnCanvas
 	 *            the objectsOnCanvas to set
 	 */
@@ -136,6 +147,8 @@ public class Model {
 	}
 
 	/**
+	 * Get all Edges on the Canvas.
+	 * 
 	 * @return the objectsOnCanvas
 	 */
 	public ArrayList<CpsEdge> getEdgesOnCanvas() {
@@ -143,15 +156,19 @@ public class Model {
 	}
 
 	/**
-	 * @param objectsOnCanvas
-	 *            the objectsOnCanvas to set
+	 * Adds an Edge to The Canvas.
+	 * 
+	 * @param edge
+	 *            the edgesOnCanvas to add
 	 */
 	public void addEdgeOnCanvas(CpsEdge edge) {
 		this.edgesOnCanvas.add(edge);
 	}
 
 	/**
-	 * @param edgesOnCanvas
+	 * Remove an edge from the Canvas.
+	 * 
+	 * @param edge
 	 *            the edge to remove
 	 */
 	public void removeEdgesOnCanvas(CpsEdge edge) {
@@ -159,7 +176,9 @@ public class Model {
 	}
 
 	/**
-	 * @param EdgesOnCanvas
+	 * Sets the edges on the Canvas.
+	 * 
+	 * @param arrayList
 	 *            the edgesOnCanvas to set
 	 */
 	public void setEdgesOnCanvas(ArrayList<CpsEdge> arrayList) {
@@ -167,6 +186,8 @@ public class Model {
 	}
 
 	/**
+	 * Returns the ObjectListener.
+	 * 
 	 * @return the objectListeners
 	 */
 	public List<ObjectListener> getObjectListeners() {
@@ -174,6 +195,8 @@ public class Model {
 	}
 
 	/**
+	 * Sets the ObjectListener.
+	 * 
 	 * @param linkedList
 	 *            the objectListeners to set
 	 */
@@ -182,6 +205,8 @@ public class Model {
 	}
 
 	/**
+	 * Returns the CategorieListener.
+	 * 
 	 * @return the categoryListeners
 	 */
 	public List<CategoryListener> getCategoryListeners() {
@@ -189,6 +214,8 @@ public class Model {
 	}
 
 	/**
+	 * Sets the CategorieListener.
+	 * 
 	 * @param linkedList
 	 *            the categoryListeners to set
 	 */
@@ -197,9 +224,10 @@ public class Model {
 	}
 
 	/**
-	 * Set the ID of the selected Object 0 = no Object is selected
+	 * Set the ID of the selected Object 0 = no Object is selected.
 	 * 
-	 * @param ID
+	 * @param id
+	 *            the ID
 	 * 
 	 */
 	public void setSelectedObjectID(int id) {
@@ -207,7 +235,7 @@ public class Model {
 	}
 
 	/**
-	 * 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
 	 */
@@ -215,51 +243,84 @@ public class Model {
 		return selectedID;
 	}
 
+	/**
+	 * Returns the Selected Cps Object.
+	 * 
+	 * @return selected Cps Object
+	 */
 	public AbstractCpsObject getSelectedCpsObject() {
 		return selectedCpsObject;
 	}
 
+	/**
+	 * Set the Selected Objecs.
+	 * 
+	 * @param selectedCpsObject
+	 *            Objects that are selected
+	 */
 	public void setSelectedCpsObject(AbstractCpsObject selectedCpsObject) {
 		this.selectedCpsObject = selectedCpsObject;
 	}
 
+	/**
+	 * Returns all selected Objects on the Canvas.
+	 * 
+	 * @return The selected Objects
+	 */
 	public ArrayList<AbstractCpsObject> getSelectedCpsObjects() {
 		return selectedObjects;
 	}
 
+	/**
+	 * Returns the Selected Holon Element.
+	 * 
+	 * @return selected Holon Element
+	 */
 	public HolonElement getSelectedHolonElement() {
 		return selectedHolonElement;
 	}
 
+	/**
+	 * Sets the Selecte HolonElement.
+	 * 
+	 * @param selectedHolonElement
+	 *            that is Selected
+	 */
 	public void setSelectedHolonElement(HolonElement selectedHolonElement) {
 		this.selectedHolonElement = selectedHolonElement;
 	}
 
 	/**
-	 * Returns SCALE
+	 * Returns the sCale (Scale for the Images).
 	 * 
-	 * @return SCALE
+	 * @return sCALE
 	 */
 	public int getScale() {
-		return SCALE;
+		return sCALE;
 	}
 
 	/**
-	 * Returns SCALE_DIV2
+	 * Returns sCALEdIV2 (The Scale divided by 2).
 	 * 
-	 * @return SCALE_DIV2
+	 * @return sCALEdIV2
 	 */
 	public int getScaleDiv2() {
-		return SCALE_DIV2;
+		return sCALEdIV2;
 	}
 
+	/**
+	 * Sets the Image Scale.
+	 * 
+	 * @param scale
+	 *            for the image
+	 */
 	public void setScale(int scale) {
-		SCALE = scale;
-		SCALE_DIV2 = SCALE / 2;
+		sCALE = scale;
+		sCALEdIV2 = sCALE / 2;
 	}
 
 	/**
-	 * Returns ITERATIONS
+	 * Returns ITERATIONS.
 	 * 
 	 * @return ITERATIONS
 	 */
@@ -268,28 +329,29 @@ public class Model {
 	}
 
 	/**
-	 * sets the current Iteration
+	 * sets the current Iteration.
 	 * 
-	 * @param cur_it,
+	 * @param curIT
 	 *            the current Iteration
 	 */
-	public void setCurIteration(int cur_it) {
-		this.CUR_ITERATION = cur_it;
+	public void setCurIteration(int curIT) {
+		this.curIteration = curIT;
 	}
 
 	/**
-	 * Returns CUR_ITERATIONS
+	 * Returns cURiTERATION.
 	 * 
-	 * @return CUR_ITERATIONS
+	 * @return cURiTERATION
 	 */
 	public int getCurIteration() {
-		return CUR_ITERATION;
+		return curIteration;
 	}
 
 	/**
-	 * Set the selected Edge
+	 * Set the selected Edge.
 	 * 
 	 * @param edge
+	 *            that is selected
 	 * 
 	 */
 	public void setSelectedEdge(CpsEdge edge) {
@@ -297,7 +359,7 @@ public class Model {
 	}
 
 	/**
-	 * Returns the selected Edge
+	 * Returns the selected Edge.
 	 * 
 	 * @return selectedEdge
 	 */
@@ -306,6 +368,8 @@ public class Model {
 	}
 
 	/**
+	 * Returns the Categorie Index.
+	 * 
 	 * @return the cgIdx
 	 */
 	public HashMap<String, Integer> getCgIdx() {
@@ -313,6 +377,8 @@ public class Model {
 	}
 
 	/**
+	 * Sets the Categorie Index.
+	 * 
 	 * @param cgIdx
 	 *            the cgIdx to set
 	 */
@@ -321,6 +387,8 @@ public class Model {
 	}
 
 	/**
+	 * Returns the CanvasObject Index.
+	 * 
 	 * @return the cvsObjIdx
 	 */
 	public HashMap<Integer, Integer> getCvsObjIdx() {
@@ -328,6 +396,8 @@ public class Model {
 	}
 
 	/**
+	 * Sets the CanvasObject Index.
+	 * 
 	 * @param cvsObjIdx
 	 *            the cvsObjIdx to set
 	 */
@@ -335,15 +405,28 @@ public class Model {
 		this.cvsObjIdx = cvsObjIdx;
 	}
 
+	/**
+	 * Sets the auto save Number.
+	 * 
+	 * @param autoSaveNr
+	 *            the auto save number
+	 */
 	public void setAutoSaveNr(int autoSaveNr) {
 		this.autoSaveNr = autoSaveNr;
 	}
 
+	/**
+	 * Returns the auto save Number.
+	 * 
+	 * @return the auto save Number
+	 */
 	public int getAutoSaveNr() {
 		return autoSaveNr;
 	}
 
 	/**
+	 * Returns the Number of Saves.
+	 * 
 	 * @return the numberOfSaves
 	 */
 	public int getNumberOfSaves() {
@@ -351,6 +434,8 @@ public class Model {
 	}
 
 	/**
+	 * Set the Number of Saves.
+	 * 
 	 * @param numberOfSaves
 	 *            the numberOfSaves to set
 	 */
@@ -359,7 +444,9 @@ public class Model {
 	}
 
 	/**
-	 * @param Objects
+	 * Sets the ClipboardObjects.
+	 * 
+	 * @param c
 	 *            Array of Objects
 	 */
 	public void setClipboradObjects(ArrayList<AbstractCpsObject> c) {
@@ -367,6 +454,7 @@ public class Model {
 	}
 
 	/**
+	 * Returns all Objects in the Clipboard.
 	 * 
 	 * @return Objects in the Clipboard
 	 */
@@ -375,6 +463,7 @@ public class Model {
 	}
 
 	/**
+	 * Sets the console.
 	 * 
 	 * @param console
 	 *            the console
@@ -384,6 +473,7 @@ public class Model {
 	}
 
 	/**
+	 * Returns the Console.
 	 * 
 	 * @return console the console
 	 */
@@ -392,7 +482,9 @@ public class Model {
 	}
 
 	/**
-	 * @param timerSpeed
+	 * Sets the Interval in ms between each Iteration.
+	 * 
+	 * @param t
 	 *            speed for the Iterations
 	 */
 	public void setTimerSpeed(int t) {
@@ -400,6 +492,8 @@ public class Model {
 	}
 
 	/**
+	 * get the Interval in ms between each Iteration.
+	 * 
 	 * @return timerSpeed speed for the Iterations
 	 */
 	public int getTimerSpeed() {
@@ -407,14 +501,18 @@ public class Model {
 	}
 
 	/**
+	 * Sets the Simulation state (true = simulation, false = modeling).
+	 * 
 	 * @param isSimulation
 	 *            boolean for for isSimulation
 	 */
-	public void setIsSimulation(boolean b) {
-		this.isSimulation = b;
+	public void setIsSimulation(boolean isSimulation) {
+		this.isSimulation = isSimulation;
 	}
 
 	/**
+	 * Returns the Simulation state (true = simulation, false = modeling).
+	 * 
 	 * @return isSimulation boolean for for isSimulation
 	 */
 	public boolean getIsSimulation() {