Java Code Examples for java.awt.Graphics#copyArea()
The following examples show how to use
java.awt.Graphics#copyArea() .
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: MiscTests.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 7 votes |
public void runTest(Object ctx, int numReps) { GraphicsTests.Context gctx = (GraphicsTests.Context)ctx; int size = gctx.size; int x = gctx.initX; int y = gctx.initY; Graphics g = gctx.graphics; g.translate(gctx.orgX, gctx.orgY); if (gctx.animate) { do { g.copyArea(x, y, size, size, dx, dy); if ((x -= 3) < 0) x += gctx.maxX; if ((y -= 1) < 0) y += gctx.maxY; } while (--numReps > 0); } else { do { g.copyArea(x, y, size, size, dx, dy); } while (--numReps > 0); } g.translate(-gctx.orgX, -gctx.orgY); }
Example 2
Source File: MiscTests.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void runTest(Object ctx, int numReps) { GraphicsTests.Context gctx = (GraphicsTests.Context)ctx; int size = gctx.size; int x = gctx.initX; int y = gctx.initY; Graphics g = gctx.graphics; g.translate(gctx.orgX, gctx.orgY); if (gctx.animate) { do { g.copyArea(x, y, size, size, dx, dy); if ((x -= 3) < 0) x += gctx.maxX; if ((y -= 1) < 0) y += gctx.maxY; } while (--numReps > 0); } else { do { g.copyArea(x, y, size, size, dx, dy); } while (--numReps > 0); } g.translate(-gctx.orgX, -gctx.orgY); }
Example 3
Source File: ValidateCodeFactory.java From MicroCommunity with Apache License 2.0 | 6 votes |
private static void shearY(Graphics g, int w1, int h1, Color color) { int period = random.nextInt(40) + 10; // 50; boolean borderGap = true; int frames = 20; int phase = 7; for (int i = 0; i < w1; i++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); g.copyArea(i, 0, 1, h1, 0, (int) d); if (borderGap) { g.setColor(color); g.drawLine(i, (int) d, i, 0); g.drawLine(i, (int) d + h1, i, h1); } } }
Example 4
Source File: ValidateCodeFactory.java From MicroCommunity with Apache License 2.0 | 6 votes |
private static void shearX(Graphics g, int w1, int h1, Color color) { int period = random.nextInt(2); boolean borderGap = true; int frames = 1; int phase = random.nextInt(2); for (int i = 0; i < h1; i++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); g.copyArea(0, i, w1, 1, (int) d, 0); if (borderGap) { g.setColor(color); g.drawLine((int) d, i, 0, i); g.drawLine((int) d + w1, i, w1, i); } } }
Example 5
Source File: Capts.java From HongsCORE with MIT License | 6 votes |
private void shearX(int w, int h, Graphics g, Random r, Color c) { int x = (int) (0.2f * h); int period = r.nextInt(x)+ x; int phases = r.nextInt(x)+ x; int frames = r.nextInt(w - 2) + 2; for (int i = 0; i < h; i ++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phases) / (double) frames); g.copyArea(0, i, w, 1, (int) d, 0); g.setColor(c); g.drawLine((int) d, i, 0, i ); g.drawLine((int) d+ w, i, w, i); } }
Example 6
Source File: MiscTests.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void runTest(Object ctx, int numReps) { GraphicsTests.Context gctx = (GraphicsTests.Context)ctx; int size = gctx.size; int x = gctx.initX; int y = gctx.initY; Graphics g = gctx.graphics; g.translate(gctx.orgX, gctx.orgY); if (gctx.animate) { do { g.copyArea(x, y, size, size, dx, dy); if ((x -= 3) < 0) x += gctx.maxX; if ((y -= 1) < 0) y += gctx.maxY; } while (--numReps > 0); } else { do { g.copyArea(x, y, size, size, dx, dy); } while (--numReps > 0); } g.translate(-gctx.orgX, -gctx.orgY); }
Example 7
Source File: CaptchaUtils.java From ueboot with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static void shearY(Graphics g, int w1, int h1, Color color) { int period = random.nextInt(40) + 10; boolean borderGap = true; int frames = 20; int phase = 7; for(int i = 0; i < w1; ++i) { double d = (double)(period >> 1) * Math.sin((double)i / (double)period + 6.283185307179586D * (double)phase / (double)frames); g.copyArea(i, 0, 1, h1, 0, (int)d); if(borderGap) { g.setColor(color); g.drawLine(i, (int)d, i, 0); g.drawLine(i, (int)d + h1, i, h1); } } }
Example 8
Source File: MiscTests.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void runTest(Object ctx, int numReps) { GraphicsTests.Context gctx = (GraphicsTests.Context)ctx; int size = gctx.size; int x = gctx.initX; int y = gctx.initY; Graphics g = gctx.graphics; g.translate(gctx.orgX, gctx.orgY); if (gctx.animate) { do { g.copyArea(x, y, size, size, dx, dy); if ((x -= 3) < 0) x += gctx.maxX; if ((y -= 1) < 0) y += gctx.maxY; } while (--numReps > 0); } else { do { g.copyArea(x, y, size, size, dx, dy); } while (--numReps > 0); } g.translate(-gctx.orgX, -gctx.orgY); }
Example 9
Source File: CodeOfLogin.java From OASystem with MIT License | 6 votes |
private static void shearY(Graphics g, int w1, int h1, Color color) { int period = random.nextInt(40) + 10; // 50; boolean borderGap = true; int frames = 20; int phase = 7; for (int i = 0; i < w1; i++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); g.copyArea(i, 0, 1, h1, 0, (int) d); if (borderGap) { g.setColor(color); g.drawLine(i, (int) d, i, 0); g.drawLine(i, (int) d + h1, i, h1); } } }
Example 10
Source File: MiscTests.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void runTest(Object ctx, int numReps) { GraphicsTests.Context gctx = (GraphicsTests.Context)ctx; int size = gctx.size; int x = gctx.initX; int y = gctx.initY; Graphics g = gctx.graphics; g.translate(gctx.orgX, gctx.orgY); if (gctx.animate) { do { g.copyArea(x, y, size, size, dx, dy); if ((x -= 3) < 0) x += gctx.maxX; if ((y -= 1) < 0) y += gctx.maxY; } while (--numReps > 0); } else { do { g.copyArea(x, y, size, size, dx, dy); } while (--numReps > 0); } g.translate(-gctx.orgX, -gctx.orgY); }
Example 11
Source File: MiscTests.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void runTest(Object ctx, int numReps) { GraphicsTests.Context gctx = (GraphicsTests.Context)ctx; int size = gctx.size; int x = gctx.initX; int y = gctx.initY; Graphics g = gctx.graphics; g.translate(gctx.orgX, gctx.orgY); if (gctx.animate) { do { g.copyArea(x, y, size, size, dx, dy); if ((x -= 3) < 0) x += gctx.maxX; if ((y -= 1) < 0) y += gctx.maxY; } while (--numReps > 0); } else { do { g.copyArea(x, y, size, size, dx, dy); } while (--numReps > 0); } g.translate(-gctx.orgX, -gctx.orgY); }
Example 12
Source File: Capts.java From HongsCORE with MIT License | 6 votes |
private void shearY(int w, int h, Graphics g, Random r, Color c) { int x = (int) (0.2f * h); int period = r.nextInt(x)+ x; int phases = r.nextInt(x)+ x; int frames = r.nextInt(w - 2) + 2; for (int i = 0; i < w; i ++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phases) / (double) frames); g.copyArea(i, 0, 1, h, 0, (int) d); g.setColor(c); g.drawLine(i, (int) d, i, 0 ); g.drawLine(i, (int) d+ h, i, h); } }
Example 13
Source File: ShiftFilter.java From GIFKR with GNU Lesser General Public License v3.0 | 6 votes |
@Override public BufferedImage apply(BufferedImage img) { int size = (int) (squareSize * Math.min(img.getWidth(), img.getHeight())); int shift = (int) (distance * Math.min(img.getWidth(), img.getHeight())); for(int i = 0; i < passes; i++) { int x = (int) (rand.nextDouble() * (img.getWidth()-size)); int y = (int) (rand.nextDouble() * (img.getHeight()-size)); Graphics g = img.getGraphics(); g.copyArea(x, y, size, size, (int) ((rand.nextDouble()-.5) * shift), (int) ((rand.nextDouble()-.5) * shift)); } return img; }
Example 14
Source File: VerifyCodeUtils.java From console with Apache License 2.0 | 6 votes |
private static void shearX(Graphics g, int w1, int h1, Color color) { int period = random.nextInt(2); boolean borderGap = true; int frames = 1; int phase = random.nextInt(2); for (int i = 0; i < h1; i++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); g.copyArea(0, i, w1, 1, (int) d, 0); if (borderGap) { g.setColor(color); g.drawLine((int) d, i, 0, i); g.drawLine((int) d + w1, i, w1, i); } } }
Example 15
Source File: MiscTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void runTest(Object ctx, int numReps) { GraphicsTests.Context gctx = (GraphicsTests.Context)ctx; int size = gctx.size; int x = gctx.initX; int y = gctx.initY; Graphics g = gctx.graphics; g.translate(gctx.orgX, gctx.orgY); if (gctx.animate) { do { g.copyArea(x, y, size, size, dx, dy); if ((x -= 3) < 0) x += gctx.maxX; if ((y -= 1) < 0) y += gctx.maxY; } while (--numReps > 0); } else { do { g.copyArea(x, y, size, size, dx, dy); } while (--numReps > 0); } g.translate(-gctx.orgX, -gctx.orgY); }
Example 16
Source File: VerifyCodeUtil.java From anyline with Apache License 2.0 | 6 votes |
private static void shearX(Graphics g, int w1, int h1, Color color) { int period = random.nextInt(2); boolean borderGap = true; int frames = 1; int phase = random.nextInt(2); for (int i = 0; i < h1; i++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); g.copyArea(0, i, w1, 1, (int) d, 0); if (borderGap) { g.setColor(color); g.drawLine((int) d, i, 0, i); g.drawLine((int) d + w1, i, w1, i); } } }
Example 17
Source File: MiscTests.java From hottub with GNU General Public License v2.0 | 6 votes |
public void runTest(Object ctx, int numReps) { GraphicsTests.Context gctx = (GraphicsTests.Context)ctx; int size = gctx.size; int x = gctx.initX; int y = gctx.initY; Graphics g = gctx.graphics; g.translate(gctx.orgX, gctx.orgY); if (gctx.animate) { do { g.copyArea(x, y, size, size, dx, dy); if ((x -= 3) < 0) x += gctx.maxX; if ((y -= 1) < 0) y += gctx.maxY; } while (--numReps > 0); } else { do { g.copyArea(x, y, size, size, dx, dy); } while (--numReps > 0); } g.translate(-gctx.orgX, -gctx.orgY); }
Example 18
Source File: TokenImgGenerator.java From WeBASE-Node-Manager with Apache License 2.0 | 6 votes |
public static void shearY(Graphics g, int w1, int h1, Color color) { int period = generator.nextInt(5) + 2; // 50; boolean borderGap = true; int frames = 20; int phase = 7; for (int i = 0; i < w1; i++) { double d = (double) (period >> 1) * Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames); g.copyArea(i, 0, 1, h1, 0, (int) d); if (borderGap) { g.setColor(color); g.drawLine(i, (int) d, i, 0); g.drawLine(i, (int) d + h1, i, h1); } } }
Example 19
Source File: CopyAreaPerformance.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void paintComponent(Graphics g) { long startTime = System.nanoTime(); // prevVX is set to -10000 when first enabled if (useCopyArea && prevVX > -9999) { // Most of this code determines the proper areas to copy and clip int scrollX = viewX - prevVX; int scrollY = viewY - prevVY; int copyFromY, copyFromX; int clipFromY, clipFromX; if (scrollX == 0) { // vertical scroll if (scrollY < 0) { copyFromY = 0; clipFromY = 0; } else { copyFromY = scrollY; clipFromY = getHeight() - scrollY; } // copy the old content, set the clip to the new area g.copyArea(0, copyFromY, getWidth(), getHeight() - Math.abs(scrollY), 0, -scrollY); g.setClip(0, clipFromY, getWidth(), Math.abs(scrollY)); } else { // horizontal scroll if (scrollX < 0) { copyFromX = 0; clipFromX = 0; } else { copyFromX = scrollX; clipFromX = getWidth() - scrollX; } // copy the old content, set the clip to the new area g.copyArea(copyFromX, 0, getWidth() - Math.abs(scrollX), getHeight(), -scrollX, 0); g.setClip(clipFromX, 0, Math.abs(scrollX), getHeight()); } } // Track previous view position for next scrolling operation prevVX = viewX; prevVY = viewY; // Get the clip in case we need it later Rectangle clipRect = g.getClip().getBounds(); int clipL = (int)(clipRect.getX()); int clipT = (int)(clipRect.getY()); int clipR = (int)(clipRect.getMaxX()); int clipB = (int)(clipRect.getMaxY()); g.setColor(Color.WHITE); g.fillRect(clipL, clipT, (int)clipRect.getWidth(), (int)clipRect.getHeight()); for (int column = 0; column < 256; ++column) { int x = column * (SMILEY_SIZE + PADDING) - viewX; if (useClip) { if (x > clipR || (x + (SMILEY_SIZE + PADDING)) < clipL) { // trivial reject; outside to the left or right continue; } } for (int row = 0; row < 256; ++row) { int y = row * (SMILEY_SIZE + PADDING) - viewY; if (useClip) { if (y > clipB || (y + (SMILEY_SIZE + PADDING)) < clipT) { // trivial reject; outside to the top or bottom continue; } } Color faceColor = new Color(column, row, 0); drawSmiley(g, faceColor, x, y); } } long stopTime = System.nanoTime(); System.out.println("Painted in " + ((stopTime - startTime) / 1000000) + " ms"); }
Example 20
Source File: TransformableCanvasComponent.java From netbeans with Apache License 2.0 | 4 votes |
private void shift(Graphics g, int idx, int idy, int width, int height) { Rectangle areaToRepaint = new Rectangle(); if (idx == 0) { // Vertical shift if (idy > 0) { // --- Shift down -------------------------------------- g.copyArea(0, 0, width, height - idy, 0, idy); areaToRepaint.setBounds(0, 0, width, idy); } else { // --- Shift up ---------------------------------------- g.copyArea(0, -idy, width, height + idy, 0, idy); areaToRepaint.setBounds(0, height + idy, width, -idy); } } else if (idy == 0) { // Horizontal shift if (idx > 0) { // --- Shift right ------------------------------------- g.copyArea(0, 0, width - idx, height, idx, 0); areaToRepaint.setBounds(0, 0, idx, height); } else { // --- Shift left -------------------------------------- g.copyArea(-idx, 0, width + idx, height, idx, 0); areaToRepaint.setBounds(width + idx, 0, -idx, height); } } else { // Diagonal shift if (idx > 0) { // Shift right if (idy > 0) { // --- Shift right down ------------------------ g.copyArea(0, 0, width - idx, height - idy, idx, idy); areaToRepaint.setBounds(0, 0, width, idy); paintContents(g, areaToRepaint); areaToRepaint.setBounds(0, idy, idx, height - idy); } else { // --- Shift right up -------------------------- g.copyArea(0, -idy, width - idx, height + idy, idx, idy); areaToRepaint.setBounds(0, height + idy, width, -idy); paintContents(g, areaToRepaint); areaToRepaint.setBounds(0, 0, idx, height + idy); } } else { // Shift left if (idy > 0) { // --- Shift left down ------------------------- g.copyArea(-idx, 0, width + idx, height - idy, idx, idy); areaToRepaint.setBounds(0, 0, width, idy); paintContents(g, areaToRepaint); areaToRepaint.setBounds(width + idx, idy, -idx, height - idy); } else { // --- Shift left up --------------------------- g.copyArea(-idx, -idy, width + idx, height + idy, idx, idy); areaToRepaint.setBounds(0, height + idy, width, -idy); paintContents(g, areaToRepaint); areaToRepaint.setBounds(width + idx, 0, -idx, height + idy); } } } paintContents(g, areaToRepaint); }