|
@@ -81,10 +81,6 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
|
|
|
graphCurve.reset();
|
|
graphCurve.reset();
|
|
|
|
|
|
- if (arrayOfValue != null) {
|
|
|
|
- fillArrayofValue();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Draw the Vertical Lines
|
|
// Draw the Vertical Lines
|
|
g2.setColor(new Color(240, 240, 240));
|
|
g2.setColor(new Color(240, 240, 240));
|
|
for (int i = 0; i < model.getIterations(); i++) {
|
|
for (int i = 0; i < model.getIterations(); i++) {
|
|
@@ -97,22 +93,28 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
(i) * this.getHeight() / (model.getIterations() - 1));
|
|
(i) * this.getHeight() / (model.getIterations() - 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));
|
|
|
|
- graphCurve.append(c, true);
|
|
|
|
- }
|
|
|
|
- g2.draw(graphCurve);
|
|
|
|
|
|
+ if (arrayOfValue != null) {
|
|
|
|
+ //array fillen
|
|
|
|
+ fillArrayofValue();
|
|
|
|
|
|
- // 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());
|
|
|
|
|
|
+ // 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));
|
|
|
|
+ graphCurve.append(c, 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 Line
|
|
// Iteration Line
|
|
|
|
+ g2.setColor(Color.BLUE);
|
|
g2.drawLine((model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), 0,
|
|
g2.drawLine((model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), 0,
|
|
(model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), this.getHeight());
|
|
(model.getCurIteration()) * this.getWidth() / (model.getIterations() - 1), this.getHeight());
|
|
// Iteration Value
|
|
// Iteration Value
|
|
@@ -158,9 +160,10 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
x = tempP.getX();
|
|
x = tempP.getX();
|
|
}
|
|
}
|
|
tempP.setLocation(x, y);
|
|
tempP.setLocation(x, y);
|
|
|
|
+ repaint();
|
|
}
|
|
}
|
|
|
|
|
|
- repaint();
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -193,39 +196,41 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
|
|
|
// Click on Point
|
|
// Click on Point
|
|
tempP = null;
|
|
tempP = null;
|
|
- for (Point p : pointList) {
|
|
|
|
- if (x >= p.getX() - recSize.getX() / 2 && y >= p.getY() - recSize.getY() / 2
|
|
|
|
- && x <= p.getX() + recSize.getX() / 2 && y <= p.getY() * scaleY + recSize.getY() / 2) {
|
|
|
|
- if (e.getButton() == MouseEvent.BUTTON3) {
|
|
|
|
- tempP = p;
|
|
|
|
- deletePoint = true;
|
|
|
|
- } else {
|
|
|
|
- pointDrag = true;
|
|
|
|
- tempP = p;
|
|
|
|
|
|
+ if (pointList != null) {
|
|
|
|
+ for (Point p : pointList) {
|
|
|
|
+ if (x >= p.getX() - recSize.getX() / 2 && y >= p.getY() - recSize.getY() / 2
|
|
|
|
+ && x <= p.getX() + recSize.getX() / 2 && y <= p.getY() * scaleY + recSize.getY() / 2) {
|
|
|
|
+ if (e.getButton() == MouseEvent.BUTTON3) {
|
|
|
|
+ tempP = p;
|
|
|
|
+ deletePoint = true;
|
|
|
|
+ } else {
|
|
|
|
+ pointDrag = true;
|
|
|
|
+ tempP = p;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (!pointDrag && e.getButton() != MouseEvent.BUTTON3 && e.getX() != 0
|
|
|
|
- && e.getX() != this.getWidth() / scaleX) {
|
|
|
|
- for (int i = 0; i < pointList.size(); i++) {
|
|
|
|
- if (x < pointList.get(i).getX() && !added) {
|
|
|
|
- if (e.getY() <= 0) {
|
|
|
|
- pointList.add(i, new Point((int) (x), (int) (0 / scaleY)));
|
|
|
|
- } else {
|
|
|
|
- pointList.add(i, new Point((int) (x), (int) y));
|
|
|
|
|
|
+ if (!pointDrag && e.getButton() != MouseEvent.BUTTON3 && e.getX() != 0
|
|
|
|
+ && e.getX() != this.getWidth() / scaleX) {
|
|
|
|
+ for (int i = 0; i < pointList.size(); i++) {
|
|
|
|
+ if (x < pointList.get(i).getX() && !added) {
|
|
|
|
+ if (e.getY() <= 0) {
|
|
|
|
+ pointList.add(i, new Point((int) (x), (int) (0 / scaleY)));
|
|
|
|
+ } else {
|
|
|
|
+ pointList.add(i, new Point((int) (x), (int) y));
|
|
|
|
+ }
|
|
|
|
+ added = true;
|
|
|
|
+ pointDrag = true;
|
|
|
|
+ tempP = pointList.get(i);
|
|
}
|
|
}
|
|
- added = true;
|
|
|
|
- pointDrag = true;
|
|
|
|
- tempP = pointList.get(i);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (deletePoint && tempP.getX() != 0
|
|
|
|
- && (tempP.getX() != this.getWidth() / scaleX || tempP != pointList.getLast())) {
|
|
|
|
- pointList.remove(tempP);
|
|
|
|
- }
|
|
|
|
|
|
+ if (deletePoint && tempP.getX() != 0
|
|
|
|
+ && (tempP.getX() != this.getWidth() / scaleX || tempP != pointList.getLast())) {
|
|
|
|
+ pointList.remove(tempP);
|
|
|
|
+ }
|
|
|
|
|
|
- repaint();
|
|
|
|
|
|
+ repaint();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -273,7 +278,17 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Resets the Graph
|
|
|
|
|
|
+ * Emptys the Graph
|
|
|
|
+ */
|
|
|
|
+ public void empty() {
|
|
|
|
+ pointList = null;
|
|
|
|
+ tempElement = null;
|
|
|
|
+ arrayOfValue = null;
|
|
|
|
+ repaint();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Resets the Points for the Element
|
|
*/
|
|
*/
|
|
public void reset() {
|
|
public void reset() {
|
|
pointList.removeAll(pointList);
|
|
pointList.removeAll(pointList);
|
|
@@ -390,14 +405,14 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
// Teil der Kurve aussuchen
|
|
// Teil der Kurve aussuchen
|
|
if (cl.getX1() <= xVal * scaleX && cl.getX2() > xVal * scaleX) {
|
|
if (cl.getX1() <= xVal * scaleX && cl.getX2() > xVal * scaleX) {
|
|
c = cl;
|
|
c = cl;
|
|
- //Kurve Links von "unten"
|
|
|
|
|
|
+ // Kurve Links von "unten"
|
|
if (pointList.get(i).getY() >= pointList.get(i + 1).getY()) {
|
|
if (pointList.get(i).getY() >= pointList.get(i + 1).getY()) {
|
|
for (int j = (int) (height - 1); j >= 0; j--) {
|
|
for (int j = (int) (height - 1); j >= 0; j--) {
|
|
if (c.contains(xVal * scaleX, j * scaleY)) {
|
|
if (c.contains(xVal * scaleX, j * scaleY)) {
|
|
return (float) (j);
|
|
return (float) (j);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else {//Kurve Links von "oben"
|
|
|
|
|
|
+ } else {// Kurve Links von "oben"
|
|
for (int j = 0; j < height; j++) {
|
|
for (int j = 0; j < height; j++) {
|
|
if (c.contains(xVal * scaleX, j * scaleY)) {
|
|
if (c.contains(xVal * scaleX, j * scaleY)) {
|
|
return (float) (j);
|
|
return (float) (j);
|
|
@@ -406,14 +421,14 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
c = cr;
|
|
c = cr;
|
|
- //Kurve Links von "unten"
|
|
|
|
|
|
+ // Kurve Links von "unten"
|
|
if (pointList.get(i).getY() >= pointList.get(i + 1).getY()) {
|
|
if (pointList.get(i).getY() >= pointList.get(i + 1).getY()) {
|
|
for (int j = 0; j < height; j++) {
|
|
for (int j = 0; j < height; j++) {
|
|
if (c.contains(xVal * scaleX, j * scaleY)) {
|
|
if (c.contains(xVal * scaleX, j * scaleY)) {
|
|
return (float) (j);
|
|
return (float) (j);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else {//Kurve Links von "oben"
|
|
|
|
|
|
+ } else {// Kurve Links von "oben"
|
|
for (int j = (int) (height - 1); j >= 0; j--) {
|
|
for (int j = (int) (height - 1); j >= 0; j--) {
|
|
if (c.contains(xVal * scaleX, j * scaleY)) {
|
|
if (c.contains(xVal * scaleX, j * scaleY)) {
|
|
return (float) (j);
|
|
return (float) (j);
|