Ver Fonte

switch graph improvement

Kevin Trometer há 8 anos atrás
pai
commit
c297666182
1 ficheiros alterados com 11 adições e 6 exclusões
  1. 11 6
      src/ui/view/UnitGraph.java

+ 11 - 6
src/ui/view/UnitGraph.java

@@ -203,9 +203,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 				g2.setStroke(new BasicStroke(2));
 				g2.setColor(Color.BLACK);
 				for (int i = 0; i < pointList.size() - 1; i++) {
-					line = new Line2D.Double(pointList.get(i).getX() * scaleX + border,
-							pointList.get(i).getY() * scaleY, pointList.get(i + 1).getX() * scaleX + border,
-							pointList.get(i + 1).getY() * scaleY);
+					if ((i == 1 || i == 2) && pointList.get(i).getX() < 0) {
+						line = new Line2D.Double(border, pointList.get(i).getY() * scaleY, border,
+								pointList.get(i + 1).getY() * scaleY);
+					} else {
+						line = new Line2D.Double(pointList.get(i).getX() * scaleX + border,
+								pointList.get(i).getY() * scaleY, pointList.get(i + 1).getX() * scaleX + border,
+								pointList.get(i + 1).getY() * scaleY);
+					}
 					graphCurve.append(line, true);
 				}
 				g2.draw(graphCurve);
@@ -484,8 +489,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 			if (deletePoint && tempP.getX() != 0
 					&& (tempP.getX() != this.getWidth() / scaleX || tempP != pointList.getLast())) {
 				int i = pointList.indexOf(tempP);
-				//If Right, else if Left
-				if (tempP.getY() == (int) (height / 6) && i < pointList.size() - 1 && i>0) {
+				// If Right, else if Left
+				if (tempP.getY() == (int) (height / 6) && i < pointList.size() - 1 && i > 0) {
 					pointList.remove(i);
 					pointList.remove(i - 1);
 					pointList.remove(i - 2);
@@ -682,7 +687,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 */
 	public void fillArrayofBooleans() {
 		for (int i = 0; i < arrayOfBooleans.length; i++) {
-			int t = (int) getYValueAt2((int) (i * width / (model.getIterations() - 1)));
+			int t = (int) getYValueAt((int) (i * width / (model.getIterations() - 1)));
 			if (t <= height / 2) {
 				arrayOfBooleans[i] = true;
 			} else {