|
@@ -13,7 +13,7 @@ import java.util.LinkedList;
|
|
|
*
|
|
|
* @author Gruppe14
|
|
|
*/
|
|
|
-public class HolonElement {
|
|
|
+public class HolonElement implements IGraphedElement{
|
|
|
|
|
|
/* Points on the UnitGraph */
|
|
|
private LinkedList<Point> graphPoints;
|
|
@@ -48,7 +48,7 @@ public class HolonElement {
|
|
|
@Expose
|
|
|
private int id;
|
|
|
|
|
|
- private static final int DEFAULT_GRAPH_LENGTH=100;
|
|
|
+ //private static final int DEFAULT_GRAPH_LENGTH=100;
|
|
|
//private int graphLength=DEFAULT_GRAPH_LENGTH; Unimplementable due to former developer's dark magic.
|
|
|
|
|
|
/*
|
|
@@ -57,6 +57,9 @@ public class HolonElement {
|
|
|
* If switched to flexible, this represents the maximum of usable energy
|
|
|
*/
|
|
|
private float[] availableEnergyPerElementAt;
|
|
|
+
|
|
|
+ @Expose
|
|
|
+ private int localPeriod;
|
|
|
|
|
|
/**
|
|
|
* Create a new HolonElement with a user-defined name, amount of the same
|
|
@@ -79,8 +82,7 @@ public class HolonElement {
|
|
|
* same as standard constructor, but with already given id (so the counter is not increased twice)
|
|
|
*/
|
|
|
public HolonElement(String eleName, int amount, float energy, int id, Model model){
|
|
|
- //if(model!=null)graphLength=model.getGraphIterations();
|
|
|
- //if(graphLength==0)graphLength=DEFAULT_GRAPH_LENGTH;//This would work if the used HolonElements were actually made using a proper constructor.
|
|
|
+ setLocalPeriod(model.getGraphIterations());
|
|
|
setEleName(eleName);
|
|
|
setAmount(amount);
|
|
|
setEnergyPerElement(energy);
|
|
@@ -101,6 +103,7 @@ public class HolonElement {
|
|
|
public HolonElement(HolonElement element) {
|
|
|
//graphLength=element.graphLength;//Should I add a getter?
|
|
|
setEleName(element.getEleName());
|
|
|
+ setLocalPeriod(element.getLocalPeriod());
|
|
|
setAmount(element.getAmount());
|
|
|
setEnergyPerElement(element.getEnergyPerElement());
|
|
|
setActive(element.isActive());
|
|
@@ -156,7 +159,7 @@ public class HolonElement {
|
|
|
* Get the energyPerElement currently available
|
|
|
*/
|
|
|
public float getAvailableEnergyAt(int timestep) {
|
|
|
- return this.availableEnergyPerElementAt[timestep%DEFAULT_GRAPH_LENGTH];//TODO:use an attribute here
|
|
|
+ return this.availableEnergyPerElementAt[timestep%localPeriod];//TODO:use an attribute here
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -264,7 +267,7 @@ public class HolonElement {
|
|
|
if (flexible) {
|
|
|
return ((float) amount) * energyPerElement;
|
|
|
} else {
|
|
|
- return ((float) amount) * availableEnergyPerElementAt[x%DEFAULT_GRAPH_LENGTH];//TODO: use an attribute
|
|
|
+ return ((float) amount) * availableEnergyPerElementAt[x%localPeriod];//TODO: use an attribute
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -397,4 +400,15 @@ public class HolonElement {
|
|
|
|
|
|
return sb.toString();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setLocalPeriod(int period) {
|
|
|
+ localPeriod=period;
|
|
|
+ availableEnergyPerElementAt=new float[period];//TODO do they get rewritten?
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getLocalPeriod() {
|
|
|
+ return localPeriod;
|
|
|
+ }
|
|
|
}
|