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); } }
protected java.awt.Point adjustDrawPointToViewport( int x, int y, java.awt.geom.Rectangle2D bounds, java.awt.Rectangle viewport) { if (x + bounds.getMaxX() > viewport.getWidth()) x = (int) (viewport.getWidth() - bounds.getWidth()) - 1; else if (x < 0) x = 0; if (y + bounds.getMaxY() > viewport.getHeight()) y = (int) (viewport.getHeight() - bounds.getHeight()) - 1; else if (y < 0) y = 0; return new java.awt.Point(x, y); }
private Vec4 computeReferencePoint(DrawContext dc) { if (dc.getViewportCenterPosition() != null) return dc.getGlobe().computePointFromPosition(dc.getViewportCenterPosition()); java.awt.geom.Rectangle2D viewport = dc.getView().getViewport(); int x = (int) viewport.getWidth() / 2; for (int y = (int) (0.5 * viewport.getHeight()); y >= 0; y--) { Position pos = dc.getView().computePositionFromScreenPoint(x, y); if (pos == null) continue; return dc.getGlobe().computePointFromPosition(pos.getLatitude(), pos.getLongitude(), 0d); } return null; }