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; }
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; }