Browse Source

versuche graph zu vverbessern

Kevin Trometer 8 years ago
parent
commit
3855f6d9f2
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/ui/view/UnitGraph.java

+ 3 - 2
src/ui/view/UnitGraph.java

@@ -72,7 +72,8 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	public void mouseDragged(MouseEvent e) {
 	public void mouseDragged(MouseEvent e) {
 		if (pointDrag) {
 		if (pointDrag) {
 			pointList[tempP].setLocation(pointList[tempP].getX(), e.getY());
 			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();
 		repaint();
 	}
 	}
@@ -100,7 +101,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	@Override
 	@Override
 	public void mousePressed(MouseEvent e){
 	public void mousePressed(MouseEvent e){
 		for (int i = 0; i < pointList.length; i++) {
 		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;
 				pointDrag = true;
 				tempP = i;
 				tempP = i;
 			}
 			}