Java Code Examples for java.awt.Graphics#clearRect()
The following examples show how to use
java.awt.Graphics#clearRect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PolygonPanel.java From jenetics with Apache License 2.0 | 6 votes |
@Override protected void paintComponent(final Graphics g) { super.paintComponent(g); if (_chromosome != null) { _chromosome.draw((Graphics2D) g, width(), height()); } else { g.setColor(Color.white); g.clearRect(0, 0, width(), height()); } }
Example 2
Source File: WCanvasPeer.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics g) { Dimension d = ((Component)target).getSize(); if (g instanceof Graphics2D || g instanceof sun.awt.Graphics2Delegate) { // background color is setup correctly, so just use clearRect g.clearRect(0, 0, d.width, d.height); } else { // emulate clearRect g.setColor(((Component)target).getBackground()); g.fillRect(0, 0, d.width, d.height); g.setColor(((Component)target).getForeground()); } super.paint(g); }
Example 3
Source File: XYZApp.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void update(Graphics g) { if (backBuffer == null) { g.clearRect(0, 0, getSize().width, getSize().height); } paint(g); }
Example 4
Source File: WCanvasPeer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics g) { Dimension d = ((Component)target).getSize(); if (g instanceof Graphics2D || g instanceof sun.awt.Graphics2Delegate) { // background color is setup correctly, so just use clearRect g.clearRect(0, 0, d.width, d.height); } else { // emulate clearRect g.setColor(((Component)target).getBackground()); g.fillRect(0, 0, d.width, d.height); g.setColor(((Component)target).getForeground()); } super.paint(g); }
Example 5
Source File: VolatileSurfaceManager.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * Set contents of the current SurfaceData to default state (i.e. clear * the background). */ public void initContents() { // images with forced acceleration type may have a null sdCurrent // because we do not create a backup surface for them if (sdCurrent != null) { Graphics g = vImg.createGraphics(); g.clearRect(0, 0, vImg.getWidth(), vImg.getHeight()); g.dispose(); } }
Example 6
Source File: VolatileSurfaceManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Set contents of the current SurfaceData to default state (i.e. clear * the background). */ public void initContents() { // images with forced acceleration type may have a null sdCurrent // because we do not create a backup surface for them if (sdCurrent != null) { Graphics g = vImg.createGraphics(); g.clearRect(0, 0, vImg.getWidth(), vImg.getHeight()); g.dispose(); } }
Example 7
Source File: WCanvasPeer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics g) { Dimension d = ((Component)target).getSize(); if (g instanceof Graphics2D || g instanceof sun.awt.Graphics2Delegate) { // background color is setup correctly, so just use clearRect g.clearRect(0, 0, d.width, d.height); } else { // emulate clearRect g.setColor(((Component)target).getBackground()); g.fillRect(0, 0, d.width, d.height); g.setColor(((Component)target).getForeground()); } super.paint(g); }
Example 8
Source File: XYZApp.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public void update(Graphics g) { if (backBuffer == null) { g.clearRect(0, 0, getSize().width, getSize().height); } paint(g); }
Example 9
Source File: VolatileSurfaceManager.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Set contents of the current SurfaceData to default state (i.e. clear * the background). */ public void initContents() { // images with forced acceleration type may have a null sdCurrent // because we do not create a backup surface for them if (sdCurrent != null) { Graphics g = vImg.createGraphics(); g.clearRect(0, 0, vImg.getWidth(), vImg.getHeight()); g.dispose(); } }
Example 10
Source File: XYZApp.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void update(Graphics g) { if (backBuffer == null) { g.clearRect(0, 0, getSize().width, getSize().height); } paint(g); }
Example 11
Source File: WCanvasPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics g) { Dimension d = ((Component)target).getSize(); if (g instanceof Graphics2D || g instanceof sun.awt.Graphics2Delegate) { // background color is setup correctly, so just use clearRect g.clearRect(0, 0, d.width, d.height); } else { // emulate clearRect g.setColor(((Component)target).getBackground()); g.fillRect(0, 0, d.width, d.height); g.setColor(((Component)target).getForeground()); } super.paint(g); }
Example 12
Source File: VolatileSurfaceManager.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Set contents of the current SurfaceData to default state (i.e. clear * the background). */ public void initContents() { // images with forced acceleration type may have a null sdCurrent // because we do not create a backup surface for them if (sdCurrent != null) { Graphics g = vImg.createGraphics(); g.clearRect(0, 0, vImg.getWidth(), vImg.getHeight()); g.dispose(); } }
Example 13
Source File: WCanvasPeer.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics g) { Dimension d = ((Component)target).getSize(); if (g instanceof Graphics2D || g instanceof sun.awt.Graphics2Delegate) { // background color is setup correctly, so just use clearRect g.clearRect(0, 0, d.width, d.height); } else { // emulate clearRect g.setColor(((Component)target).getBackground()); g.fillRect(0, 0, d.width, d.height); g.setColor(((Component)target).getForeground()); } super.paint(g); }
Example 14
Source File: WCanvasPeer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override public void paint(Graphics g) { Dimension d = ((Component)target).getSize(); if (g instanceof Graphics2D || g instanceof sun.awt.Graphics2Delegate) { // background color is setup correctly, so just use clearRect g.clearRect(0, 0, d.width, d.height); } else { // emulate clearRect g.setColor(((Component)target).getBackground()); g.fillRect(0, 0, d.width, d.height); g.setColor(((Component)target).getForeground()); } super.paint(g); }
Example 15
Source File: HistogramPanel.java From pdfxtk with Apache License 2.0 | 5 votes |
/** Paints the histogram component. @param g graphics context */ protected void paintComponent(Graphics g) { size = getSize(null); g.clearRect(0, 0, size.width, size.height); int[][] bins = histogram.getBins(); int numBands = bins.length; int highValue = 0; for (int band = 0; band < numBands; band++) { for (int bin = 0; bin < bins[band].length; bin++) { highValue = Math.max(highValue, bins[band][bin]); } } for (int band = 0; band < numBands; band++) { g.setColor(bandColor[band]); for (int bin = 0; bin < bins[band].length; bin++) { int xpos = ((bin*numBands)+band) * size.width / (maxBins*numBands); int xpos2 = ((bin*numBands)+(band+1)) * size.width / (maxBins*numBands); int ysize = size.height * bins[band][bin] / highValue; g.fillRect(xpos, size.height-ysize, xpos2-xpos, ysize); } } }
Example 16
Source File: RepaintArea.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Invokes paint and update on target Component with optimal * rectangular clip region. * If PAINT bounding rectangle is less than * MAX_BENEFIT_RATIO times the benefit, then the vertical and horizontal unions are * painted separately. Otherwise the entire bounding rectangle is painted. * * @param target Component to <code>paint</code> or <code>update</code> * @since 1.4 */ public void paint(Object target, boolean shouldClearRectBeforePaint) { Component comp = (Component)target; if (isEmpty()) { return; } if (!comp.isVisible()) { return; } RepaintArea ra = this.cloneAndReset(); if (!subtract(ra.paintRects[VERTICAL], ra.paintRects[HORIZONTAL])) { subtract(ra.paintRects[HORIZONTAL], ra.paintRects[VERTICAL]); } if (ra.paintRects[HORIZONTAL] != null && ra.paintRects[VERTICAL] != null) { Rectangle paintRect = ra.paintRects[HORIZONTAL].union(ra.paintRects[VERTICAL]); int square = paintRect.width * paintRect.height; int benefit = square - ra.paintRects[HORIZONTAL].width * ra.paintRects[HORIZONTAL].height - ra.paintRects[VERTICAL].width * ra.paintRects[VERTICAL].height; // if benefit is comparable with bounding box if (MAX_BENEFIT_RATIO * benefit < square) { ra.paintRects[HORIZONTAL] = paintRect; ra.paintRects[VERTICAL] = null; } } for (int i = 0; i < paintRects.length; i++) { if (ra.paintRects[i] != null && !ra.paintRects[i].isEmpty()) { // Should use separate Graphics for each paint() call, // since paint() can change Graphics state for next call. Graphics g = comp.getGraphics(); if (g != null) { try { g.setClip(ra.paintRects[i]); if (i == UPDATE) { updateComponent(comp, g); } else { if (shouldClearRectBeforePaint) { g.clearRect( ra.paintRects[i].x, ra.paintRects[i].y, ra.paintRects[i].width, ra.paintRects[i].height); } paintComponent(comp, g); } } finally { g.dispose(); } } } } }
Example 17
Source File: RepaintArea.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Invokes paint and update on target Component with optimal * rectangular clip region. * If PAINT bounding rectangle is less than * MAX_BENEFIT_RATIO times the benefit, then the vertical and horizontal unions are * painted separately. Otherwise the entire bounding rectangle is painted. * * @param target Component to {@code paint} or {@code update} * @since 1.4 */ public void paint(Object target, boolean shouldClearRectBeforePaint) { Component comp = (Component)target; if (isEmpty()) { return; } if (!comp.isVisible()) { return; } RepaintArea ra = this.cloneAndReset(); if (!subtract(ra.paintRects[VERTICAL], ra.paintRects[HORIZONTAL])) { subtract(ra.paintRects[HORIZONTAL], ra.paintRects[VERTICAL]); } if (ra.paintRects[HORIZONTAL] != null && ra.paintRects[VERTICAL] != null) { Rectangle paintRect = ra.paintRects[HORIZONTAL].union(ra.paintRects[VERTICAL]); int square = paintRect.width * paintRect.height; int benefit = square - ra.paintRects[HORIZONTAL].width * ra.paintRects[HORIZONTAL].height - ra.paintRects[VERTICAL].width * ra.paintRects[VERTICAL].height; // if benefit is comparable with bounding box if (MAX_BENEFIT_RATIO * benefit < square) { ra.paintRects[HORIZONTAL] = paintRect; ra.paintRects[VERTICAL] = null; } } for (int i = 0; i < paintRects.length; i++) { if (ra.paintRects[i] != null && !ra.paintRects[i].isEmpty()) { // Should use separate Graphics for each paint() call, // since paint() can change Graphics state for next call. Graphics g = comp.getGraphics(); if (g != null) { try { g.setClip(ra.paintRects[i]); if (i == UPDATE) { updateComponent(comp, g); } else { if (shouldClearRectBeforePaint) { g.clearRect( ra.paintRects[i].x, ra.paintRects[i].y, ra.paintRects[i].width, ra.paintRects[i].height); } paintComponent(comp, g); } } finally { g.dispose(); } } } } }
Example 18
Source File: RepaintArea.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Invokes paint and update on target Component with optimal * rectangular clip region. * If PAINT bounding rectangle is less than * MAX_BENEFIT_RATIO times the benefit, then the vertical and horizontal unions are * painted separately. Otherwise the entire bounding rectangle is painted. * * @param target Component to <code>paint</code> or <code>update</code> * @since 1.4 */ public void paint(Object target, boolean shouldClearRectBeforePaint) { Component comp = (Component)target; if (isEmpty()) { return; } if (!comp.isVisible()) { return; } RepaintArea ra = this.cloneAndReset(); if (!subtract(ra.paintRects[VERTICAL], ra.paintRects[HORIZONTAL])) { subtract(ra.paintRects[HORIZONTAL], ra.paintRects[VERTICAL]); } if (ra.paintRects[HORIZONTAL] != null && ra.paintRects[VERTICAL] != null) { Rectangle paintRect = ra.paintRects[HORIZONTAL].union(ra.paintRects[VERTICAL]); int square = paintRect.width * paintRect.height; int benefit = square - ra.paintRects[HORIZONTAL].width * ra.paintRects[HORIZONTAL].height - ra.paintRects[VERTICAL].width * ra.paintRects[VERTICAL].height; // if benefit is comparable with bounding box if (MAX_BENEFIT_RATIO * benefit < square) { ra.paintRects[HORIZONTAL] = paintRect; ra.paintRects[VERTICAL] = null; } } for (int i = 0; i < paintRects.length; i++) { if (ra.paintRects[i] != null && !ra.paintRects[i].isEmpty()) { // Should use separate Graphics for each paint() call, // since paint() can change Graphics state for next call. Graphics g = comp.getGraphics(); if (g != null) { try { g.setClip(ra.paintRects[i]); if (i == UPDATE) { updateComponent(comp, g); } else { if (shouldClearRectBeforePaint) { g.clearRect( ra.paintRects[i].x, ra.paintRects[i].y, ra.paintRects[i].width, ra.paintRects[i].height); } paintComponent(comp, g); } } finally { g.dispose(); } } } } }
Example 19
Source File: RepaintArea.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Invokes paint and update on target Component with optimal * rectangular clip region. * If PAINT bounding rectangle is less than * MAX_BENEFIT_RATIO times the benefit, then the vertical and horizontal unions are * painted separately. Otherwise the entire bounding rectangle is painted. * * @param target Component to <code>paint</code> or <code>update</code> * @since 1.4 */ public void paint(Object target, boolean shouldClearRectBeforePaint) { Component comp = (Component)target; if (isEmpty()) { return; } if (!comp.isVisible()) { return; } RepaintArea ra = this.cloneAndReset(); if (!subtract(ra.paintRects[VERTICAL], ra.paintRects[HORIZONTAL])) { subtract(ra.paintRects[HORIZONTAL], ra.paintRects[VERTICAL]); } if (ra.paintRects[HORIZONTAL] != null && ra.paintRects[VERTICAL] != null) { Rectangle paintRect = ra.paintRects[HORIZONTAL].union(ra.paintRects[VERTICAL]); int square = paintRect.width * paintRect.height; int benefit = square - ra.paintRects[HORIZONTAL].width * ra.paintRects[HORIZONTAL].height - ra.paintRects[VERTICAL].width * ra.paintRects[VERTICAL].height; // if benefit is comparable with bounding box if (MAX_BENEFIT_RATIO * benefit < square) { ra.paintRects[HORIZONTAL] = paintRect; ra.paintRects[VERTICAL] = null; } } for (int i = 0; i < paintRects.length; i++) { if (ra.paintRects[i] != null && !ra.paintRects[i].isEmpty()) { // Should use separate Graphics for each paint() call, // since paint() can change Graphics state for next call. Graphics g = comp.getGraphics(); if (g != null) { try { g.setClip(ra.paintRects[i]); if (i == UPDATE) { updateComponent(comp, g); } else { if (shouldClearRectBeforePaint) { g.clearRect( ra.paintRects[i].x, ra.paintRects[i].y, ra.paintRects[i].width, ra.paintRects[i].height); } paintComponent(comp, g); } } finally { g.dispose(); } } } } }
Example 20
Source File: NativeView.java From noa-libre with GNU Lesser General Public License v2.1 | 3 votes |
/** * overload paint routine to show provide against * repaint errors if no office view is realy plugged * into this canvas. * If handle is present - we shouldn't paint anything further. * May the remote window is already plugged. In such case we * shouldn't paint it over. */ public void paint(Graphics aGraphic) { if (maHandle == null) { Dimension aSize = getSize(); aGraphic.clearRect(0, 0, aSize.width, aSize.height); } }