Advertisement
AishaAli

Untitled

Nov 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. /*
  2. @(#)FigureTransferCommand.java 5.2
  3. */
  4.  
  5. package CH.ifa.draw.standard;
  6.  
  7. import java.util.*;
  8. import CH.ifa.draw.util.*;
  9. import CH.ifa.draw.framework.*;
  10.  
  11. abstract class FigureTransferCommand extends Command {
  12.  
  13. protected DrawingView fView;
  14.  
  15. protected FigureTransferCommand(String name, DrawingView view) {
  16. super(name);
  17. fView = view;
  18. }
  19. protected void deleteSelection() {
  20. fView.drawing().removeAll(fView.selection());
  21. fView.clearSelection();
  22. }
  23.  
  24. protected void copySelection() {
  25. FigureSelection selection = fView.getFigureSelection();
  26. Clipboard.getClipboard().setContents(selection);
  27. }
  28. public void execute() {
  29. deleteSelection();
  30. fView.checkDamage();
  31. }
  32.  
  33. protected void insertFigures(Vector figures, int dx, int dy) {
  34. FigureEnumeration e = new FigureEnumerator(figures);
  35. while (e.hasMoreElements()) {
  36. Figure figure = e.nextFigure();
  37. figure.moveBy(dx, dy);
  38. figure = fView.add(figure);
  39. fView.addToSelection(figure);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement