@Override protected void paintComponent(Graphics g) { this.tabbedPane.getDropLineRect().ifPresent(rect -> { Graphics2D g2 = (Graphics2D) g.create(); Rectangle r = SwingUtilities.convertRectangle(this.tabbedPane, rect, this); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f)); g2.setPaint(Color.RED); g2.fill(r); g2.dispose(); }); }
@Override public void repaint(Rectangle r) { JScrollIndicator scrollIndicator = JScrollIndicator.this; // Fix #15956: NullPointerException on convertRectangle() try { Rectangle rect = SwingUtilities.convertRectangle(this, r, scrollIndicator); rect.grow(1, 1); // ensure for a translucent thumb, that the view is first painted scrollIndicator.repaint(rect); } catch (NullPointerException e) { LOGGER.error(e.getMessage(), e); } } }
public void action(Component c) { if (_componentTypes != null) { boolean allowed = false; for (Class allowedType : _componentTypes) { if (allowedType.isAssignableFrom(c.getClass())) { allowed = true; break; } } if (!allowed) return; } Rectangle bounds = c.getBounds(); rects.add(SwingUtilities.convertRectangle(c, bounds, _parent)); components.add(c); }
/** * Scrolls an AWT or Swing {@code Component} into view within a container. * * @param robot simulates user input. * @param container the given container. * @param target the given {@code Component}. */ private static void scrollToVisible(@Nonnull Robot robot, @Nonnull JComponent container, @Nonnull Component target) { Rectangle r = convertRectangle(target.getParent(), target.getBounds(), container); scrollToVisible(robot, container, checkNotNull(r)); }
public boolean isOverlayVisibleInParentComponent() { Rectangle vr = SwingUtilities.convertRectangle(parentComponent, parentComponent.getVisibleRect(), parentFrame.getJavaContainer()); Rectangle cr = SwingUtilities.convertRectangle(parentFrame.getLayeredPane(), content.getBounds(), parentFrame.getJavaContainer()); return vr.intersects(cr); }
public static void translate(Component src, Polygon poly, Component dest) { if(src==null || poly==null || dest==null) { return; } Rectangle srcRect = src.getBounds(); srcRect.setLocation(0, 0); Rectangle destRect = SwingUtilities.convertRectangle(src, srcRect, dest); int deltaX = destRect.x - srcRect.x; int deltaY = destRect.y - srcRect.y; int len = poly.npoints; for(int i=0; i<len; i++) { poly.xpoints[i] += deltaX; poly.ypoints[i] += deltaY; } }
/** Updates the current relative ancestor container and anchor positionning */ public void resetRelativePosition(Container relativeAncestorContainer, Dockable dockable) { this.relativeAncestorContainer = relativeAncestorContainer; DockableContainer dockableContainer = DockingUtilities.findSingleDockableContainer(dockable); if(dockableContainer != null && relativeAncestorContainer != null) { Component c = (Component) dockableContainer; Rectangle converted = SwingUtilities.convertRectangle(c, new Rectangle(0, 0, c.getWidth(), c.getHeight()), relativeAncestorContainer); x = converted.x / (float) relativeAncestorContainer.getWidth(); y = converted.y / (float) relativeAncestorContainer.getHeight(); w = converted.width / (float) relativeAncestorContainer.getWidth(); h = converted.height / (float) relativeAncestorContainer.getHeight(); // also set boolean anchors this.anchors = RelativeDockingUtilities.findAnchors(dockable.getComponent(), relativeAncestorContainer); } }
private void initTargetLeftRightLine(int next) { if (next < 0 || dragTabIndex == next || next - dragTabIndex == 1) { lineRect.setRect(0, 0, 0, 0); } else if (next == 0) { Rectangle r = SwingUtilities.convertRectangle(this, getBoundsAt(0), glassPane); lineRect.setRect(r.x - LINEWIDTH / 2, r.y, LINEWIDTH, r.height); } else { Rectangle r = SwingUtilities.convertRectangle(this, getBoundsAt(next - 1), glassPane); lineRect.setRect(r.x + r.width - LINEWIDTH / 2, r.y, LINEWIDTH, r.height); } }
private void initTargetTopBottomLine(int next) { if (next < 0 || dragTabIndex == next || next - dragTabIndex == 1) { lineRect.setRect(0, 0, 0, 0); } else if (next == 0) { Rectangle r = SwingUtilities.convertRectangle(this, getBoundsAt(0), glassPane); lineRect.setRect(r.x, r.y - LINEWIDTH / 2, r.width, LINEWIDTH); } else { Rectangle r = SwingUtilities.convertRectangle(this, getBoundsAt(next - 1), glassPane); lineRect.setRect(r.x, r.y + r.height - LINEWIDTH / 2, r.width, LINEWIDTH); } }
public void paint(Graphics g) { int row = TableOverlay.this.row; int column = TableOverlay.this.column; if (row >= 0 && column >= 0) { TableCellRenderer renderer = table.getCellRenderer(row, column); Component rendererComponent = renderer.getTableCellRendererComponent(table, table.getValueAt(row, column), false, false, row, column); setFont(table.getFont()); Rectangle paintBounds = SwingUtilities.convertRectangle(table, bounds, this); SwingUtilities.paintComponent(g, rendererComponent, this, paintBounds); g.setColor(Color.BLACK); g.drawRect(paintBounds.x, paintBounds.y, paintBounds.width, paintBounds.height); } } }
public Rectangle getToolWindowManagerContainerBounds() { return SwingUtilities.convertRectangle(manager, manager.getBounds(), manager.getRootPaneContainer().getContentPane()); }
private Rectangle getBoundaries( Component component ){ Rectangle bounds = component.getBounds(); if( SwingUtilities.isDescendingFrom( component, station.getComponent() ) ) { return SwingUtilities.convertRectangle( component.getParent(), bounds, station.getComponent() ); } else { return null; } } }
private void update() { Rectangle bounds = SwingUtilities.convertRectangle(overlayComponent.getParent(), overlayComponent.getBounds(), rootPane.getLayeredPane()); setBounds(bounds); repaint(); }
/** * Updates the buffer (if one exists) and repaints the given cell state. */ public void redraw(mxCellState state) { if (state != null) { Rectangle dirty = state.getBoundingBox().getRectangle(); repaintTripleBuffer(new Rectangle(dirty)); dirty = SwingUtilities.convertRectangle(graphControl, dirty, this); repaint(dirty); } }
/** * Updates the buffer (if one exists) and repaints the given cell state. */ public void redraw(mxCellState state) { if (state != null) { Rectangle dirty = state.getBoundingBox().getRectangle(); repaintTripleBuffer(new Rectangle(dirty)); dirty = SwingUtilities.convertRectangle(graphControl, dirty, this); repaint(dirty); } }
private Rectangle calculateBounds(Component overlayComponent) { JRootPane rootPane = SwingUtilities.getRootPane(overlayComponent); Rectangle rect = SwingUtilities.convertRectangle(overlayComponent.getParent(), overlayComponent.getBounds(), rootPane.getContentPane()); JMenuBar menuBar = rootPane.getJMenuBar(); rect.x += MARGIN; rect.y += MARGIN + (menuBar == null ? 0 : menuBar.getHeight()); rect.width -= MARGIN * 2; rect.height -= MARGIN * 2; return rect; }
protected Rectangle getDropRect() { Dimension d=sp_.getViewport().getExtentSize(); Rectangle r=super.getDropRect(); r.x=2; r.y=2; r.width =d.width-4; r.height=d.height-4; r=SwingUtilities.convertRectangle(sp_.getViewport(),r,this); return r; }
public Rectangle getCaretLocation() throws BadLocationException { Rectangle rectangle = getEditor().modelToView( getEditor().getCaretPosition() ); return SwingUtilities.convertRectangle( getEditor(), rectangle, this ); }
public Rectangle getCaretLocation() throws BadLocationException { Rectangle rectangle = getEditor().modelToView( getEditor().getCaretPosition() ); return SwingUtilities.convertRectangle( getEditor(), rectangle, this ); }
protected void paintChildren(final Graphics g) { super.paintChildren(g); if (getLabelComponent().getParent() == null) return; final Rectangle textBounds = SwingUtilities.convertRectangle(getLabelComponent().getParent(), getLabelComponent().getBounds(), this); // Paint border around label if we got the focus if (isFocusOwner()) { g.setColor(UIUtil.getTreeSelectionBorderColor()); DrawUtil.drawDottedRectangle(g, textBounds.x, textBounds.y, textBounds.x + textBounds.width - 1, textBounds.y + textBounds.height - 1); } if (myOverlayedIcon == null) return; }