|
@@ -6,7 +6,6 @@ import interfaces.GraphEditable;
|
|
|
import interfaces.IGraphedElement;
|
|
|
import ui.model.Model;
|
|
|
import ui.view.IndexTranslator;
|
|
|
-import ui.view.UnitGraph;
|
|
|
|
|
|
import java.awt.*;
|
|
|
import java.awt.geom.Point2D;
|
|
@@ -26,9 +25,8 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
* Represent the Graph
|
|
|
* the X component from a Point is period from 0..1
|
|
|
* the Y component from a Point is the percentage from 0..1
|
|
|
- * currently saved in int -> TODO serelized float point class
|
|
|
* */
|
|
|
- private LinkedList<Point2D.Double> testGraphPoints;
|
|
|
+ private LinkedList<Point2D.Double> graphPoints;
|
|
|
/** Name of the object, e.g. House, 1 */
|
|
|
@Expose
|
|
|
private String objName;
|
|
@@ -100,8 +98,8 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
setEnergyPerElement(energy);
|
|
|
setActive(true);
|
|
|
System.out.println("heiNEW");
|
|
|
- setTestGraphPoints(new LinkedList<>());
|
|
|
- initTestGraphPoints(1);
|
|
|
+ setGraphPoints(new LinkedList<>());
|
|
|
+ initGraphPoints();
|
|
|
sampleGraph();
|
|
|
setId(id);
|
|
|
setFlexibleEnergyAvailable(0);
|
|
@@ -121,13 +119,10 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
setAmount(element.getAmount());
|
|
|
setEnergyPerElement(element.getEnergyPerElement());
|
|
|
setActive(element.isActive());
|
|
|
- setTestGraphPoints(new LinkedList<>());
|
|
|
+ setGraphPoints(new LinkedList<>());
|
|
|
System.out.println("hei");
|
|
|
- for (Point2D.Double p : element.getTestGraphPoints()) {
|
|
|
- this.testGraphPoints.add(new Point2D.Double(p.getX(), p.getY()));
|
|
|
- }
|
|
|
- for (Point2D.Double p : getTestGraphPoints()) {
|
|
|
- System.out.println(testGraphPoints);
|
|
|
+ for (Point2D.Double p : element.getGraphPoints()) {
|
|
|
+ this.graphPoints.add(new Point2D.Double(p.getX(), p.getY()));
|
|
|
}
|
|
|
sampleGraph();
|
|
|
setSaving(null);
|
|
@@ -145,18 +140,6 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * Set energyPerElement to any value to the whole array.
|
|
|
- *
|
|
|
- * @param energy the value
|
|
|
- */
|
|
|
- public void setAvailableEnergyPerElementAt(float energy) {
|
|
|
- this.curveSample = new float[100];
|
|
|
- for (int i = 0; i < curveSample.length; i++) {
|
|
|
- this.curveSample[i] = energy;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Get the energyPerElement currently(at given time step) available
|
|
|
*/
|
|
@@ -165,16 +148,6 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
return amount * energyPerElement * this.curveSample[IndexTranslator.getEffectiveIndex(this, timestep)];
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Set energyPerElement to any value at a given position.
|
|
|
- *
|
|
|
- * @param pos int
|
|
|
- * @param energyPerElement float
|
|
|
- */
|
|
|
- public void setAvailableEnergyPerElementAt(int pos, float energyPerElement) {
|
|
|
- this.curveSample[pos] = energyPerElement;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Get the user-defined Name.
|
|
|
*
|
|
@@ -291,26 +264,6 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * Get the points (values) in the graph.
|
|
|
- *
|
|
|
- * @return the Graph Points
|
|
|
- */
|
|
|
- public LinkedList<Point> getGraphPoints() {
|
|
|
- return null;
|
|
|
- //TODO DELETE
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Set the points (values) in the graph.
|
|
|
- *
|
|
|
- * @param points the Graph points
|
|
|
- */
|
|
|
- public void setGraphPoints(LinkedList<Point> points) {
|
|
|
- //TODO DELETE
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Get the flexibleEnergyAvailable of an element
|
|
|
*/
|
|
@@ -321,8 +274,8 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
/**
|
|
|
* Set the flexibleEnergyAvailable of an element
|
|
|
*/
|
|
|
- public void setFlexibleEnergyAvailable(float f) {
|
|
|
- this.flexibleEnergyAvailable = f;
|
|
|
+ public void setFlexibleEnergyAvailable(float energy) {
|
|
|
+ this.flexibleEnergyAvailable = energy;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -422,20 +375,19 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
this.stretch=stretch;
|
|
|
}
|
|
|
|
|
|
-//--> Test Area --> TODO Neue float Point Klasse
|
|
|
- public void initTestGraphPoints(int percentage)
|
|
|
+ public void initGraphPoints()
|
|
|
{
|
|
|
- testGraphPoints.clear();
|
|
|
- testGraphPoints.add(new Point2D.Double(0,percentage));
|
|
|
- testGraphPoints.add(new Point2D.Double(1,percentage));
|
|
|
+ graphPoints.clear();
|
|
|
+ graphPoints.add(new Point2D.Double(0,1.0));
|
|
|
+ graphPoints.add(new Point2D.Double(1,1.0));
|
|
|
}
|
|
|
- public LinkedList<Point2D.Double> getTestGraphPoints() {
|
|
|
- return testGraphPoints;
|
|
|
+ public LinkedList<Point2D.Double> getGraphPoints() {
|
|
|
+ return graphPoints;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public void setTestGraphPoints(LinkedList<Point2D.Double> testGraphPoints) {
|
|
|
- this.testGraphPoints = testGraphPoints;
|
|
|
+ public void setGraphPoints(LinkedList<Point2D.Double> testGraphPoints) {
|
|
|
+ this.graphPoints = testGraphPoints;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -447,7 +399,7 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
|
|
|
@Override
|
|
|
public LinkedList<Double> getStateGraph() {
|
|
|
- return getTestGraphPoints();
|
|
|
+ return getGraphPoints();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -479,7 +431,7 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
|
|
|
private float[] sampleGraph(int sampleLength)
|
|
|
{
|
|
|
- ListIterator<Point2D.Double> iter = this.testGraphPoints.listIterator();
|
|
|
+ ListIterator<Point2D.Double> iter = this.graphPoints.listIterator();
|
|
|
Point.Double before = iter.next();
|
|
|
Point.Double after = iter.next();
|
|
|
float [] sampleCurve = new float[sampleLength];
|
|
@@ -504,4 +456,11 @@ public class HolonElement implements IGraphedElement, GraphEditable{
|
|
|
public void sampleGraph() {
|
|
|
curveSample = sampleGraph(100);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void reset() {
|
|
|
+ initGraphPoints();
|
|
|
+ sampleGraph();
|
|
|
+ }
|
|
|
}
|