|
@@ -72,7 +72,8 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
public void mouseDragged(MouseEvent e) {
|
|
|
if (pointDrag) {
|
|
|
pointList[tempP].setLocation(pointList[tempP].getX(), e.getY());
|
|
|
- System.out.println("drag");
|
|
|
+ pointList[tempP-1].setLocation(pointList[tempP-1].getX(), pointList[tempP-1].getY()+(e.getY()-pointList[tempP-1].getY())/10);
|
|
|
+ pointList[tempP+1].setLocation(pointList[tempP+1].getX(), pointList[tempP-1].getY()+(e.getY()-pointList[tempP-1].getY())/10);
|
|
|
}
|
|
|
repaint();
|
|
|
}
|
|
@@ -100,7 +101,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
|
|
|
@Override
|
|
|
public void mousePressed(MouseEvent e){
|
|
|
for (int i = 0; i < pointList.length; i++) {
|
|
|
- if(e.getX()-5<pointList[i].getX() && e.getX()+5>pointList[i].getX() && e.getY()-10<pointList[i].getY() && e.getY()+10>pointList[i].getY()){
|
|
|
+ if(e.getX()-this.getWidth()/NUMBER<pointList[i].getX() && e.getX()+this.getWidth()/NUMBER>pointList[i].getX() && e.getY()-10<pointList[i].getY() && e.getY()+10>pointList[i].getY()){
|
|
|
pointDrag = true;
|
|
|
tempP = i;
|
|
|
}
|