Refine search
protected void paintComponentPatch(Graphics g) { Graphics2D g2 = (Graphics2D) g.create(); try { if (isPaintingBackground()) { g2.setColor(getBackground()); g2.fillRect(0, 0, getWidth(), getHeight()); } if (getBackgroundPainter() != null) { getBackgroundPainter().paint(g2, this, getWidth(), getHeight()); } fakeTransparent = true; getUI().update(g2, this); } finally { g2.dispose(); fakeTransparent = false; } }
return; Graphics2D g2 = (Graphics2D) g.create(); g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); getBackgroundPainter().paint(g2, this, getWidth(), getHeight()); } else { Insets insets = getInsets(); g.translate(insets.left, insets.top); getBackgroundPainter().paint(g2, this, getWidth() - insets.left - insets.right, getHeight() - insets.top - insets.bottom); g.translate(-insets.left, -insets.top); g2.dispose();
private void invokePainter(Graphics g, Painter<JXButton> ptr) { if(ptr == null) return; Graphics2D g2d = (Graphics2D) g.create(); try { if(isPaintBorderInsets()) { ptr.paint(g2d, this, getWidth(), getHeight()); } else { Insets ins = this.getInsets(); g2d.translate(ins.left, ins.top); ptr.paint(g2d, this, this.getWidth() - ins.left - ins.right, this.getHeight() - ins.top - ins.bottom); } } finally { g2d.dispose(); } } // paint anything but text and icon
@SuppressWarnings("unchecked") static <C extends JComponent & BackgroundPaintable> void paintBackground(C comp, Graphics2D g) { // we should be painting the background behind the painter if we have one // this prevents issues with buffer reuse where visual artifacts sneak in if (comp.isOpaque() || (comp instanceof AlphaPaintable && ((AlphaPaintable) comp).getAlpha() < 1f) || UIManager.getLookAndFeel().getID().equals("Nimbus")) { g.setColor(comp.getBackground()); g.fillRect(0, 0, comp.getWidth(), comp.getHeight()); } Painter<? super C> painter = comp.getBackgroundPainter(); if (painter != null) { if (comp.isPaintBorderInsets()) { painter.paint(g, comp, comp.getWidth(), comp.getHeight()); } else { Insets insets = comp.getInsets(); g.translate(insets.left, insets.top); painter.paint(g, comp, comp.getWidth() - insets.left - insets.right, comp.getHeight() - insets.top - insets.bottom); g.translate(-insets.left, -insets.top); } } }
/** * <p>This method is called by the component whenever it needs to paint * its background. The default implementation fills the background with * a solid color as defined by {@link #getBackground()}. Background painting * does not happen when {@link #isBackgroundPainted()} returns false.</p> * <p>It is recommended to subclasses to honor the contract defined by * {@link #isBackgroundPainted()} and {@link #setBackgroundPainted(boolean)}. * * @param g2 the graphics surface on which the background must be drawn * @see #setupGraphics(Graphics2D) * @see #paintExtra(Graphics2D) * @see #isBackgroundPainted() * @see #setBackgroundPainted(boolean) */ protected void paintBackground(Graphics2D g2) { if (isBackgroundPainted()) { Painter p = getBackgroundPainter(); if (p != null) { p.paint(g2, this, getWidth(), getHeight()); } else { g2.setColor(getBackground()); g2.fill(g2.getClipBounds()); } } }
/** * {@inheritDoc} */ @Override protected void doPaint(Graphics2D g, T component, int width, int height) { for (Painter<T> p : getPainters()) { Graphics2D temp = (Graphics2D) g.create(); try { p.paint(temp, component, width, height); if(isClipPreserved()) { g.setClip(temp.getClip()); } } finally { temp.dispose(); } } }
/** * {@inheritDoc} */ @Override public Raster getRaster(int x, int y, int w, int h) { if (saved == null || saved.getWidth() != w || saved.getHeight() != h) { saved = GraphicsUtilities.createCompatibleImage(w, h); Graphics2D g2d = saved.createGraphics(); try { if (painter instanceof AbstractPainter) { ((AbstractPainter<?>) painter).setInPaintContext(true); } painter.paint(g2d, object, w, h); } finally { g2d.dispose(); if (painter instanceof AbstractPainter) { ((AbstractPainter<?>) painter).setInPaintContext(false); } } } return saved.getData(); } }
protected void paintComponent(Graphics gfx) { Graphics2D g = (Graphics2D)gfx; if(getPainter() != null) { for(JComponent target : targets) { Point offset = calcOffset(target); g.translate(offset.x,offset.y); getPainter().paint(g, target, target.getWidth(), target.getHeight()); g.translate(-offset.x,-offset.y); } } }
/** * {@inheritDoc} */ @Override public void paint(Graphics2D g, T component, int width, int height) { if (p != null) { p.paint(g, component, width, height); } } }
protected void paintComponentPatch(Graphics g) { Graphics2D g2 = (Graphics2D) g.create(); try { if (isPaintingBackground()) { g2.setColor(getBackground()); g2.fillRect(0, 0, getWidth(), getHeight()); } if (getBackgroundPainter() != null) { getBackgroundPainter().paint(g2, this, getWidth(), getHeight()); } fakeTransparent = true; getUI().update(g2, this); } finally { g2.dispose(); fakeTransparent = false; } }
return; Graphics2D g2 = (Graphics2D) g.create(); g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); getBackgroundPainter().paint(g2, this, getWidth(), getHeight()); } else { Insets insets = getInsets(); g.translate(insets.left, insets.top); getBackgroundPainter().paint(g2, this, getWidth() - insets.left - insets.right, getHeight() - insets.top - insets.bottom); g.translate(-insets.left, -insets.top); g2.dispose();
/** * Overridden to provide Painter support. It will call backgroundPainter.paint() * if it is not null, else it will call super.paintComponent(). */ @Override protected void paintComponent(Graphics g) { if(backgroundPainter != null) { if (isOpaque()) super.paintComponent(g); Graphics2D g2 = (Graphics2D)g.create(); try { // account for the insets if(isPaintBorderInsets()) { backgroundPainter.paint(g2, this, this.getWidth(), this.getHeight()); } else { Insets ins = this.getInsets(); g2.translate(ins.left, ins.top); backgroundPainter.paint(g2, this, this.getWidth() - ins.left - ins.right, this.getHeight() - ins.top - ins.bottom); } } finally { g2.dispose(); } } else { super.paintComponent(g); } }
@SuppressWarnings("unchecked") static <C extends JComponent & BackgroundPaintable> void paintBackground(C comp, Graphics2D g) { // we should be painting the background behind the painter if we have one // this prevents issues with buffer reuse where visual artifacts sneak in if (comp.isOpaque() || (comp instanceof AlphaPaintable && ((AlphaPaintable) comp).getAlpha() < 1f) || UIManager.getLookAndFeel().getID().equals("Nimbus")) { g.setColor(comp.getBackground()); g.fillRect(0, 0, comp.getWidth(), comp.getHeight()); } Painter<? super C> painter = comp.getBackgroundPainter(); if (painter != null) { if (comp.isPaintBorderInsets()) { painter.paint(g, comp, comp.getWidth(), comp.getHeight()); } else { Insets insets = comp.getInsets(); g.translate(insets.left, insets.top); painter.paint(g, comp, comp.getWidth() - insets.left - insets.right, comp.getHeight() - insets.top - insets.bottom); g.translate(-insets.left, -insets.top); } } }
/** * <p>This method is called by the component whenever it needs to paint * its background. The default implementation fills the background with * a solid color as defined by {@link #getBackground()}. Background painting * does not happen when {@link #isBackgroundPainted()} returns false.</p> * <p>It is recommended to subclasses to honor the contract defined by * {@link #isBackgroundPainted()} and {@link #setBackgroundPainted(boolean)}. * * @param g2 the graphics surface on which the background must be drawn * @see #setupGraphics(Graphics2D) * @see #paintExtra(Graphics2D) * @see #isBackgroundPainted() * @see #setBackgroundPainted(boolean) */ protected void paintBackground(Graphics2D g2) { if (isBackgroundPainted()) { Painter p = getBackgroundPainter(); if (p != null) { p.paint(g2, this, getWidth(), getHeight()); } else { g2.setColor(getBackground()); g2.fill(g2.getClipBounds()); } } }
/** * {@inheritDoc} */ @Override protected void doPaint(Graphics2D g, T component, int width, int height) { for (Painter<T> p : getPainters()) { Graphics2D temp = (Graphics2D) g.create(); try { p.paint(temp, component, width, height); if(isClipPreserved()) { g.setClip(temp.getClip()); } } finally { temp.dispose(); } } }
/** * {@inheritDoc} */ @Override public Raster getRaster(int x, int y, int w, int h) { if (saved == null || saved.getWidth() != w || saved.getHeight() != h) { saved = GraphicsUtilities.createCompatibleImage(w, h); Graphics2D g2d = saved.createGraphics(); try { if (painter instanceof AbstractPainter) { ((AbstractPainter<?>) painter).setInPaintContext(true); } painter.paint(g2d, object, w, h); } finally { g2d.dispose(); if (painter instanceof AbstractPainter) { ((AbstractPainter<?>) painter).setInPaintContext(false); } } } return saved.getData(); } }
/** * {@inheritDoc} */ @Override public void paint(Graphics2D g, T component, int width, int height) { if (p != null) { p.paint(g, component, width, height); } } }