Back to index

moin  1.9.0~rc2
GroupCommand.java
Go to the documentation of this file.
00001 /*
00002  * @(#)GroupCommand.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.figures;
00007 
00008 import java.util.*;
00009 import CH.ifa.draw.util.Command;
00010 import CH.ifa.draw.framework.*;
00011 import CH.ifa.draw.standard.*;
00012 
00018 public  class GroupCommand extends Command {
00019 
00020     private DrawingView fView;
00021 
00027     public GroupCommand(String name, DrawingView view) {
00028         super(name);
00029         fView = view;
00030     }
00031 
00032     public void execute() {
00033         Vector selected = fView.selectionZOrdered();
00034         Drawing drawing = fView.drawing();
00035         if (selected.size() > 0) {
00036             fView.clearSelection();
00037             drawing.orphanAll(selected);
00038 
00039             GroupFigure group = new GroupFigure();
00040             group.addAll(selected);
00041             fView.addToSelection(drawing.add(group));
00042         }
00043         fView.checkDamage();
00044     }
00045 
00046     public boolean isExecutable() {
00047         return fView.selectionCount() > 0;
00048     }
00049 
00050 }
00051 
00052