simpleshape.java

来自「简单的多字符java动画,方便理解Multi-threaded 的概念.」· Java 代码 · 共 96 行

JAVA
96
字号
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.ImageObserver;

/*
 * Created on 11/04/2007
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author Xuesong Le
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public abstract class SimpleShape
{
    
    protected
    	int
    		x=0,
    		y=0;
    Image
    	img = null;
    
    
    public SimpleShape()
    {
        return;
    }//End SimpleShape Constructor
    
    public SimpleShape(Image img)
    {
        this.img = img;
        return;
    }//End SimpleShape Constructor
       
    public void setImage(Image img)
    {
        this.img = img;
    }
    
    public Image getImage()
    {
        return img;
    }
    
    public int getX()
    {
        return x;
    }
    
    public int getY()
    {
        return y;
    }
    
    public void setX(int x)
    {
        this.x = x;
        return;
    }
    
    public void setY(int y)
    {
        this.y = y;
        return;
    }
    
    /**
     * 
     */
    public SimpleShape(int x, int y, Image img)
    {
        this.x = x;
        this.y = y;
        this.img = img;
        
        return;
    }

    public abstract void move(	int canvasWidth, 
            					int canvasHeight, 
            					ImageObserver observer);
    
    public void drawShape(Graphics g, ImageObserver observer)
    {
        g.drawImage(img,x,y,observer);
        
        return;
    }
   
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?