|
@@ -11,6 +11,7 @@ import java.awt.event.MouseEvent;
|
|
|
import java.awt.event.MouseListener;
|
|
|
import java.awt.event.MouseMotionListener;
|
|
|
import java.awt.geom.CubicCurve2D;
|
|
|
+import java.awt.geom.GeneralPath;
|
|
|
import java.awt.geom.Line2D;
|
|
|
import java.util.LinkedList;
|
|
|
import java.awt.Point;
|
|
@@ -44,6 +45,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
private HolonElement tempElement;
|
|
|
private Model model;
|
|
|
private Control controller;
|
|
|
+ GeneralPath graphCurve = new GeneralPath();
|
|
|
|
|
|
private boolean pointDrag = false;
|
|
|
private boolean init = false;
|
|
@@ -56,9 +58,9 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
this.controller = control;
|
|
|
this.model = model;
|
|
|
this.ITERATIONS = model.getIterations();
|
|
|
-
|
|
|
+
|
|
|
this.pointList = new LinkedList<>();
|
|
|
-
|
|
|
+
|
|
|
this.addMouseListener(this);
|
|
|
this.addMouseMotionListener(this);
|
|
|
this.addComponentListener(this);
|
|
@@ -77,6 +79,8 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
g2.setRenderingHints(rh);
|
|
|
g2.setStroke(new BasicStroke(1));
|
|
|
|
|
|
+ graphCurve.reset();
|
|
|
+
|
|
|
if (arrayOfValue != null) {
|
|
|
for (int i = 0; i < arrayOfValue.length; i++) {
|
|
|
arrayOfValue[i] = convertToValueY(getYValueAt((int) (i * width / (ITERATIONS - 1))));
|
|
@@ -94,14 +98,15 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
g2.drawLine(0, (i) * this.getHeight() / (ITERATIONS - 1), this.getWidth(),
|
|
|
(i) * this.getHeight() / (ITERATIONS - 1));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Draw the Lines
|
|
|
g2.setColor(Color.BLACK);
|
|
|
for (int i = 0; i < pointList.size() - 1; i++) {
|
|
|
c = buildCurve(pointList.get(i), pointList.get(i + 1));
|
|
|
- g2.draw(c);
|
|
|
+ graphCurve.append(c, true);
|
|
|
}
|
|
|
-
|
|
|
+ g2.draw(graphCurve);
|
|
|
+
|
|
|
// Draw the Points
|
|
|
g2.setColor(Color.BLUE);
|
|
|
for (int i = 0; i < pointList.size() - 0; i++) {
|