|
@@ -2,6 +2,7 @@ package ui.view;
|
|
|
|
|
|
import classes.*;
|
|
import classes.*;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
|
|
+import ui.controller.SingletonControl;
|
|
import ui.model.Model;
|
|
import ui.model.Model;
|
|
|
|
|
|
import javax.swing.*;
|
|
import javax.swing.*;
|
|
@@ -104,6 +105,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
}
|
|
}
|
|
g2.drawLine(border, this.getHeight() - border, this.getWidth() - border, this.getHeight() - border);
|
|
g2.drawLine(border, this.getHeight() - border, this.getWidth() - border, this.getHeight() - border);
|
|
|
|
|
|
|
|
+ int effectiveX=getEffectiveIndex(current, model.getCurIteration());
|
|
|
|
+
|
|
if (isElement) {
|
|
if (isElement) {
|
|
// fill array with values from the pointList in a HolonElement
|
|
// fill array with values from the pointList in a HolonElement
|
|
fillArrayofValue();
|
|
fillArrayofValue();
|
|
@@ -131,17 +134,17 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
|
|
|
|
// Iteration Value
|
|
// Iteration Value
|
|
//TODO: added function getGraphIterations see if it works
|
|
//TODO: added function getGraphIterations see if it works
|
|
- textWidth = g.getFontMetrics().stringWidth("" + arrayOfFloats[model.getCurIteration()%model.getGraphIterations()]) + 2;
|
|
|
|
|
|
+ textWidth = g.getFontMetrics().stringWidth("" + arrayOfFloats[effectiveX]) + 2;
|
|
if (textWidth
|
|
if (textWidth
|
|
- + (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1) + 2
|
|
|
|
|
|
+ + (effectiveX) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1) + 2
|
|
+ border <= this.getWidth()) {
|
|
+ border <= this.getWidth()) {
|
|
- g2.drawString("" + arrayOfFloats[model.getCurIteration()%model.getGraphIterations()],
|
|
|
|
- (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
|
|
|
|
|
|
+ g2.drawString("" + arrayOfFloats[effectiveX],
|
|
|
|
+ (effectiveX) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
|
|
+ 2 + border,
|
|
+ 2 + border,
|
|
this.getHeight() - 10);
|
|
this.getHeight() - 10);
|
|
} else {
|
|
} else {
|
|
- g2.drawString("" + arrayOfFloats[model.getCurIteration()%model.getGraphIterations()],
|
|
|
|
- (model.getCurIteration()%model.getGraphIterations()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
|
|
|
|
|
|
+ g2.drawString("" + arrayOfFloats[effectiveX],
|
|
|
|
+ (effectiveX) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
|
|
+ border - textWidth,
|
|
+ border - textWidth,
|
|
this.getHeight() - 10);
|
|
this.getHeight() - 10);
|
|
}
|
|
}
|
|
@@ -215,17 +218,17 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
|
|
|
|
// Iteration Value
|
|
// Iteration Value
|
|
g2.setColor(Color.BLUE);
|
|
g2.setColor(Color.BLUE);
|
|
- textWidth = g.getFontMetrics().stringWidth("" + arrayOfBooleans[model.getCurIteration()]) + 2;
|
|
|
|
|
|
+ textWidth = g.getFontMetrics().stringWidth("" + arrayOfBooleans[effectiveX]) + 2;
|
|
if (textWidth
|
|
if (textWidth
|
|
- + (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1) + 2
|
|
|
|
|
|
+ + (effectiveX) * (this.getWidth() - (border * 2)) / (/*model.getIterations()*/100 - 1) + 2
|
|
+ border <= this.getWidth()) {
|
|
+ border <= this.getWidth()) {
|
|
- g2.drawString("" + arrayOfBooleans[model.getCurIteration()],
|
|
|
|
- (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
|
|
|
|
|
|
+ g2.drawString("" + arrayOfBooleans[effectiveX],
|
|
|
|
+ (effectiveX) * (this.getWidth() - (border * 2)) / (/*model.getIterations()*/100 - 1)
|
|
+ 2 + border,
|
|
+ 2 + border,
|
|
this.getHeight() - 10);
|
|
this.getHeight() - 10);
|
|
} else {
|
|
} else {
|
|
- g2.drawString("" + arrayOfBooleans[model.getCurIteration()],
|
|
|
|
- (model.getCurIteration()) * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
|
|
|
|
|
|
+ g2.drawString("" + arrayOfBooleans[effectiveX],
|
|
|
|
+ (effectiveX) * (this.getWidth() - (border * 2)) / (/*model.getIterations()*/100 - 1)
|
|
+ border - textWidth,
|
|
+ border - textWidth,
|
|
this.getHeight() - 10);
|
|
this.getHeight() - 10);
|
|
}
|
|
}
|
|
@@ -237,7 +240,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
int i;
|
|
int i;
|
|
- for (i = 0; (i * (this.getWidth() - (border * 2)) / (model.getIterations() - 1)
|
|
|
|
|
|
+ for (i = 0; (i * (this.getWidth() - (border * 2)) / (/*model.getIterations()*/100 - 1)
|
|
+ border < getMousePosition().getX()); i++) {
|
|
+ border < getMousePosition().getX()); i++) {
|
|
}
|
|
}
|
|
dragInformation = "" + i;
|
|
dragInformation = "" + i;
|
|
@@ -255,15 +258,15 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // Iteration Line
|
|
|
|
|
|
+ // Iteration Line TODO: repeat
|
|
g2.setColor(Color.BLUE);
|
|
g2.setColor(Color.BLUE);
|
|
g2.setStroke(new BasicStroke(1));
|
|
g2.setStroke(new BasicStroke(1));
|
|
- g2.drawLine(border + (model.getCurIteration()) * (this.getWidth() - border * 2) / (model.getIterations() - 1),
|
|
|
|
- 0, border + (model.getCurIteration()) * (this.getWidth() - border * 2) / (model.getIterations() - 1),
|
|
|
|
|
|
+ g2.drawLine(border + (effectiveX) * (this.getWidth() - border * 2) / /*(model.getIterations() - 1)*/100-1,
|
|
|
|
+ 0, border + (effectiveX) * (this.getWidth() - border * 2) / /*(model.getIterations() - 1)*/100-1,
|
|
this.getHeight());
|
|
this.getHeight());
|
|
|
|
|
|
// algorithmus
|
|
// algorithmus
|
|
- controller.calculateStateForTimeStep(model.getCurIteration());
|
|
|
|
|
|
+ controller.calculateStateForTimeStep(effectiveX);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -603,6 +606,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
public void repaintWithNewElement(ArrayList<HolonElement> selectedElement) {
|
|
public void repaintWithNewElement(ArrayList<HolonElement> selectedElement) {
|
|
arrayOfFloats = selectedElement.get(selectedElement.size() - 1).getAvailableEnergyPerElementAt();
|
|
arrayOfFloats = selectedElement.get(selectedElement.size() - 1).getAvailableEnergyPerElementAt();
|
|
current = selectedElement.get(selectedElement.size()-1);
|
|
current = selectedElement.get(selectedElement.size()-1);
|
|
|
|
+ tempElements=selectedElement;
|
|
pointList = selectedElement.get(selectedElement.size() - 1).getGraphPoints();
|
|
pointList = selectedElement.get(selectedElement.size() - 1).getGraphPoints();
|
|
isSwitch = false;
|
|
isSwitch = false;
|
|
isElement = true;
|
|
isElement = true;
|
|
@@ -622,7 +626,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
*/
|
|
*/
|
|
public void repaintWithNewSwitch(HolonSwitch s) {
|
|
public void repaintWithNewSwitch(HolonSwitch s) {
|
|
current=s;
|
|
current=s;
|
|
- arrayOfBooleans = s.getActiveAt();
|
|
|
|
|
|
+ arrayOfBooleans = s.getValueArray();
|
|
pointList = s.getGraphPoints();
|
|
pointList = s.getGraphPoints();
|
|
isSwitch = true;
|
|
isSwitch = true;
|
|
isElement = false;
|
|
isElement = false;
|
|
@@ -856,4 +860,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
if(current!=null)return current.getLocalPeriod();
|
|
if(current!=null)return current.getLocalPeriod();
|
|
else return model.getGraphIterations();//TODO: maybe rename
|
|
else return model.getGraphIterations();//TODO: maybe rename
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static int getEffectiveIndex(IGraphedElement e, int timeStep){
|
|
|
|
+ Model m=SingletonControl.getInstance().getControl().getModel();
|
|
|
|
+ if(e.isStretching())return timeStep*100/m.getIterations();
|
|
|
|
+ else return timeStep%e.getLocalPeriod()*100/e.getLocalPeriod();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static int getEffectiveIndex(IGraphedElement e){
|
|
|
|
+ return getEffectiveIndex(e,SingletonControl.getInstance().getControl().getModel().getCurIteration());
|
|
|
|
+ }
|
|
}
|
|
}
|