/** * Positions tool tips to be aligned in the text component, so that the * displayed content is shown (almost) exactly where it would be in the * editor. * * @param e The mouse location. */ @Override public Point getToolTipLocation(MouseEvent e) { // ToolTipManager requires both location and text to be null to hide // a currently-visible tool tip window. If text is null but location // has some value, it will show a tool tip with empty content, the size // of its border (!). String text = getToolTipText(e); if (text==null) { return null; } // Try to overlap the tip's text directly over the code Point p = e.getPoint(); p.y = (p.y/textArea.getLineHeight()) * textArea.getLineHeight(); p.x = getWidth() + textArea.getMargin().left; Gutter gutter = getGutter(); int gutterMargin = gutter.getInsets().right; p.x += gutterMargin; JToolTip tempTip = createToolTip(); p.x -= tempTip.getInsets().left; p.y += 16; return p; }
/** * Paints the specified component. * * @param context * context for the component being painted * @param g * the {@code Graphics} object used for painting * @see #update(Graphics,JComponent) */ protected void paint(SynthContext context, Graphics g) { JToolTip tip = (JToolTip) context.getComponent(); Insets insets = tip.getInsets(); View v = (View) tip.getClientProperty(BasicHTML.propertyKey); if (v != null) { Rectangle paintTextR = new Rectangle(insets.left, insets.top, tip.getWidth() - (insets.left + insets.right), tip.getHeight() - (insets.top + insets.bottom)); v.paint(g, paintTextR); } else { g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND)); g.setFont(style.getFont(context)); context.getStyle().getGraphicsUtils(context).paintText(context, g, tip.getTipText(), insets.left, insets.top, -1); } }
/** * Positions tool tips to be aligned in the text component, so that the * displayed content is shown (almost) exactly where it would be in the * editor. * * @param e The mouse location. */ @Override public Point getToolTipLocation(MouseEvent e) { // ToolTipManager requires both location and text to be null to hide // a currently-visible tool tip window. If text is null but location // has some value, it will show a tool tip with empty content, the size // of its border (!). String text = getToolTipText(e); if (text==null) { return null; } // Try to overlap the tip's text directly over the code Point p = e.getPoint(); p.y = (p.y/textArea.getLineHeight()) * textArea.getLineHeight(); p.x = getWidth() + textArea.getMargin().left; Gutter gutter = getGutter(); int gutterMargin = gutter.getInsets().right; p.x += gutterMargin; JToolTip tempTip = createToolTip(); p.x -= tempTip.getInsets().left; p.y += 16; return p; }