|
@@ -52,6 +52,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
private HolonSwitch tempSwitch;
|
|
private HolonSwitch tempSwitch;
|
|
private Model model;
|
|
private Model model;
|
|
private Control controller;
|
|
private Control controller;
|
|
|
|
+ private Line2D.Double line = null;
|
|
GeneralPath graphCurve = new GeneralPath();
|
|
GeneralPath graphCurve = new GeneralPath();
|
|
|
|
|
|
private boolean pointDrag = false;
|
|
private boolean pointDrag = false;
|
|
@@ -119,17 +120,13 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
(int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2), (int) recSize.getX(),
|
|
(int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2), (int) recSize.getX(),
|
|
(int) recSize.getY());
|
|
(int) recSize.getY());
|
|
}
|
|
}
|
|
- }
|
|
|
|
- // Iteration Line
|
|
|
|
- g2.setColor(Color.BLUE);
|
|
|
|
- g2.setStroke(new BasicStroke(1));
|
|
|
|
- g2.drawLine((model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), 0,
|
|
|
|
- (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), this.getHeight());
|
|
|
|
- // Iteration Value
|
|
|
|
- if (arrayOfFloats != null) {
|
|
|
|
- g2.drawString("" + arrayOfFloats[model.getCurIteration()],
|
|
|
|
- (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
|
|
|
|
- this.getHeight() - 10);
|
|
|
|
|
|
+
|
|
|
|
+ // Iteration Value
|
|
|
|
+ if (arrayOfFloats != null) {
|
|
|
|
+ g2.drawString("" + arrayOfFloats[model.getCurIteration()],
|
|
|
|
+ (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
|
|
|
|
+ this.getHeight() - 10);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
* // Actual Iteration Point Visualization g2.setColor(Color.RED);
|
|
* // Actual Iteration Point Visualization g2.setColor(Color.RED);
|
|
@@ -141,8 +138,40 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
* } }
|
|
* } }
|
|
*/
|
|
*/
|
|
} else if (isSwitch) {
|
|
} else if (isSwitch) {
|
|
|
|
+ if (arrayOfBooleans != null) {
|
|
|
|
+ // array fillen
|
|
|
|
+ fillArrayofBooleans();
|
|
|
|
|
|
|
|
+ // Draw the Lines
|
|
|
|
+ g2.setStroke(new BasicStroke(2));
|
|
|
|
+ g2.setColor(Color.BLACK);
|
|
|
|
+ for (int i = 0; i < pointList.size() - 1; i++) {
|
|
|
|
+ line = new Line2D.Double(pointList.get(i).getX()*scaleX, pointList.get(i).getY()*scaleY, pointList.get(i+1).getX()*scaleX,pointList.get(i+1).getY()*scaleY);
|
|
|
|
+ graphCurve.append(line, true);
|
|
|
|
+ }
|
|
|
|
+ g2.draw(graphCurve);
|
|
|
|
+
|
|
|
|
+ // Draw the Points
|
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
|
+ for (int i = 0; i < pointList.size() - 0; i++) {
|
|
|
|
+ g2.fillOval((int) (pointList.get(i).getX() * scaleX - recSize.getX() / 2),
|
|
|
|
+ (int) (pointList.get(i).getY() * scaleY - recSize.getY() / 2), (int) recSize.getX(),
|
|
|
|
+ (int) recSize.getY());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Iteration Value
|
|
|
|
+ if (arrayOfFloats != null) {
|
|
|
|
+ g2.drawString("" + arrayOfFloats[model.getCurIteration()],
|
|
|
|
+ (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1) + 2,
|
|
|
|
+ this.getHeight() - 10);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ // Iteration Line
|
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
|
+ g2.setStroke(new BasicStroke(1));
|
|
|
|
+ g2.drawLine((model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), 0,
|
|
|
|
+ (model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), this.getHeight());
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -385,7 +414,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
}
|
|
}
|
|
repaint();
|
|
repaint();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Visualize the HolonElement on the Graph
|
|
* Visualize the HolonElement on the Graph
|
|
*
|
|
*
|
|
@@ -400,8 +429,8 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
isElement = false;
|
|
isElement = false;
|
|
// First time clicked on the Element
|
|
// First time clicked on the Element
|
|
if (pointList.isEmpty()) {
|
|
if (pointList.isEmpty()) {
|
|
- pointList.addFirst(new Point(0, 0));
|
|
|
|
- pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
|
|
|
|
|
|
+ pointList.addFirst(new Point(0, (int) (this.getHeight()/scaleY)));
|
|
|
|
+ pointList.addLast(new Point((int) (this.getWidth() / scaleX), (int) (this.getHeight()/scaleY)));
|
|
}
|
|
}
|
|
repaint();
|
|
repaint();
|
|
}
|
|
}
|
|
@@ -437,6 +466,15 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
return c;
|
|
return c;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Fills the Arrays with booleans
|
|
|
|
+ */
|
|
|
|
+ public void fillArrayofBooleans() {
|
|
|
|
+ for (int i = 0; i < arrayOfBooleans.length; i++) {
|
|
|
|
+ arrayOfBooleans[i] = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Fills the Arrays of each HolonElement
|
|
* Fills the Arrays of each HolonElement
|
|
*/
|
|
*/
|