Bladeren bron

Comments (class classes)

Edgardo Palza 8 jaren geleden
bovenliggende
commit
1335f35614
4 gewijzigde bestanden met toevoegingen van 119 en 18 verwijderingen
  1. 83 4
      src/classes/HolonSwitch.java
  2. 22 5
      src/classes/Position.java
  3. 14 8
      src/classes/subNet.java
  4. 0 1
      src/ui/view/MyCanvas.java

+ 83 - 4
src/classes/HolonSwitch.java

@@ -3,6 +3,14 @@ package classes;
 import java.awt.Point;
 import java.util.LinkedList;
 
+/**
+ * The class HolonSwitch represents an Object in the system, that has the
+ * capacity of manipulate the electricity flow. The switch can be manage
+ * automatically through a graph or direct manually.
+ * 
+ * @author Gruppe14
+ *
+ */
 public class HolonSwitch extends CpsObject {
 	/*
 	 * manual state True, if this wire is working (capable of carrying
@@ -29,6 +37,13 @@ public class HolonSwitch extends CpsObject {
 	// Points on the UnitGraph
 	LinkedList<Point> graphPoints = new LinkedList<>();
 
+	/**
+	 * Create a new HolonSwitch with the default name ("Switch"), a default
+	 * value of automatic handle and active status
+	 * 
+	 * @param ObjName
+	 *            String
+	 */
 	public HolonSwitch(String ObjName) {
 		super(ObjName);
 		setManualState(true);
@@ -37,6 +52,15 @@ public class HolonSwitch extends CpsObject {
 		setManualMode(false);
 	}
 
+	/**
+	 * Create a new HolonSwitch with user-defined name, a default value of
+	 * automatic handle and active status
+	 * 
+	 * @param ObjName
+	 *            String
+	 * @param obj
+	 *            String
+	 */
 	public HolonSwitch(String ObjName, String obj) {
 		super(ObjName);
 		super.setName(obj);
@@ -46,6 +70,11 @@ public class HolonSwitch extends CpsObject {
 		setManualMode(false);
 	}
 
+	/**
+	 * Create a copy of an existing HolonSwitch.
+	 * 
+	 * @param obj
+	 */
 	public HolonSwitch(CpsObject obj) {
 		super(obj);
 		super.setName(obj.getName());
@@ -55,6 +84,9 @@ public class HolonSwitch extends CpsObject {
 		setManualMode(false);
 	}
 
+	/**
+	 * Calculates the state of the Switch
+	 */
 	public void switchState() {
 		if (manualMode) {
 			if (this.manualActive == true) {
@@ -65,15 +97,27 @@ public class HolonSwitch extends CpsObject {
 			this.manualActive = !manualActive;
 		}
 	}
-	
-	public boolean getState(int timeStep){
-		if(manualMode){
+
+	/**
+	 * Getter for the status of the Switch at a given timestep
+	 * 
+	 * @param timeStep
+	 *            int
+	 * @return state value
+	 */
+	public boolean getState(int timeStep) {
+		if (manualMode) {
 			return this.manualActive;
 		} else {
 			return getActiveAt()[timeStep];
 		}
 	}
 
+	/**
+	 * Overall status of the switch (manual or automatic mode)
+	 * 
+	 * @return
+	 */
 	public boolean getState() {
 		if (manualMode) {
 			return this.manualActive;
@@ -83,16 +127,29 @@ public class HolonSwitch extends CpsObject {
 
 	}
 
+	/**
+	 * Change the state of the Switch to manual
+	 * 
+	 * @param state
+	 */
 	public void setManualState(boolean state) {
 		this.manualActive = state;
 		setImage();
 	}
 
+	/**
+	 * Set the state of the Switch to automatic
+	 * 
+	 * @param state
+	 */
 	public void setAutoState(boolean state) {
 		this.autoActive = state;
 		setImage();
 	}
 
+	/**
+	 * Set Image of the Switch
+	 */
 	private void setImage() {
 		if (manualMode) {
 			if (this.manualActive == false) {
@@ -110,6 +167,8 @@ public class HolonSwitch extends CpsObject {
 	}
 
 	/**
+	 * For automatic use only (throught the graph)
+	 * 
 	 * @return the Graph Points
 	 */
 	public LinkedList<Point> getGraphPoints() {
@@ -117,6 +176,8 @@ public class HolonSwitch extends CpsObject {
 	}
 
 	/**
+	 * Set the values of the switch in the graph (auto. mode only)
+	 * 
 	 * @param points,
 	 *            the Graph points
 	 */
@@ -125,17 +186,25 @@ public class HolonSwitch extends CpsObject {
 	}
 
 	/**
-	 * get the activeAt Array
+	 * All values of the graph for the selected Switch (only auto-Mode) get the
+	 * activeAt Array
 	 */
 	public boolean[] getActiveAt() {
 		return activeAt;
 	}
 
+	/**
+	 * Overall value of the Swtich (only manual-Mode)
+	 * 
+	 * @return
+	 */
 	public boolean getActiveManual() {
 		return this.manualActive;
 	}
 
 	/**
+	 * Set the value of the Switch
+	 * 
 	 * @param active,
 	 *            the default value
 	 */
@@ -145,10 +214,20 @@ public class HolonSwitch extends CpsObject {
 		}
 	}
 
+	/**
+	 * Set the overall value of the Switch (manual mode)
+	 * 
+	 * @param mode
+	 */
 	public void setManualMode(boolean mode) {
 		manualMode = mode;
 	}
 
+	/**
+	 * Get the value of the switch (manual mode)
+	 * 
+	 * @return
+	 */
 	public boolean getManualMode() {
 		return manualMode;
 	}

+ 22 - 5
src/classes/Position.java

@@ -1,16 +1,33 @@
 package classes;
 
+/**
+ * Coordinates of an Object on the canvas with a (int) x-coord and a (int)
+ * y-coord
+ * 
+ * @author Gruppe14
+ *
+ */
 public class Position {
 	public int x;
 	public int y;
-	
-	public Position(int x, int y){
+
+	/**
+	 * Constructor with an positive x and y coord on the canvas
+	 * 
+	 * @param x
+	 *            int
+	 * @param y
+	 *            int
+	 */
+	public Position(int x, int y) {
 		this.x = x;
 		this.y = y;
 	}
-	
-	//default Constructor
-	public Position(){
+
+	/**
+	 * Default constructor without defined position
+	 */
+	public Position() {
 		this.x = -1;
 		this.y = -1;
 	}

+ 14 - 8
src/classes/subNet.java

@@ -2,26 +2,32 @@ package classes;
 
 import java.util.ArrayList;
 
+/**
+ * The class "subNet" represents ....
+ * 
+ * @author Gruppe14
+ *
+ */
 public class subNet {
 	private ArrayList<HolonObject> subNetObjects;
 	private ArrayList<CpsEdge> subNetEdges;
 	private ArrayList<HolonSwitch> subNetSwitches;
-	
-	public subNet(ArrayList<HolonObject> objects, ArrayList<CpsEdge> edges, ArrayList<HolonSwitch> switches){
+
+	public subNet(ArrayList<HolonObject> objects, ArrayList<CpsEdge> edges, ArrayList<HolonSwitch> switches) {
 		subNetObjects = objects;
 		subNetEdges = edges;
 		subNetSwitches = switches;
 	}
-	
-	public ArrayList<HolonObject> getObjects(){
+
+	public ArrayList<HolonObject> getObjects() {
 		return subNetObjects;
 	}
-	
-	public ArrayList<CpsEdge> getEdges(){
+
+	public ArrayList<CpsEdge> getEdges() {
 		return subNetEdges;
 	}
-	
-	public ArrayList<HolonSwitch> getSwitches(){
+
+	public ArrayList<HolonSwitch> getSwitches() {
 		return subNetSwitches;
 	}
 }

+ 0 - 1
src/ui/view/MyCanvas.java

@@ -656,7 +656,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			e = new CpsEdge(n, tempCps, edgeCapacity);
 
 			controller.AddEdgeOnCanvas(e);
-			// System.out.println("node ID: " + n.getID());
 		}
 
 		// Wenn ein Node ohne Connections da ist