当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.copyArea方法代码示例

本文整理汇总了Java中java.awt.Graphics.copyArea方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.copyArea方法的具体用法?Java Graphics.copyArea怎么用?Java Graphics.copyArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics的用法示例。


在下文中一共展示了Graphics.copyArea方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import java.awt.Graphics; //导入方法依赖的package包/类
@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;
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:18,代码来源:ShiftFilter.java

示例2: runTest

import java.awt.Graphics; //导入方法依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:MiscTests.java

示例3: shearX

import java.awt.Graphics; //导入方法依赖的package包/类
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);  
          }  
      }  

  }
 
开发者ID:lemon-china,项目名称:lemon-framework,代码行数:23,代码来源:VerifyCodeUtils.java

示例4: shearX

import java.awt.Graphics; //导入方法依赖的package包/类
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);
            }
        }

    }
 
开发者ID:Topview-us,项目名称:school-website,代码行数:23,代码来源:VerifyCodeUtils.java

示例5: shearY

import java.awt.Graphics; //导入方法依赖的package包/类
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);
            }

        }

    }
 
开发者ID:Topview-us,项目名称:school-website,代码行数:23,代码来源:VerifyCodeUtils.java

示例6: shearY

import java.awt.Graphics; //导入方法依赖的package包/类
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);  
          }  

      }  

  }
 
开发者ID:lemon-china,项目名称:lemon-framework,代码行数:23,代码来源:VerifyCodeUtils.java

示例7: shift

import java.awt.Graphics; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:63,代码来源:TransformableCanvasComponent.java

示例8: doPaint

import java.awt.Graphics; //导入方法依赖的package包/类
/**
    * doPaint is the method that handles the drawing of the box to the screen.
    * Several variables and conditions affect how the image is drawn.  First,
    * the Unit.Length.Sim class variable <code>TO_PIXELS</code> performs the conversion between simulation
    * length units (Angstroms) and pixels.  The default value is 10 pixels/Angstrom
    * reflecting the default size of the box (300 pixels by 300 pixels) and the
    * default box size (30 by 30 A).  
    * The field <code>scale</code> is a multiplicative factor that directly
    * scales up or down the size of the image; this value is adjusted automatically
    * whenever shells of periodic images are drawn, to permit the central image and all 
    * of the specified periodic images to fit in the drawing of the box.  
    *
    * @param g The graphic object to which the image of the box is drawn
    */
    public void doPaint(Graphics g) {
        if(!isVisible() || displayBox.getBox() == null) {return;}
        int w = getSize().width;
        int h = getSize().height;
            
        g.setColor(getBackground());
        g.fillRect(0,0,w,h);
        displayBox.computeImageParameters2(w, h);

        //Draw other features if indicated
//        if(drawBoundary>DRAW_BOUNDARY_NONE) {displayBox.getBox().boundary().draw(g, displayBox.getOrigin(), displayBox.getScale());}
//        if(displayBox.getDrawBoundary()) {displayBox.getBox().boundary().draw(g, displayBox.getOrigin(), displayBox.getScale());}

        //do drawing of all drawing objects that have been added to the display
        for(Iterator iter=displayBox.getDrawables().iterator(); iter.hasNext(); ) {
            Drawable obj = (Drawable)iter.next();
            obj.draw(g, displayBox.getOrigin(), displayBox.getToPixels());
        }
           
        int [] origin = displayBox.getOrigin();
        atomOrigin[0] =origin[0] + (int)(0.5*displayBox.getToPixels()*displayBox.getBox().getBoundary().getBoxSize().getX(0));
        atomOrigin[1] =origin[1];
        
        //Draw all atoms
        if(displayBox.getColorScheme() instanceof ColorSchemeCollective) {
            ((ColorSchemeCollective)displayBox.getColorScheme()).colorAllAtoms();
        }
        IAtomList leafList = displayBox.getBox().getLeafList();
        int nLeaf = leafList.getAtomCount();
        AtomFilter atomFilter = displayBox.getAtomFilter();
        if (atomFilter instanceof AtomFilterCollective) {
            ((AtomFilterCollective)atomFilter).resetFilter();
        }
        for (int iLeaf=0; iLeaf<nLeaf; iLeaf++) {
            IAtom a = leafList.getAtom(iLeaf);
            if(atomFilter != null && atomFilter.test(a)) continue;
            drawAtom(g, atomOrigin, a);
        }
            
        //Draw overflow images if so indicated
        //This needs some work to make more general
///        for(Atom a=displayBox.getBox().firstAtom(); a!=null; a=a.nextAtom()) {
///            if(computeShiftOrigin(a, boundary)) {
///                drawAtom(g, shiftOrigin, a);
///            }
///        }

        //Draw periodic images if indicated ONLY for an etomica Boundary
        if(displayBox.getBox().getBoundary() instanceof Boundary) {
	        if(displayBox.getImageShells() > 0) {
	            double[][] origins = ((Boundary)displayBox.getBox().getBoundary()).imageOrigins(displayBox.getImageShells());  //more efficient to save rather than recompute each time
	            for(int i=0; i<origins.length; i++) {
	                g.copyArea(displayBox.getOrigin()[0],displayBox.getOrigin()[1],displayBox.getDrawSize()[0],displayBox.getDrawSize()[1],(int)(displayBox.getToPixels()*origins[i][0]),(int)(displayBox.getToPixels()*origins[i][1]));
	            }
	        }
        }
        //Draw bar showing scale if indicated
        if(writeScale) {
            g.setColor(Color.lightGray);
            g.fillRect(0,getSize().height-annotationHeight,getSize().width,annotationHeight);
            g.setColor(Color.black);
            g.setFont(font);
            g.drawString("Scale: "+Integer.toString((int)(100*displayBox.getScale()))+"%", 0, getSize().height-3);
        }
    }
 
开发者ID:etomica,项目名称:etomica,代码行数:80,代码来源:DisplayBoxCanvas1D.java


注:本文中的java.awt.Graphics.copyArea方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。