Ejemplo n.º 1
0
  protected void drawToolTip(
      DrawContext dc,
      java.awt.Rectangle viewport,
      String text,
      int x,
      int y,
      ToolTipAttributes attributes) {
    java.awt.geom.Rectangle2D textBounds = this.computeTextBounds(dc, text, attributes.getFont());
    java.awt.geom.Rectangle2D bgBounds =
        this.computeBackgroundBounds(
            dc, textBounds.getWidth(), textBounds.getHeight(), attributes.getInsets());

    java.awt.Point screenPoint = this.adjustDrawPointToViewport(x, y, bgBounds, viewport);
    java.awt.geom.Point2D textTranslation =
        this.computeTextTranslation(dc, textBounds, attributes.getInsets());

    GL2 gl = dc.getGL();
    OGLStackHandler stackHandler = new OGLStackHandler();

    stackHandler.pushModelview(gl);
    try {
      gl.glTranslated(
          screenPoint.getX() + bgBounds.getX(), screenPoint.getY() + bgBounds.getY(), 0);
      this.drawToolTipInterior(dc, bgBounds.getWidth(), bgBounds.getHeight(), attributes);
      this.drawToolTipOutline(dc, bgBounds.getWidth(), bgBounds.getHeight(), attributes);

      gl.glTranslated(textTranslation.getX(), textTranslation.getY(), 0);
      this.drawToolTipText(dc, text, 0, 0, attributes);
    } finally {
      stackHandler.pop(gl);
    }
  }
Ejemplo n.º 2
0
  @SuppressWarnings({"UnusedDeclaration"})
  protected java.awt.geom.Point2D computeTextTranslation(
      DrawContext dc, java.awt.geom.Rectangle2D textBounds, java.awt.Insets insets) {
    // The text bounds are assumed to come from the return value of a call to
    // TextRenderer.getBounds(). The bounds
    // place the origin in the upper left hand corner, with the y axis increasing downward. The y
    // coordinate in the bounds corresponds to the baseline of the leftmost character.

    return new java.awt.geom.Point2D.Double(
        insets.left - textBounds.getX(),
        insets.bottom + textBounds.getY() + textBounds.getHeight());
  }