shape.java
来自「环境配置:系统装有jre运行环境。 使用说明: 1.双击drawer.jar」· Java 代码 · 共 61 行
JAVA
61 行
///////////////////////////////////////////////////////////
// Name: Drawer //
// Author:Zhanghan //
// Date: 2005-9-10 //
// Email: zhang_han04@ncic.ac.cn //
///////////////////////////////////////////////////////////
// The Abstract Class Shape
import java.awt.Graphics2D;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.*;
import java.awt.Color;
import java.awt.Stroke;
public abstract class Shape extends JLabel
implements MouseMotionListener
{
protected Color color = null;
protected Stroke stroke = null;
protected int startX = 0;
protected int startY = 0;
protected int endX = 0;
protected int endY = 0;
protected int currentX = 0;
protected int currentY = 0;
protected int currentD = 0;
protected Shape(Color color1, Stroke stroke1, int i, int j)
{
color = color1;
stroke = stroke1;
startX = endX = currentX = i;
startY = endY = currentY = j;
addMouseMotionListener(this);
}
public void mouseDragged(MouseEvent mouseevent)
{
if (DrawingBoard.cursor == 0) {
endX = mouseevent.getX();
endY = mouseevent.getY();
currentD = Math.abs(startX - endX);
if (startX > endX) currentX = endX;
if (startY > endY) currentY = endY;
}
else {
currentX = mouseevent.getX();
currentY = mouseevent.getY();
}
}
public abstract void draw(Graphics2D graphics2d);
public void mouseMoved(MouseEvent mouseevent) {}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?