📄 yuanjian.java
字号:
public void yjpaint(Graphics2D g) {
g.setColor(Color.white);
g.drawRect(x, y, width, height);
}
public void yjpaint(Graphics2D g, Color c) {
g.setColor(c);
g.drawRect(x, y, width, height);
}
// 设置值后,同时更新坐标范围
public void setValue(int setX, int setY, int setWidth, int setHeight) {
x = setX;
y = setY;
width = setWidth;
height = setHeight;
// 计算范围
minX = x;
minY = y;
maxX = x + width;
maxY = y + height;
}
public yjRec getValue() {
yjRec tmpRec = new yjRec();
tmpRec.x = this.x;
tmpRec.y = this.y;
tmpRec.width = this.width;
tmpRec.height = this.height;
tmpRec.minX = this.minX;
tmpRec.minY = this.minY;
tmpRec.maxX = this.maxX;
tmpRec.maxY = this.maxY;
return tmpRec;
}
public boolean yjMovie(int x0, int y0) {
setValue(x0, y0, this.width, this.height);
return true;
}
}
/**************************************************/
class yjLine
extends yjBase {
public int x1, x2, y1, y2;
public void setValue(int x1, int y1, int x2, int y2) {
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
// 计算范围
if (x1 <= x2) {
minX = x1;
maxX = x2;
}
else {
minX = x2;
maxX = x1;
}
if (y1 <= y2) {
minY = y1;
maxY = y2;
}
else {
minY = y2;
maxY = y1;
}
this.x = minX;
this.y = minY;
if((minY == maxY)){
minY=minY-5;
maxY=maxY+5;
minX=minX-5;
maxX=maxX+3;
}
if((minX == maxX)){
minY=minY-5;
maxY=maxY+5;
minX=minX-5;
maxX=maxX+5;
}
}
public void yjpaint(Graphics2D g) {
g.setColor(Color.white);
g.drawLine(x1, y1, x2, y2);
}
public void yjpaint(Graphics2D g, Color c) {
g.setColor(c);
g.drawLine(x1, y1, x2, y2);
}
public yjLine getValue() {
yjLine tmpLine = new yjLine();
tmpLine.x1 = this.x1;
tmpLine.y1 = this.y1;
tmpLine.x2 = this.x2;
tmpLine.y2 = this.y2;
tmpLine.x = this.x;
tmpLine.y = this.y;
tmpLine.minX = this.minX;
tmpLine.minY = this.minY;
tmpLine.maxX = this.maxX;
tmpLine.maxY = this.maxY;
return tmpLine;
}
public boolean yjMovie(int x, int y) {
int xChg, yChg;
xChg = x - this.x;
yChg = y - this.y;
setValue(x1 + xChg, y1 + yChg, x2 + xChg, y2 + yChg);
return true;
}
}
/**************************************************/
class yjCircle
extends yjBase {
int r;
public void setValue(int setX, int setY, int setR) {
x = setX;
y = setY;
r = setR;
// 计算范围
minX = x - r;
minY = y - r;
maxX = x + r*2;
maxY = y + r*2;
}
public void setValue(int setX, int setY, int setR,int setfF) {
x = setX;
y = setY;
r = setR;
fillFlag = setfF;
// 计算范围
minX = x - r;
minY = y - r;
maxX = x + r*3;
maxY = y + r*3;
}
public void yjpaint(Graphics2D g) {
g.setColor(Color.white);
Arc2D.Float tmpCircle = new Arc2D.Float(x, y, r * 2, r * 2, 0, 360,
Arc2D.OPEN);
g.draw(tmpCircle);
}
public void yjpaint(Graphics2D g, Color c) {
g.setColor(c);
Arc2D.Float tmpCircle = new Arc2D.Float(x, y, r * 2, r * 2, 0, 360,
Arc2D.OPEN);
if(fillFlag==0){
g.draw(tmpCircle);
}else if(fillFlag==1){
g.fill(tmpCircle);
}
}
public yjCircle getValue() {
yjCircle tmpCir = new yjCircle();
tmpCir.x = this.x;
tmpCir.y = this.y;
tmpCir.r = this.r;
tmpCir.minX = this.minX;
tmpCir.minY = this.minY;
tmpCir.maxX = this.maxX;
tmpCir.maxY = this.maxY;
tmpCir.fillFlag = this.fillFlag;
return tmpCir;
}
public boolean yjMovie(int x, int y) {
setValue(x, y, this.r);
return true;
}
}
class yjPoint extends yjCircle{
public void yjpaint(Graphics2D g) {
g.setColor(Color.white);
Arc2D.Float tmpCircle = new Arc2D.Float(x, y, r * 2, r * 2, 0, 360,
Arc2D.OPEN);
g.draw(tmpCircle);
}
public void yjpaint(Graphics2D g, Color c) {
g.setColor(c);
Arc2D.Float tmpCircle = new Arc2D.Float(x, y, r * 2, r * 2, 0, 360,
Arc2D.OPEN);
g.draw(tmpCircle);
}
}
/**************************************************/
class yjStr
extends yjBase {
String str;
public void setValue(int setX, int setY, String setStr) {
x = setX;
y = setY;
str = setStr;
// 计算范围
minX = x;
minY = y - 20;
maxX = x + str.length() * 15;
maxY = y;
}
public void yjpaint(Graphics2D g) {
g.setColor(Color.white);
Font tmpF = new Font("Dialog", Font.PLAIN, 24);
g.setFont(tmpF);
g.drawString(str, x, y);
}
public void yjpaint(Graphics2D g, Color c) {
g.setColor(c);
Font tmpF = new Font("Dialog", Font.PLAIN, 12);
g.setFont(tmpF);
g.drawString(str, x, y);
}
public void yjpaint(Graphics2D g, Font tmpF, Color c) {
g.setColor(c);
g.setFont(tmpF);
g.drawString(str, x, y);
}
public yjStr getValue() {
yjStr tmpStr = new yjStr();
tmpStr.x = this.x;
tmpStr.y = this.y;
tmpStr.str = this.str;
tmpStr.minX = this.minX;
tmpStr.minY = this.minY;
tmpStr.maxX = this.maxX;
tmpStr.maxY = this.maxY;
return tmpStr;
}
public boolean yjMovie(int x, int y) {
setValue(x, y, this.str);
return true;
}
}
/**************************************************/
class yjArc
extends yjBase {
/**
* 圆弧的高度:构成该圆弧的椭圆的高度
* 圆弧的宽度:构成该圆弧的椭圆的宽度
*/
int width, height, startDu, Du, typeDu;
public yjArc() {
}
public void setValue(int x, int y, int width, int height, int startDu, int Du,
int typeDu) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.startDu = startDu;
this.Du = Du;
this.typeDu = typeDu;
minX = x;
minY = y;
maxX = x + width;
maxY = y + height;
}
public void yjpaint(Graphics2D g) {
g.setColor(Color.white);
Arc2D.Float tmpCircle = new Arc2D.Float(x, y, width, height, startDu, Du,
typeDu);
g.draw(tmpCircle);
}
public void yjpaint(Graphics2D g, Color c) {
g.setColor(c);
Arc2D.Float tmpCircle = new Arc2D.Float(x, y, width, height, startDu, Du,
typeDu);
g.draw(tmpCircle);
}
public yjArc getValue() {
yjArc tmpArc = new yjArc();
tmpArc.x = this.x;
tmpArc.y = this.y;
tmpArc.width = this.width;
tmpArc.height = this.height;
tmpArc.startDu = this.startDu;
tmpArc.Du = this.Du;
tmpArc.typeDu = this.typeDu;
tmpArc.minX = this.minX;
tmpArc.minY = this.minY;
tmpArc.maxX = this.maxX;
tmpArc.maxY = this.maxY;
return tmpArc;
}
public boolean yjMovie(int x, int y) {
setValue(x, y, this.width, this.height, this.startDu, this.Du, this.typeDu);
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -