📄 curce.java
字号:
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.QuadCurve2D;
public class Curce extends RectBoundedShape {
public Curce(Color c, Stroke s, int x, int y) {
super(c, s, x, y);
}
public Curce() {
super();
}
public void processCursorEvent(MouseEvent e, int t) {
if (t != IShape.CURSOR_DRAGGED)
return;
int x = e.getX();
int y = e.getY();
if (e.isShiftDown()) {
if (x - startX == 0) {
endX = startX;
endY = y;
} else {
float slope = Math.abs(((float) (y - startY)) / (x - startX));
if (slope < 0.577) {
endX = x;
endY = startY;
} else if (slope < 1.155) {
regulateShape(x, y);
} else {
endX = startX;
endY = y;
}
}
} else {
endX = x;
endY = y;
}
}
public void draw(Graphics2D g) {
g.setColor(color);
g.setStroke(stroke);
QuadCurve2D curve=new QuadCurve2D.Double(startX, startY,DrawingBoard.ctrlx,DrawingBoard.ctrly,endX, endY);
g.draw(curve);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -