Browse Source

tooltip verbesserung, trotzdem nicht perfekt

Kevin Trometer 8 years ago
parent
commit
b87cd08dd5
2 changed files with 13 additions and 14 deletions
  1. 8 11
      src/ui/view/MyCanvas.java
  2. 5 3
      src/ui/view/UpperNodeCanvas.java

+ 8 - 11
src/ui/view/MyCanvas.java

@@ -111,6 +111,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	 */
 	public MyCanvas(Model mod, Control control) {
 		this.add(objectTT);
+		objectTT.setVisible(false);
 		this.controller = control;
 		this.model = mod;
 
@@ -435,10 +436,10 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 						con.getA().getPosition().y + controller.getScaleDiv2(),
 						con.getB().getPosition().x + controller.getScaleDiv2(),
 						con.getB().getPosition().y + controller.getScaleDiv2());
-				
+
 				if (con.getCapacity() == -1) {
 					maxCap = Character.toString('\u221e');
-				} else if (con.getCapacity() == -2){
+				} else if (con.getCapacity() == -2) {
 					maxCap = "???";
 				} else {
 					maxCap = String.valueOf(con.getCapacity());
@@ -479,8 +480,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 							con.getA().getPosition().y + controller.getScaleDiv2(),
 							con.getB().getPosition().x + controller.getScaleDiv2(),
 							con.getB().getPosition().y + controller.getScaleDiv2());
-					
-					
+
 					if (con.getCapacity() == -1) {
 						maxCap = Character.toString('\u221e');
 					} else if (con.getCapacity() == -2) {
@@ -516,7 +516,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 					edgeHighlight.getA().getPosition().y + controller.getScaleDiv2(),
 					edgeHighlight.getB().getPosition().x + controller.getScaleDiv2(),
 					edgeHighlight.getB().getPosition().y + controller.getScaleDiv2());
-			
 
 			if (edgeHighlight.getCapacity() == -1) {
 				maxCap = Character.toString('\u221e');
@@ -860,20 +859,18 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		// Everytghing for the tooltip :)
 		boolean on = false;
 		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
-
 			cx = cps.getPosition().x;
 			cy = cps.getPosition().y;
 			if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
-
 				objectTT.setLocation(cx, cy + controller.getScale());
 				objectTT.setTipText(cps.getName() + ", " + cps.getID());
-
 				on = true;
 			}
 		}
-		if (!on) {
-			objectTT.setTipText("");
-			objectTT.setLocation(-200, -200);
+		if (on) {
+			objectTT.setVisible(true);
+		} else {
+			objectTT.setVisible(false);
 		}
 	}
 

+ 5 - 3
src/ui/view/UpperNodeCanvas.java

@@ -122,6 +122,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 	 */
 	public UpperNodeCanvas(Model mod, Control control, CpsUpperNode UpperNode, String parentPath) {
 		//this.add(objectTT);
+		objectTT.setVisible(false);
 		this.controller = control;
 		this.model = mod;
 		this.upperNode = UpperNode;
@@ -1114,9 +1115,10 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
 			count++;
 		}
 
-		if (!on) {
-			objectTT.setTipText("");
-			// objectTT.setLocation(-200, -200);
+		if (on) {
+			objectTT.setVisible(true);
+		} else {
+			objectTT.setVisible(false);
 		}
 
 	}