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
  protected void drawToolTipInterior(
      DrawContext dc, double width, double height, ToolTipAttributes attributes) {
    GL2 gl = dc.getGL();

    this.applyColor(dc, attributes.getInteriorColor(), attributes.getInteriorOpacity());

    // Draw a filled rectangle with the background dimensions.
    gl.glRectd(0, 0, width, height);
  }
Ejemplo n.º 3
0
  protected void drawToolTipText(
      DrawContext dc, String text, int x, int y, ToolTipAttributes attributes) {
    java.awt.Color textColor =
        this.modulateColorOpacity(attributes.getTextColor(), attributes.getTextOpacity());

    TextRenderer textRenderer = this.getTextRenderer(dc, attributes.getFont());
    textRenderer.begin3DRendering();
    textRenderer.setColor(textColor);
    textRenderer.draw(text, x, y);
    textRenderer.end3DRendering();
  }
Ejemplo n.º 4
0
  protected void drawToolTipOutline(
      DrawContext dc, double width, double height, ToolTipAttributes attributes) {
    GL2 gl = dc.getGL();

    this.applyColor(dc, attributes.getOutlineColor(), attributes.getOutlineOpacity());
    gl.glLineWidth((float) getOutlineWidth());

    // Draw a line loop around the background rectangle. Inset the lines slightly to compensate for
    // OpenGL's line
    // rasterization algorithm. We want the line to straddle the rectangle pixels.
    double inset = 0.5;
    gl.glBegin(GL2.GL_LINE_LOOP);
    gl.glVertex2d(inset, inset);
    gl.glVertex2d(width - inset, inset);
    gl.glVertex2d(width - inset, height - inset);
    gl.glVertex2d(inset, height - inset);
    gl.glEnd();
  }