- package cn.edu.nju.software.grapheditor.cmd;
- import java.awt.Point;
- import cn.edu.nju.software.grapheditor.Drawing;
- import cn.edu.nju.software.grapheditor.shape.Rectangle;
- public class RectCmd extends Command{
- Rectangle r;
- public void executePress(Point p, Drawing dwg) {
- r=new Rectangle(dwg.currentColor);
- r.startPoint =p;
- r.endPoint =p;
- dwg.a.add(r);
- }
- public void executeDrag(Point p, Drawing dwg) {
- r.endPoint =p;
- }
- }