|
@@ -5,7 +5,6 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
import ui.controller.MultiPurposeController;
|
|
|
-import ui.model.idCounter;
|
|
|
|
|
|
/**
|
|
|
* The class HolonObject represents any Object on the system which capability of
|
|
@@ -24,7 +23,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
/* Array of all consumers */
|
|
|
private ArrayList<HolonElement> elements;
|
|
|
/* Array of all Indices of Elements */
|
|
|
- private HashMap<String, Integer> EleIdx;
|
|
|
+ private HashMap<String, Integer> eleIdx;
|
|
|
/* Total of consumption */
|
|
|
private float currentEnergy;
|
|
|
|
|
@@ -36,32 +35,19 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
/**
|
|
|
* Constructor Set by default the name of the object equals to the category
|
|
|
* name, until the user changes it.
|
|
|
- */
|
|
|
- public HolonObject(String ObjName) {
|
|
|
- super(ObjName);
|
|
|
- setElements(new ArrayList<HolonElement>());
|
|
|
- setEleIdx(new HashMap<String, Integer>());
|
|
|
- setState();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Constructor with a user-defined name
|
|
|
*
|
|
|
- * @param ObjName
|
|
|
- * Type of Object
|
|
|
- * @param obj
|
|
|
- * user-defined name
|
|
|
+ * @param objName
|
|
|
+ * name of the Object
|
|
|
*/
|
|
|
- public HolonObject(String ObjName, String obj) {
|
|
|
- super(ObjName);
|
|
|
- super.setName(obj);
|
|
|
+ public HolonObject(String objName) {
|
|
|
+ super(objName);
|
|
|
setElements(new ArrayList<HolonElement>());
|
|
|
setEleIdx(new HashMap<String, Integer>());
|
|
|
setState();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Contructor of a copy of an Object
|
|
|
+ * Contructor of a copy of an Object.
|
|
|
*
|
|
|
* @param obj
|
|
|
* object to be copied
|
|
@@ -74,8 +60,8 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * sets the State, wether object is a producer, zero Energy, supplied or not
|
|
|
- * supplied
|
|
|
+ * sets the State, wether object is a producer, zero Energy, supplied or
|
|
|
+ * not.
|
|
|
*/
|
|
|
public void setState() {
|
|
|
if (getCurrentEnergy() > 0) {
|
|
@@ -97,7 +83,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Getter for all Elements in the HolonObject
|
|
|
+ * Getter for all Elements in the HolonObject.
|
|
|
*
|
|
|
* @return the elements ArrayList
|
|
|
*/
|
|
@@ -106,7 +92,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Set a new ArrayList with HolonElements into the HolonObject
|
|
|
+ * Set a new ArrayList with HolonElements into the HolonObject.
|
|
|
*
|
|
|
* @param elements
|
|
|
* the elements to set
|
|
@@ -115,13 +101,19 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
this.elements = elements;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * add an Element to the Object.
|
|
|
+ *
|
|
|
+ * @param element
|
|
|
+ * the Element to add
|
|
|
+ */
|
|
|
public void addElements(HolonElement element) {
|
|
|
elements.add(element);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Doesn't take into account which timestep is watched, calculates the max
|
|
|
- * values
|
|
|
+ * values.
|
|
|
*
|
|
|
* @return the currentEnergy
|
|
|
*/
|
|
@@ -137,7 +129,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Getter for the current energy at a given timestep
|
|
|
+ * Getter for the current energy at a given timestep.
|
|
|
*
|
|
|
* @param x
|
|
|
* timestep
|
|
@@ -155,7 +147,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * deletes Element at a given index
|
|
|
+ * deletes Element at a given index.
|
|
|
*
|
|
|
* @param idx
|
|
|
* index
|
|
@@ -165,7 +157,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * String of all consumers in this HolonObject
|
|
|
+ * String of all consumers in this HolonObject.
|
|
|
*
|
|
|
* @return all the names of this HolonObject separated by "," each object
|
|
|
*/
|
|
@@ -182,29 +174,30 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Getter index of all elements in the HolonObject
|
|
|
+ * Getter index of all elements in the HolonObject.
|
|
|
*
|
|
|
* @return the eleIdx
|
|
|
*/
|
|
|
public HashMap<String, Integer> getEleIdx() {
|
|
|
- return EleIdx;
|
|
|
+ return eleIdx;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Set the indexes of all elements
|
|
|
+ * Set the indexes of all elements.
|
|
|
*
|
|
|
* @param eleIdx
|
|
|
* the eleIdx to set
|
|
|
*/
|
|
|
public void setEleIdx(HashMap<String, Integer> eleIdx) {
|
|
|
- EleIdx = eleIdx;
|
|
|
+ this.eleIdx = eleIdx;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Copy all Elements into a New Array
|
|
|
+ * Copy all Elements into a New Array.
|
|
|
*
|
|
|
* @param arr
|
|
|
- * @return
|
|
|
+ * to copy
|
|
|
+ * @return the copy of arr
|
|
|
*/
|
|
|
public ArrayList<HolonElement> copyElements(ArrayList<HolonElement> arr) {
|
|
|
ArrayList<HolonElement> newArr = new ArrayList<>();
|
|
@@ -215,23 +208,23 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Get the state of the Object
|
|
|
+ * Get the state of the Object.
|
|
|
*
|
|
|
- * @return state
|
|
|
+ * @return state the State of the Element
|
|
|
*/
|
|
|
public int getState() {
|
|
|
return this.state;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Set the state of the Object
|
|
|
+ * Set the state of the Object.
|
|
|
*
|
|
|
- * @param supplied
|
|
|
+ * @param state
|
|
|
* boolean if the Object is fully supplied
|
|
|
*/
|
|
|
- public void setState(int st) {
|
|
|
- this.state = st;
|
|
|
- switch (st) {
|
|
|
+ public void setState(int state) {
|
|
|
+ this.state = state;
|
|
|
+ switch (state) {
|
|
|
case 0:
|
|
|
stateColor = Color.WHITE;
|
|
|
break;
|
|
@@ -254,7 +247,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Search for the element with the name
|
|
|
+ * Search for the element with the name.
|
|
|
*
|
|
|
* @param name
|
|
|
* name of the object to be searched
|
|
@@ -271,7 +264,7 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Search for the element with the id
|
|
|
+ * Search for the element with the id.
|
|
|
*
|
|
|
* @param id
|
|
|
* id of the element to be founded
|
|
@@ -288,9 +281,11 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Check if Partially Supplied.
|
|
|
*
|
|
|
* @param x
|
|
|
- * @return
|
|
|
+ * current Iteration
|
|
|
+ * @return boolean is partially supplied
|
|
|
*/
|
|
|
public boolean checkIfPartiallySupplied(int x) {
|
|
|
if (getElements().size() == 0) {
|
|
@@ -318,10 +313,21 @@ public class HolonObject extends AbstractCpsObject {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Set the State Color.
|
|
|
+ *
|
|
|
+ * @param color
|
|
|
+ * the Color
|
|
|
+ */
|
|
|
public void setColor(Color color) {
|
|
|
stateColor = color;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Get the Color.
|
|
|
+ *
|
|
|
+ * @return stateColor the Color
|
|
|
+ */
|
|
|
public Color getColor() {
|
|
|
return stateColor;
|
|
|
}
|