Back to index

moin  1.9.0~rc2
UngroupCommand.java
Go to the documentation of this file.
00001 /*
00002  * @(#)UngroupCommand.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.figures;
00007 
00008 import java.awt.*;
00009 import java.util.*;
00010 import CH.ifa.draw.framework.*;
00011 import CH.ifa.draw.util.Command;
00012 
00017 public  class UngroupCommand extends Command {
00018 
00019     private DrawingView fView;
00020 
00026     public UngroupCommand(String name, DrawingView view) {
00027         super(name);
00028         fView = view;
00029     }
00030 
00031     public void execute() {
00032         FigureEnumeration selection = fView.selectionElements();
00033         fView.clearSelection();
00034 
00035         Vector parts = new Vector();
00036         while (selection.hasMoreElements()) {
00037             Figure selected = selection.nextFigure();
00038             Figure group = fView.drawing().orphan(selected);
00039             FigureEnumeration k = group.decompose();
00040             while (k.hasMoreElements())
00041                 fView.addToSelection(fView.add(k.nextFigure()));
00042         }
00043         fView.checkDamage();
00044     }
00045 
00046     public boolean isExecutable() {
00047         return fView.selectionCount() > 0;
00048     }
00049 
00050 }