📄 drawnshape.java
字号:
import java.awt.*;
import java.io.Serializable;
public abstract class DrawnShape implements Serializable{
public DrawnShape(Color color, int x, int y, String text) {
this.color = color;
this.x1 = x;
this.y1 = y;
this.x2 = x;
this.y2 = y;
this.text = text;
}
public abstract void draw(Graphics g);
public void changeEnd(int x, int y) {
x2 = x;
y2 = y;
}
public void makePermanent() {
perm = true;
}
public boolean isPermanent() {
return perm;
}
public Rectangle getBoundingBox() {
rect.width = x2 > x1 ? x2 - x1 + 1: x1 - x2 + 1;
rect.height = y2 > y1 ? y2 - y1 + 1: y1 - y2 + 1;
rect.x = x1 < x2 ? x1 : x2;
rect.y = y1 < y2 ? y1 : y2;
return rect;
}
// Get the text for the shape
public String getText() {
return text;
}
protected Color color; // Pen color
protected int x1; // Start...
protected int y1; // ... point
protected int x2; // End...
protected int y2; // ... point
protected boolean perm; // Permanent or not
protected String text; // Description
protected Rectangle rect = new Rectangle();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -