Back to index

moin  1.9.0~rc2
FigureTransferCommand.java
Go to the documentation of this file.
00001 /*
00002  * @(#)FigureTransferCommand.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.standard;
00007 
00008 import java.util.*;
00009 import CH.ifa.draw.util.*;
00010 import CH.ifa.draw.framework.*;
00011 
00016 abstract class FigureTransferCommand extends Command {
00017 
00018     protected DrawingView fView;
00019 
00025     protected FigureTransferCommand(String name, DrawingView view) {
00026         super(name);
00027         fView = view;
00028     }
00029 
00033     protected void deleteSelection() {
00034        fView.drawing().removeAll(fView.selection());
00035        fView.clearSelection();
00036     }
00037 
00041     protected void copySelection() {
00042         FigureSelection selection = fView.getFigureSelection();
00043         Clipboard.getClipboard().setContents(selection);
00044     }
00045 
00050     protected void insertFigures(Vector figures, int dx, int dy) {
00051         FigureEnumeration e = new FigureEnumerator(figures);
00052         while (e.hasMoreElements()) {
00053             Figure figure = e.nextFigure();
00054             figure = fView.add(figure);
00055             fView.addToSelection(figure);
00056         }
00057         fView.moveSelection(dx,dy);
00058     }
00059 
00060 }
00061 
00062