int y = rowIndex * fontHeight - scrollingOffsetInPixels; g.setColor(backgroundColor); g.setClip(x, y, characterWidth, fontHeight); g.fillRect(x, y, characterWidth, fontHeight);
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Rectangle bounds = g.getClipBounds(); int index = 0; for (String name : shortLineNames.keySet()) { int nameWidth = g.getFontMetrics().stringWidth(name); int lineX = lineStep * index; index++; if (bounds.getMaxX() < lineX || bounds.getMinX() > lineX + nameWidth) { continue; } g.setClip(lineX + LINE_LABEL_BOUNDARY, 0, lineStep - +LINE_LABEL_BOUNDARY * 2, getHeight()); g.drawString(name, lineX + LINE_LABEL_BOUNDARY, AXIS_SIZE / 3); g.setClip(null); } } }
graphics.setClip(rect.x, 0, rect.width, (int) paper.getHeight() + 100);
totalGraphics.setClip(bounds);
Graphics g = JComponent.safelyGetGraphics( dirtyComponent, dirtyComponent); // If the Graphics goes away, it means someone disposed of // the window, don't do anything. if (g != null) { g.setClip(rect.x, rect.y, rect.width, rect.height); try { dirtyComponent.paint(g); // This will eventually call paintComponent() } finally { g.dispose(); } }
/** Fetch a scratch graphics object for calculating preferred sizes while * offscreen */ private static final Graphics scratchGraphics() { Graphics result = null; if (scratchGraphics != null) { result = scratchGraphics.get(); if (result != null) { result.setClip(null); //just in case somebody did something nasty } } if (result == null) { result = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration() .createCompatibleImage(1, 1).getGraphics(); if (!noCacheGraphics) { scratchGraphics = new SoftReference<Graphics>(result); } } return result; }
g2.fillRect(0, 0, getWidth(), getHeight()); g2.setPaint(Color.black); g2.setClip(outside); g2.drawLine(0, 0, getWidth(), getHeight());
int cHeight = delegateIcon.getIconHeight() / 2; Rectangle r = new Rectangle(x, y, delegateIcon.getIconWidth(), delegateIcon.getIconHeight()); g2.setClip(r); AffineTransform original = g2.getTransform(); AffineTransform at = new AffineTransform();
Graphics g = hShadowBg.createGraphics(); g.translate(-RECT.x, -RECT.y); g.setClip(RECT); if (layeredPane instanceof JComponent) { JComponent c = (JComponent) layeredPane; Graphics g = vShadowBg.createGraphics(); g.translate(-RECT.x, -RECT.y); g.setClip(RECT); if (layeredPane instanceof JComponent) { JComponent c = (JComponent) layeredPane;
// DO NOT - a opaque component violates its contract, as it will not fill // its complete area @Override protected void paintComponent(Graphics g) { if (getBorder() instanceof JRoundedCornerBorder) { Shape borderShape = ((JRoundedCornerBorder) getBorder()). getBorderShape(getWidth(), getHeight()); g.setClip(borderShape); } super.paintComponent(g); }
/** * Only called by paintBorder() */ protected void paintTopLeft(Component c, Graphics g, int x, int y, int width, int height) { Graphics cg = g.create(); try { cg.setClip(x, y, width, height); tileIcons[0].paintIcon(c, cg, x, y); } finally { cg.dispose(); } }
/** * Only called by paintBorder() */ protected void paintTopLeft(Component c, Graphics g, int x, int y, int width, int height) { Graphics cg = g.create(); try { cg.setClip(x, y, width, height); tileIcons[0].paintIcon(c, cg, x, y); } finally { cg.dispose(); } }
@Override public Graphics create(int x, int y, int width, int height) { Graphics g = create(); g.translate(x, y); g.setClip(0, 0, width, height); return g; }
if (clippedCanvas instanceof mxGraphics2DCanvas) { System.out.println("setting new clip"); Graphics g = ((mxGraphics2DCanvas) clippedCanvas).getGraphics(); clip = g.getClip(); g.setClip(newClip); ((mxGraphics2DCanvas) clippedCanvas).paintRectangle(((mxGraphics2DCanvas) clippedCanvas).getGraphics().getClipBounds(), Color.GREEN, Color.WHITE); }
public void paintIcon(Component c, Graphics g, int x, int y) { g = g.create(); Area area = new Area(new Rectangle(x, y, getIconWidth(), getIconHeight())); // X11 needs more of a window due to differences in event processing area.subtract(new Area(new Rectangle(x + cursorOffset.x-1, y + cursorOffset.y-1, 3, 3))); g.setClip(area); icon.paintIcon(c, g, x, y); g.dispose(); }