OvalCmd.java
上传用户:sdzznc
上传日期:2022-07-23
资源大小:51k
文件大小:1k
- 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.Oval;
- public class OvalCmd extends Command{
- Oval o;
- public int x1,x2,y1,y2;
- public void executePress(Point p,Drawing dwg){
- o=new Oval(dwg.currentColor);
- x1=p.x;
- y1 =p.y;
- dwg.a.add(o);
-
- }
- public void executeDrag(Point p, Drawing dwg) {
- x2=p.x;
- y2=p.y;
- o.x=Math.min(x1,x2 );
- o.y=Math.min(y1,y2);
- o.width=Math.abs(x1-x2);
- o.height=Math.abs(y1-y2);
- }
- }