⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shape.java

📁 环境配置:系统装有jre运行环境。 使用说明: 1.双击drawer.jar文件
💻 JAVA
字号:
///////////////////////////////////////////////////////////
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -