|
@@ -90,7 +90,11 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
public JMenuItem itemUngroup = new JMenuItem("Ungroup");
|
|
public JMenuItem itemUngroup = new JMenuItem("Ungroup");
|
|
public JMenuItem itemTrack = new JMenuItem("Track");
|
|
public JMenuItem itemTrack = new JMenuItem("Track");
|
|
public JMenuItem itemUntrack = new JMenuItem("Untrack");
|
|
public JMenuItem itemUntrack = new JMenuItem("Untrack");
|
|
- private JToolTip objectTT = new JToolTip();
|
|
|
|
|
|
+
|
|
|
|
+ // Tooltip
|
|
|
|
+ private boolean toolTip; // Tooltip on or off
|
|
|
|
+ private Position toolTipPos = new Position(); // Tooltip Position
|
|
|
|
+ private String toolTipText = "";
|
|
|
|
|
|
private Point mousePosition = new Point(); // Mouse Position when
|
|
private Point mousePosition = new Point(); // Mouse Position when
|
|
// rightclicked
|
|
// rightclicked
|
|
@@ -121,10 +125,11 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
* the Controller
|
|
* the Controller
|
|
*/
|
|
*/
|
|
public UpperNodeCanvas(Model mod, Control control, CpsUpperNode UpperNode, String parentPath) {
|
|
public UpperNodeCanvas(Model mod, Control control, CpsUpperNode UpperNode, String parentPath) {
|
|
- // this.add(objectTT);
|
|
|
|
- objectTT.setVisible(false);
|
|
|
|
|
|
+ toolTip = false;
|
|
|
|
+
|
|
this.controller = control;
|
|
this.controller = control;
|
|
this.model = mod;
|
|
this.model = mod;
|
|
|
|
+
|
|
this.upperNode = UpperNode;
|
|
this.upperNode = UpperNode;
|
|
this.path = parentPath + upperNode.getName();
|
|
this.path = parentPath + upperNode.getName();
|
|
this.breadCrumb = new JLabel(path);
|
|
this.breadCrumb = new JLabel(path);
|
|
@@ -740,6 +745,17 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
// Border Line
|
|
// Border Line
|
|
g2.setColor(Color.BLACK);
|
|
g2.setColor(Color.BLACK);
|
|
g2.drawLine(borderPos, 0, borderPos, this.getHeight());
|
|
g2.drawLine(borderPos, 0, borderPos, this.getHeight());
|
|
|
|
+
|
|
|
|
+ // Tooltip
|
|
|
|
+ if (toolTip) {
|
|
|
|
+ g2.setColor(new Color(255, 225, 150));
|
|
|
|
+ g2.setStroke(new BasicStroke(1));
|
|
|
|
+ int textWidth = g.getFontMetrics().stringWidth(toolTipText) + 2; // Text width
|
|
|
|
+ g2.fillRect(toolTipPos.x - (textWidth >> 1) + model.getScaleDiv2(), toolTipPos.y, textWidth, 15);
|
|
|
|
+ g2.setColor(Color.BLACK);
|
|
|
|
+ g2.drawRect(toolTipPos.x - (textWidth >> 1) + model.getScaleDiv2(), toolTipPos.y, textWidth, 15);
|
|
|
|
+ g2.drawString(toolTipText, toolTipPos.x - (textWidth >> 1) + model.getScaleDiv2() + 2, toolTipPos.y + 12);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -994,9 +1010,12 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
yDist = y - tempCps.getPosition().y;
|
|
yDist = y - tempCps.getPosition().y;
|
|
|
|
|
|
tempCps.setPosition(x, y); // Drag Position
|
|
tempCps.setPosition(x, y); // Drag Position
|
|
|
|
+
|
|
// TipText Position and name
|
|
// TipText Position and name
|
|
- objectTT.setTipText(tempCps.getName() + ", " + tempCps.getID());
|
|
|
|
- objectTT.setLocation(x, y + controller.getScale());
|
|
|
|
|
|
+ toolTip = true;
|
|
|
|
+ toolTipText = tempCps.getName() + ", " + tempCps.getID();
|
|
|
|
+ toolTipPos.x = tempCps.getPosition().x;
|
|
|
|
+ toolTipPos.y = tempCps.getPosition().y + model.getScale();
|
|
|
|
|
|
// All Selected Objects
|
|
// All Selected Objects
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
@@ -1092,8 +1111,10 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
cy = cps.getPosition().y;
|
|
cy = cps.getPosition().y;
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
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;
|
|
|
|
+ toolTipPos.x = cps.getPosition().x;
|
|
|
|
+ toolTipPos.y = cps.getPosition().y + model.getScale();
|
|
|
|
+ toolTipText = cps.getName() + ", " + cps.getID();
|
|
|
|
|
|
on = true;
|
|
on = true;
|
|
}
|
|
}
|
|
@@ -1112,20 +1133,21 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
cy = (int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count);
|
|
cy = (int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count);
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
|
|
|
|
- objectTT.setLocation(cx - model.getScaleDiv2(), cy + controller.getScale());
|
|
|
|
- objectTT.setTipText(cps.getName() + ", " + cps.getID());
|
|
|
|
-
|
|
|
|
on = true;
|
|
on = true;
|
|
|
|
+ toolTipPos.x = cx - model.getScaleDiv2();
|
|
|
|
+ toolTipPos.y = cy + controller.getScale();
|
|
|
|
+ toolTipText = cps.getName() + ", " + cps.getID();
|
|
|
|
+
|
|
}
|
|
}
|
|
count++;
|
|
count++;
|
|
}
|
|
}
|
|
|
|
|
|
if (on) {
|
|
if (on) {
|
|
- objectTT.setVisible(true);
|
|
|
|
|
|
+ toolTip = true;
|
|
} else {
|
|
} else {
|
|
- objectTT.setVisible(false);
|
|
|
|
|
|
+ toolTip = false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ repaint();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|