drawing.java
来自「设计模式是软件工程的核心思想」· Java 代码 · 共 40 行
JAVA
40 行
import java.awt.*;
public class Drawing
{
protected int x, y, w, h;
protected Rectangle rect;
protected boolean selected;
protected boolean filled;
protected Color fillColor;
//-------------------------------------------
public void setSelected(boolean b)
{
selected = b;
}
public void draw(Graphics g){}
public void move(int xpt, int ypt)
{
x = xpt;
y = ypt;
}
public boolean contains(int x, int y)
{
return rect.contains(x, y);
}
//-------------------------------------------
protected void saveAsRect()
{
rect = new Rectangle(x-w/2, y-h/2, w, h);
}
//-------------------------------------------
protected void setFill(Color c)
{
filled = true;
fillColor = c;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?