|
@@ -751,10 +751,20 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
g2.setColor(new Color(255, 225, 150));
|
|
g2.setColor(new Color(255, 225, 150));
|
|
g2.setStroke(new BasicStroke(1));
|
|
g2.setStroke(new BasicStroke(1));
|
|
int textWidth = g.getFontMetrics().stringWidth(toolTipText) + 2; // Text width
|
|
int textWidth = g.getFontMetrics().stringWidth(toolTipText) + 2; // Text width
|
|
- g2.fillRect(toolTipPos.x - (textWidth >> 1) + model.getScaleDiv2(), toolTipPos.y, textWidth, 15);
|
|
|
|
|
|
+ int fixXPos = toolTipPos.x - (textWidth >> 1) + model.getScaleDiv2(); // Position fixed x Position to the screen
|
|
|
|
+ int fixYPos = toolTipPos.y; //// Position fixed y Position to the screen
|
|
|
|
+ if (fixXPos < 0) {
|
|
|
|
+ fixXPos = 0;
|
|
|
|
+ } else if (fixXPos + textWidth + 1 > this.getWidth()) {
|
|
|
|
+ fixXPos -= (fixXPos + textWidth + 1) - this.getWidth();
|
|
|
|
+ }
|
|
|
|
+ if (fixYPos + 16 > this.getHeight()) {
|
|
|
|
+ fixYPos -= (fixYPos + 16) - this.getHeight();
|
|
|
|
+ }
|
|
|
|
+ g2.fillRect(fixXPos, fixYPos, textWidth, 15);
|
|
g2.setColor(Color.BLACK);
|
|
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);
|
|
|
|
|
|
+ g2.drawRect(fixXPos, fixYPos, textWidth, 15);
|
|
|
|
+ g2.drawString(toolTipText, fixXPos + 2, fixYPos + 12);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|