Browse Source

#3 Make the graph of the switches more obvious

Kevin Trometer 7 years ago
parent
commit
ff3415d642
2 changed files with 24 additions and 18 deletions
  1. BIN
      res/Button_Images/Thumbs.db
  2. 24 18
      src/ui/view/UnitGraph.java

BIN
res/Button_Images/Thumbs.db


+ 24 - 18
src/ui/view/UnitGraph.java

@@ -20,7 +20,6 @@ import java.awt.Point;
 import javax.swing.JPanel;
 
 import classes.HolonElement;
-import classes.HolonObject;
 import ui.controller.Control;
 import ui.model.Model;
 import classes.HolonSwitch;
@@ -405,17 +404,19 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 						double p1 = pointList.get(i - 1).getX();
 						double p2 = pointList.get(i).getX();
 						// Punkte hinzuf�gen, je nachdem ob true oder false
-						if (pointList.get(i - 1).getY() != 0 && pointList.get(i).getY() != 0) {
-							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));
+						if (pointList.get(i - 1).getY() != (int) (height / 6)
+								&& pointList.get(i).getY() != (int) (height / 6)) {
+							pointList.add(i, new Point((int) ((x + p2) / 2 + dist), (int) (height - height / 6)));
+							pointList.add(i, new Point((int) ((x + p2) / 2 + dist), (int) (height / 6)));
+							pointList.add(i, new Point((int) ((x + p1) / 2 - dist), (int) (height / 6)));
+							pointList.add(i, new Point((int) ((x + p1) / 2 - dist), (int) (height - height / 6)));
 							added = true;
-						} else if (pointList.get(i - 1).getY() == 0 && pointList.get(i).getY() == 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));
+						} else if (pointList.get(i - 1).getY() == (int) (height / 6)
+								&& pointList.get(i).getY() == (int) (height / 6)) {
+							pointList.add(i, new Point((int) ((x + p2) / 2 + dist), (int) (height / 6)));
+							pointList.add(i, new Point((int) ((x + p2) / 2 + dist), (int) (height - height / 6)));
+							pointList.add(i, new Point((int) ((x + p1) / 2 - dist), (int) (height - height / 6)));
+							pointList.add(i, new Point((int) ((x + p1) / 2 - dist), (int) (height / 6)));
 							added = true;
 						}
 					}
@@ -426,13 +427,13 @@ 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 (tempP.getY() == 0) {
+				if (tempP.getY() == (int) (height / 6)) {
 					pointList.remove(i);
 					pointList.remove(i - 1);
 					pointList.remove(i - 2);
 					pointList.remove(i - 3);
 				}
-				if (tempP.getY() == height - 1) {
+				if (tempP.getY() == (int) (height - height / 6)) {
 					pointList.remove(i + 2);
 					pointList.remove(i + 1);
 					pointList.remove(i);
@@ -515,8 +516,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 */
 	public void reset() {
 		pointList.removeAll(pointList);
-		pointList.addFirst(new Point(0, 0));
-		pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
+		if (isSwitch) {
+			pointList.addFirst(new Point(0, (int)(height/6)));
+			pointList.addLast(new Point((int) (this.getWidth() / scaleX), (int)(height-height/6)));
+		} else {
+			pointList.addFirst(new Point(0, 0));
+			pointList.addLast(new Point((int) (this.getWidth() / scaleX), 0));
+		}
 		repaint();
 	}
 
@@ -576,8 +582,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		isElement = false;
 		// First time clicked on the Element
 		if (pointList.isEmpty()) {
-			pointList.addFirst(new Point(0, 0));
-			pointList.addLast(new Point((int) (width), 0));
+			pointList.addFirst(new Point(0, (int) (height / 6)));
+			pointList.addLast(new Point((int) (width), (int) (height / 6)));
 		}
 		repaint();
 	}
@@ -621,7 +627,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)));
-			if (t == 0) {
+			if (t == (int) (height / 6)) {
 				arrayOfBooleans[i] = true;
 			} else {
 				arrayOfBooleans[i] = false;