|
@@ -338,7 +338,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
tempP = null;
|
|
|
if (pointList != null) {
|
|
|
for (Point p : pointList) {
|
|
|
- if (x >= p.getX() - dist*2 && x <= p.getX() + dist*2) {
|
|
|
+ if (x >= p.getX() - dist * 2 && x <= p.getX() + dist * 2) {
|
|
|
if (e.getButton() == MouseEvent.BUTTON3) {
|
|
|
tempP = p;
|
|
|
deletePoint = true;
|
|
@@ -352,20 +352,21 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
if (!pointDrag && e.getButton() != MouseEvent.BUTTON3 && x != 0 && x != width) {
|
|
|
for (int i = 0; i < pointList.size() && !added; i++) {
|
|
|
if (x < pointList.get(i).getX() - dist) {
|
|
|
+ // double p1, p2 um location der points zu bestimmen
|
|
|
+ double p1 = pointList.get(i - 1).getX();
|
|
|
+ double p2 = pointList.get(i).getX();
|
|
|
// Punkte hinzufügen, je nachdem ob true oder false
|
|
|
- double p1 = pointList.get(i - 1).getX();
|
|
|
- double p2 = pointList.get(i).getX();
|
|
|
if (pointList.get(i - 1).getY() != 0 && pointList.get(i).getY() != 0) {
|
|
|
- pointList.add(i, new Point((int) ((x+p2)/2 + dist), (int) height - 1));
|
|
|
- pointList.add(i, new Point((int) ((x+p2)/2 + dist), 0));
|
|
|
- pointList.add(i, new Point((int) ((x+p1)/2 - dist), 0));
|
|
|
- pointList.add(i, new Point((int) ((x+p1)/2- dist), (int) height - 1));
|
|
|
+ pointList.add(i, new Point((int) ((x + p2) / 2 + dist), (int) height - 1));
|
|
|
+ pointList.add(i, new Point((int) ((x + p2) / 2 + dist), 0));
|
|
|
+ pointList.add(i, new Point((int) ((x + p1) / 2 - dist), 0));
|
|
|
+ pointList.add(i, new Point((int) ((x + p1) / 2 - dist), (int) height - 1));
|
|
|
added = true;
|
|
|
} else if (pointList.get(i - 1).getY() == 0 && pointList.get(i).getY() == 0) {
|
|
|
- pointList.add(i, new Point((int) ((x+p2)/2 + dist), 0));
|
|
|
- pointList.add(i, new Point((int) ((x+p2)/2 + dist), (int) height - 1));
|
|
|
- pointList.add(i, new Point((int) ((x+p1)/2 - dist), (int) height - 1));
|
|
|
- pointList.add(i, new Point((int) ((x+p1)/2 - dist), 0));
|
|
|
+ pointList.add(i, new Point((int) ((x + p2) / 2 + dist), 0));
|
|
|
+ pointList.add(i, new Point((int) ((x + p2) / 2 + dist), (int) height - 1));
|
|
|
+ pointList.add(i, new Point((int) ((x + p1) / 2 - dist), (int) height - 1));
|
|
|
+ pointList.add(i, new Point((int) ((x + p1) / 2 - dist), 0));
|
|
|
added = true;
|
|
|
}
|
|
|
}
|
|
@@ -378,15 +379,15 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
int i = pointList.indexOf(tempP);
|
|
|
if (tempP.getY() == 0) {
|
|
|
pointList.remove(i);
|
|
|
- pointList.remove(i-1);
|
|
|
- pointList.remove(i-2);
|
|
|
- pointList.remove(i-3);
|
|
|
+ pointList.remove(i - 1);
|
|
|
+ pointList.remove(i - 2);
|
|
|
+ pointList.remove(i - 3);
|
|
|
}
|
|
|
- if (tempP.getY() == height-1) {
|
|
|
- pointList.remove(i+2);
|
|
|
- pointList.remove(i+1);
|
|
|
+ if (tempP.getY() == height - 1) {
|
|
|
+ pointList.remove(i + 2);
|
|
|
+ pointList.remove(i + 1);
|
|
|
pointList.remove(i);
|
|
|
- pointList.remove(i-1);
|
|
|
+ pointList.remove(i - 1);
|
|
|
}
|
|
|
}
|
|
|
|