示例#1
0
 public void invertSelection() {
   int[] sel = this.list.getSelectedIndices();
   int[] newSel = new int[listModel.getSize() - sel.length];
   int idx = 0;
   int lastIdx = -1;
   for (int i : sel) {
     for (int i2 = lastIdx + 1; i2 < i; i2++) newSel[idx++] = i2;
     lastIdx = i;
   }
   for (int i2 = lastIdx + 1; i2 < listModel.getSize(); i2++) newSel[idx++] = i2;
   list.setSelectedIndices(newSel);
 }
示例#2
0
 public void mergeSelectedObjects() {
   this.populatingObjects = true;
   HashMap<Integer, ArrayList<Object3DGui>> allObjects = getSplitSelection();
   for (int channelIdx : allObjects.keySet()) {
     ArrayList<Object3DGui> objects = allObjects.get(channelIdx);
     if (objects != null && objects.size() >= 2) {
       Collections.sort(objects);
       Object3DGui o1 = objects.get(0);
       for (int i = objects.size() - 1; i > 0; i--) {
         Object3DGui o2 = objects.get(i);
         o1.merge(o2);
         listModel.removeElement(o2);
         // IJ.log("merge:"+o1.getName()+ "::"+objects.get(i).getName()+ " channel:"+channelIdx);
       }
       o1.getChannel().createObjects();
       if (autoSave) o1.getChannel().saveOutput();
       ImagePlus img = o1.getChannel().getSegmented().getImagePlus();
       if (img.isVisible()) {
         img.updateAndDraw();
       }
     }
   }
   this.populatingObjects = false;
 }
示例#3
0
 public void deleteSelectedObjects() {
   populatingObjects = true;
   try {
     boolean[] modif = new boolean[currentChannels.length];
     for (Object o : this.list.getSelectedValues()) {
       listModel.removeElement(o);
       modif[getChannelRank(((Object3DGui) o).getChannel())] = true;
       ((Object3DGui) o).delete(true);
     }
     for (int i = 0; i < currentChannels.length; i++) {
       if (modif[i]) {
         ImagePlus img = currentChannels[i].getSegmented().getImagePlus();
         if (img.isVisible()) {
           img.updateAndDraw();
         }
         currentChannels[i].createObjects();
         if (autoSave) currentChannels[i].saveOutput();
       }
     }
   } catch (Exception e) {
     exceptionPrinter.print(e, "", Core.GUIMode);
   }
   populatingObjects = false;
 }