📄 circle.java
字号:
/*
* 创建日期 2005-11-5
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package src;
/**
* @author flash
*
* TODO 要更改此生成的类型注释的模板,请转至 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
import java.awt.*;
import java.awt.event.*;
public class Circle implements Picture {
Stroke line_stroke = null;
Color line_color = null;
Color fill_color = null;
int startx = 0;
int starty = 0;
int endx = 0;
int endy = 0;
int width = 0;
int height = 0;
int oval = 0;
public Circle(Stroke line_stroke, Color line_color, Color fill_color,
int startx, int starty, int oval) {
this.line_stroke = line_stroke;
this.line_color = line_color;
this.fill_color = fill_color;
this.startx = startx;
this.starty = starty;
endx = startx;
endy = starty;
this.oval = oval;
}
public void dataCollect(MouseEvent e) {
endx = e.getX();
endy = e.getY();
/*
* }else{ int w = startx - endx; int h = starty - endy; int qq
* =Math.min(Math.abs(w),Math.abs(h)); if (qq == 0) { endx = startx;
* endy = starty; } else { endx = startx + qq* (w / Math.abs(w)); endy =
* starty + qq * (h / Math.abs(h)); } }
*/
}
public void drawSelf(Graphics2D g) {
g.setColor(line_color);
g.setStroke(line_stroke);
width = Math.abs(endx - startx);
height = Math.abs(endx - starty);
if (oval == 0) {
if (width != 0 && height != 0) {
g.drawOval(startx > endx ? endx : startx, starty > endy ? endy
: starty, width, height);
g.setColor(fill_color);
g.fillOval(startx > endx ? endx : startx, starty > endy ? endy
: starty, width, height);
}
} else {
int w = startx - endx;
int h = starty - endy;
int qq = Math.min(Math.abs(w), Math.abs(h));
g.drawOval(startx > endx ? endx : startx, starty > endy ? endy
: starty, qq, qq);
g.setColor(fill_color);
g.fillOval(startx > endx ? endx : startx, starty > endy ? endy
: starty, qq, qq);
}
}
public void choosed() {
//return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -