Advertisement
AishaAli

Untitled

Nov 19th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 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 boolean isExecutable() {
  29. return fView.selectionCount() > 0;
  30. }
  31.  
  32. protected void insertFigures(Vector figures, int dx, int dy) {
  33. FigureEnumeration e = new FigureEnumerator(figures);
  34. while (e.hasMoreElements()) {
  35. Figure figure = e.nextFigure();
  36. figure.moveBy(dx, dy);
  37. figure = fView.add(figure);
  38. fView.addToSelection(figure);
  39. }
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement