/** Paint cell at (row, column) */ protected void paintCell(Graphics g, Rectangle cellBounds, int row, int column) { if (grid.getEditingRow() == row && grid.getEditingColumn() == column) { return; } GridCellRenderer renderer = grid.getCellRenderer(row, column); Component rendererComp = grid.prepareRenderer(renderer, row, column); CellSpan span = grid.getSpanModel().getSpanOver(row, column); rendererPane.paintComponent( g, rendererComp, grid, cellBounds.x, cellBounds.y, cellBounds.width, cellBounds.height, true); }
protected void doPaintTooltipImage( Component rComponent, Rectangle cellBounds, Graphics2D g, KeyType key) { myRendererPane.paintComponent( g, rComponent, myComponent, 0, 0, cellBounds.width, cellBounds.height, true); }
@Nullable private Point createToolTipImage(@NotNull KeyType key) { UIUtil.putClientProperty(myComponent, EXPANDED_RENDERER, true); Pair<Component, Rectangle> rendererAndBounds = getCellRendererAndBounds(key); UIUtil.putClientProperty(myComponent, EXPANDED_RENDERER, null); if (rendererAndBounds == null) return null; JComponent renderer = ObjectUtils.tryCast(rendererAndBounds.first, JComponent.class); if (renderer == null) return null; if (renderer.getClientProperty(DISABLE_EXPANDABLE_HANDLER) != null) return null; if (UIUtil.getClientProperty((JComponent) rendererAndBounds.getFirst(), USE_RENDERER_BOUNDS) == Boolean.TRUE) { rendererAndBounds.getSecond().translate(renderer.getX(), renderer.getY()); rendererAndBounds.getSecond().setSize(renderer.getSize()); } myKeyItemBounds = rendererAndBounds.second; Rectangle cellBounds = myKeyItemBounds; Rectangle visibleRect = getVisibleRect(key); if (cellBounds.y < visibleRect.y) return null; int cellMaxY = cellBounds.y + cellBounds.height; int visMaxY = visibleRect.y + visibleRect.height; if (cellMaxY > visMaxY) return null; int cellMaxX = cellBounds.x + cellBounds.width; int visMaxX = visibleRect.x + visibleRect.width; Point location = new Point(visMaxX, cellBounds.y); SwingUtilities.convertPointToScreen(location, myComponent); Rectangle screen = !Registry.is("ide.expansion.hints.on.all.screens") ? ScreenUtil.getScreenRectangle(location) : ScreenUtil.getAllScreensRectangle(); int borderWidth = isPaintBorder() ? 1 : 0; int width = Math.min(screen.width + screen.x - location.x - borderWidth, cellMaxX - visMaxX); int height = cellBounds.height; if (width <= 0 || height <= 0) return null; Dimension size = getImageSize(width, height); myImage = UIUtil.createImage(size.width, size.height, BufferedImage.TYPE_INT_RGB); Graphics2D g = myImage.createGraphics(); g.setClip(null); doFillBackground(height, width, g); g.translate(cellBounds.x - visMaxX, 0); doPaintTooltipImage(renderer, cellBounds, g, key); CustomLineBorder border = null; if (borderWidth > 0) { border = new CustomLineBorder(getBorderColor(), borderWidth, 0, borderWidth, borderWidth); location.y -= borderWidth; size.width += borderWidth; size.height += borderWidth + borderWidth; } g.dispose(); myRendererPane.remove(renderer); myTipComponent.setBorder(border); myTipComponent.setPreferredSize(size); return location; }