MoveCmd.java
上传用户:sdzznc
上传日期:2022-07-23
资源大小:51k
文件大小:1k
源码类别:

绘图程序

开发平台:

Java

  1. package cn.edu.nju.software.grapheditor.cmd;
  2. import java.awt.Point;
  3. import cn.edu.nju.software.grapheditor.Drawing;
  4. import cn.edu.nju.software.grapheditor.shape.Shape;
  5. public class MoveCmd extends Command{
  6. Shape s;
  7. boolean judge;
  8. double x1,y1,x2,y2;
  9. public void executePress(Point p, Drawing dwg) {
  10. s=dwg.getFrontmostContainer(p);
  11. if(s!=null){
  12. x1=p.getX();
  13.     y1=p.getY();
  14.     judge=true;
  15. }else
  16.     judge=false;
  17. }
  18. public void executeDrag(Point p, Drawing dwg) {
  19. if(judge==true){
  20. s.move((int)(p.getX()-x1),(int)(p.getY()-y1));
  21. x1=p.getX();
  22. y1=p.getY();
  23. }
  24. }
  25. }