|
@@ -4,35 +4,54 @@ import java.awt.Point;
|
|
|
import java.util.LinkedList;
|
|
|
import ui.model.idCounterElem;
|
|
|
|
|
|
+/**
|
|
|
+ * The class "HolonElement" represents any possible element that can be added to
|
|
|
+ * a CpsObject (such as TV (consumer) or any energy source/producer)
|
|
|
+ *
|
|
|
+ * @author Gruppe14
|
|
|
+ *
|
|
|
+ */
|
|
|
public class HolonElement {
|
|
|
|
|
|
/* Name of the gadget */
|
|
|
- String eleName;
|
|
|
+ private String eleName;
|
|
|
/* Quantity */
|
|
|
- int amount;
|
|
|
+ private int amount;
|
|
|
/* Energy per gadget */
|
|
|
- float energy;
|
|
|
+ private float energy;
|
|
|
/* If the gadget is working xor not (true xor false) */
|
|
|
- boolean active;
|
|
|
+ private boolean active;
|
|
|
/* Total Energy */
|
|
|
- float totalEnergy;
|
|
|
+ private float totalEnergy;
|
|
|
/* Path of the image for the Obj. */
|
|
|
- String image;
|
|
|
+ private String image;
|
|
|
/* +: for Consumers and -: Producers */
|
|
|
- char sign;
|
|
|
+ private char sign;
|
|
|
/* Place where the Object is Stored */
|
|
|
- String sav;
|
|
|
+ private String sav;
|
|
|
/* Object where the Element is Stored */
|
|
|
- String obj;
|
|
|
- int id;
|
|
|
+ private String obj;
|
|
|
+ /* Unique Id of the Element */
|
|
|
+ private int id;
|
|
|
/*
|
|
|
* Energy at each point of the graph with 100 predefined points. At the
|
|
|
* beginning, it starts with all values at energy
|
|
|
*/
|
|
|
- float[] energyAt = new float[100];
|
|
|
+ private float[] energyAt = new float[100];
|
|
|
// Points on the UnitGraph
|
|
|
LinkedList<Point> graphPoints = new LinkedList<>();
|
|
|
|
|
|
+ /**
|
|
|
+ * Create a new HolonElement with a user-defined name, amount of the same
|
|
|
+ * element and energy per element
|
|
|
+ *
|
|
|
+ * @param eleName
|
|
|
+ * String
|
|
|
+ * @param amount
|
|
|
+ * int
|
|
|
+ * @param energy
|
|
|
+ * float
|
|
|
+ */
|
|
|
public HolonElement(String eleName, int amount, float energy) {
|
|
|
setEleName(eleName);
|
|
|
setAmount(amount);
|
|
@@ -40,9 +59,14 @@ public class HolonElement {
|
|
|
setActive(true);
|
|
|
setSign(energy);
|
|
|
setEnergyAt(energy);
|
|
|
- setId(idCounterElem.nextId());
|
|
|
+ // setId(idCounterElem.nextId());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Create a copy of the HolonElement given each one a new ID
|
|
|
+ *
|
|
|
+ * @param element
|
|
|
+ */
|
|
|
public HolonElement(HolonElement element) {
|
|
|
setEleName(element.getEleName());
|
|
|
setAmount(element.getAmount());
|
|
@@ -56,13 +80,17 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * get the EnergyAt Array
|
|
|
+ * Get the Array of energy (100 values)
|
|
|
+ *
|
|
|
+ * @return Array of floats
|
|
|
*/
|
|
|
public float[] getEnergyAt() {
|
|
|
return energyAt;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set energy to any value to the whole array
|
|
|
+ *
|
|
|
* @param energy,
|
|
|
* the value
|
|
|
*/
|
|
@@ -72,18 +100,30 @@ public class HolonElement {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Set energy to any value at a given position
|
|
|
+ *
|
|
|
+ * @param pos
|
|
|
+ * int
|
|
|
+ * @param energy
|
|
|
+ * float
|
|
|
+ */
|
|
|
public void setEnergyAt(int pos, float energy) {
|
|
|
this.energyAt[pos] = energy;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return the name
|
|
|
+ * Get the user-defined Name
|
|
|
+ *
|
|
|
+ * @return the name String
|
|
|
*/
|
|
|
public String getEleName() {
|
|
|
return eleName;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the name to any new name
|
|
|
+ *
|
|
|
* @param name
|
|
|
* the name to set
|
|
|
*/
|
|
@@ -92,13 +132,17 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return the amount
|
|
|
+ * Get the actual amount of Elements in the selected Object
|
|
|
+ *
|
|
|
+ * @return the amount int
|
|
|
*/
|
|
|
public int getAmount() {
|
|
|
return amount;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the amount of the Element in the selected Object
|
|
|
+ *
|
|
|
* @param amount
|
|
|
* the amount to set
|
|
|
*/
|
|
@@ -107,6 +151,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Get the energy value of the selected Element
|
|
|
+ *
|
|
|
* @return the energy
|
|
|
*/
|
|
|
public float getEnergy() {
|
|
@@ -114,6 +160,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the energy value of the selected Element
|
|
|
+ *
|
|
|
* @param energy
|
|
|
* the energy to set
|
|
|
*/
|
|
@@ -122,6 +170,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Get the Status of the Element (see description of variables)
|
|
|
+ *
|
|
|
* @return the active
|
|
|
*/
|
|
|
public boolean getActive() {
|
|
@@ -129,6 +179,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the Status of the Element (see description of variables)
|
|
|
+ *
|
|
|
* @param active
|
|
|
* the active to set
|
|
|
*/
|
|
@@ -137,6 +189,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Get Image path
|
|
|
+ *
|
|
|
* @return the image
|
|
|
*/
|
|
|
public String getImage() {
|
|
@@ -144,6 +198,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set Image path
|
|
|
+ *
|
|
|
* @param image
|
|
|
* the image to set
|
|
|
*/
|
|
@@ -163,12 +219,21 @@ public class HolonElement {
|
|
|
return totalEnergy;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Get the energy value at a selected time x
|
|
|
+ *
|
|
|
+ * @param x
|
|
|
+ * int
|
|
|
+ * @return energy value
|
|
|
+ */
|
|
|
public float getTotalEnergyAtTimeStep(int x) {
|
|
|
float result = ((float) amount) * energyAt[x];
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Get the symbol of the value (see variable description)
|
|
|
+ *
|
|
|
* @return the sign
|
|
|
*/
|
|
|
public char getSign() {
|
|
@@ -176,6 +241,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set symbol of the value
|
|
|
+ *
|
|
|
* @param energy
|
|
|
* the sign to set
|
|
|
*/
|
|
@@ -202,6 +269,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Get the actual object
|
|
|
+ *
|
|
|
* @return the obj
|
|
|
*/
|
|
|
public String getObj() {
|
|
@@ -209,6 +278,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the object to a new one
|
|
|
+ *
|
|
|
* @param obj
|
|
|
* the obj to set
|
|
|
*/
|
|
@@ -217,6 +288,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Get the points (values) in the graph
|
|
|
+ *
|
|
|
* @return the Graph Points
|
|
|
*/
|
|
|
public LinkedList<Point> getGraphPoints() {
|
|
@@ -224,6 +297,8 @@ public class HolonElement {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Set the points (values) in the graph
|
|
|
+ *
|
|
|
* @param points,
|
|
|
* the Graph points
|
|
|
*/
|
|
@@ -231,10 +306,20 @@ public class HolonElement {
|
|
|
this.graphPoints = points;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Set the ID of the HolonElement (one time only)
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
private void setId(int id) {
|
|
|
this.id = id;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Get the Id of the selected HolonElement
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public int getId() {
|
|
|
return id;
|
|
|
}
|