MoveCmd.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.Shape;
- public class MoveCmd extends Command{
- Shape s;
- boolean judge;
- double x1,y1,x2,y2;
- public void executePress(Point p, Drawing dwg) {
- s=dwg.getFrontmostContainer(p);
- if(s!=null){
- x1=p.getX();
- y1=p.getY();
- judge=true;
- }else
- judge=false;
- }
- public void executeDrag(Point p, Drawing dwg) {
- if(judge==true){
- s.move((int)(p.getX()-x1),(int)(p.getY()-y1));
- x1=p.getX();
- y1=p.getY();
- }
- }
- }