📄 rectangle_.java
字号:
/*
* 创建日期 2005-11-5
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package src;
/**
* @author flash
*
* TODO 要更改此生成的类型注释的模板,请转至 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
import java.awt.*;
import java.awt.event.*;
public class Rectangle_ 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 rect = 0;
public Rectangle_(Stroke line_stroke, Color line_color, Color fill_color,
int startx, int starty, int rect) {
this.line_color = line_color;
this.line_stroke = line_stroke;
this.fill_color = fill_color;
endx = this.startx = startx;
endy = this.starty = starty;
this.rect = rect;
}
public void dataCollect(MouseEvent e) {
endx = e.getX();
endy = e.getY();
width = Math.abs(endx - startx);
height = Math.abs(endy - starty);
}
public void drawSelf(Graphics2D g) {
g.setColor(line_color);
if (rect == 0) {
g.drawRect(startx > endx ? endx : startx, starty > endy ? endy
: starty, width, height);
g.setColor(fill_color);
System.out.print(line_stroke);
g.setStroke(line_stroke);
g.fillRect(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.drawRect(startx > endx ? endx : startx, starty > endy ? endy
: starty, qq, qq);
g.setColor(fill_color);
g.setStroke(line_stroke);
g.fillRect(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 + -