|
@@ -245,13 +245,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
|
y = e.getY() / scaleY;
|
|
|
|
|
|
if (e.getY() <= 0) {
|
|
|
- y = 0 / scaleY;
|
|
|
+ y = 0;
|
|
|
} else if (this.getHeight() <= e.getY()) {
|
|
|
y = this.getHeight() / scaleY;
|
|
|
}
|
|
|
|
|
|
- if (tempP == pointList.getFirst() || tempP == pointList.getLast() || pointList.get(i + 1).getX() <= x
|
|
|
- || pointList.get(i - 1).getX() >= x) {
|
|
|
+ if (tempP == pointList.getFirst() || tempP == pointList.getLast() || pointList.get(i + 1).getX() < x
|
|
|
+ || pointList.get(i - 1).getX() > x) {
|
|
|
x = tempP.getX();
|
|
|
}
|
|
|
tempP.setLocation(x, y);
|
|
@@ -325,7 +325,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
|
boolean added = false;
|
|
|
boolean deletePoint = false;
|
|
|
|
|
|
- double x = e.getX() / scaleX;
|
|
|
+ int x = (int) (e.getX() / scaleX);
|
|
|
double y = e.getY() / scaleY;
|
|
|
|
|
|
|
|
@@ -348,6 +348,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
|
|
|
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() || x == width || x == 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
if (x < pointList.get(i).getX() && !added) {
|
|
|
if (e.getY() <= 0) {
|
|
|
pointList.add(i, new Point((int) (x), 0));
|