|
@@ -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 && x <= p.getX() + dist) {
|
|
|
+ if (x >= p.getX() - dist*2 && x <= p.getX() + dist*2) {
|
|
|
if (e.getButton() == MouseEvent.BUTTON3) {
|
|
|
tempP = p;
|
|
|
deletePoint = true;
|
|
@@ -353,17 +353,19 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
for (int i = 0; i < pointList.size() && !added; i++) {
|
|
|
if (x < pointList.get(i).getX() - dist) {
|
|
|
// 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 + dist), (int) height - 1));
|
|
|
- pointList.add(i, new Point((int) (x + dist), 0));
|
|
|
- pointList.add(i, new Point((int) (x - dist), 0));
|
|
|
- pointList.add(i, new Point((int) (x - 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 + dist), 0));
|
|
|
- pointList.add(i, new Point((int) (x + dist), (int) height - 1));
|
|
|
- pointList.add(i, new Point((int) (x - dist), (int) height - 1));
|
|
|
- pointList.add(i, new Point((int) (x - 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;
|
|
|
}
|
|
|
}
|