Exemple #1
0
 protected HashMap<Integer, ArrayList<Integer>> getSplitSelectionIndexes() {
   HashMap<Integer, ArrayList<Object3DGui>> splitSelection = getSplitSelection();
   HashMap<Integer, ArrayList<Integer>> res =
       new HashMap<Integer, ArrayList<Integer>>(splitSelection.size());
   for (Map.Entry<Integer, ArrayList<Object3DGui>> e : splitSelection.entrySet()) {
     ArrayList<Integer> idxs = new ArrayList<Integer>(e.getValue().size());
     for (Object3DGui o : e.getValue()) idxs.add(o.getLabel());
     res.put(e.getKey(), idxs);
   }
   return res;
 }
Exemple #2
0
 public void setSelectedObjectsFromDB() {
   this.selectingObject = true;
   this.list.clearSelection();
   int offsetIdx = 0;
   ArrayList<Integer> selectedIndices = new ArrayList<Integer>();
   for (ObjectStructure s : this.currentChannels) {
     BasicDBList selectedObjects =
         Core.mongoConnector.getSelectedObjects(currentNucId, s.getIdx());
     if (selectedObjects != null && !selectedObjects.isEmpty()) {
       for (Object o : selectedObjects) selectedIndices.add((Integer) o + offsetIdx);
     }
     offsetIdx += s.getObjects().length;
   }
   if (!selectedIndices.isEmpty()) {
     int[] selectedIdx = new int[selectedIndices.size()];
     for (int i = 0; i < selectedIdx.length; i++) selectedIdx[i] = selectedIndices.get(i);
     this.list.setSelectedIndices(selectedIdx);
   }
   this.selectingObject = false;
 }
Exemple #3
0
 public void populateObjects() {
   try {
     this.listModel.removeAllElements();
     if (currentChannels == null) {
       return;
     }
     this.populatingObjects = true;
     ArrayList<Integer> selection = null;
     if (showSelection != null && showSelection.isSelected()) selection = new ArrayList<Integer>();
     int currentIdx = 0;
     for (ObjectStructure ass : currentChannels) {
       Object3D[] os = ass.getObjects();
       if (os != null) {
         Object3DGui[] osg = new Object3DGui[os.length];
         for (int i = 0; i < os.length; i++) osg[i] = new Object3DGui(os[i], ass);
         if (layout instanceof ObjectManagerLayout
             && currentChannels.length == 1
             && !((ObjectManagerLayout) layout).getSortKey().equals("idx"))
           this.sort(((ObjectManagerLayout) layout).getSortKey(), osg, ass.getIdx());
         // System.out.println("populating objects.. nb objects:"+os.length);
         for (Object3DGui o3D : osg) {
           this.listModel.addElement(o3D);
           if (selection != null && o3D.isInSelection()) selection.add(currentIdx);
           currentIdx++;
         }
         // if (selection!=null) System.out.println("populating objects.. selection
         // size:"+selection.size());
       } // else System.out.println("no objects int channel:"+ass.getChannelName());
     }
     if (selection != null && !selection.isEmpty()) {
       int[] sel = new int[selection.size()];
       int i = 0;
       for (int idx : selection) sel[i++] = idx;
       list.setSelectedIndices(sel);
     }
   } catch (Exception e) {
     exceptionPrinter.print(e, "", Core.GUIMode);
   }
   this.populatingObjects = false;
 }
Exemple #4
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;
 }