(boolean clone)
| 687 | } |
| 688 | |
| 689 | boolean update(boolean clone) { |
| 690 | ImagePlus imp = getImage(); |
| 691 | if (imp==null) |
| 692 | return false; |
| 693 | ImageCanvas ic = imp.getCanvas(); |
| 694 | boolean showingAll = ic!=null && ic.getShowAllROIs(); |
| 695 | Roi roi = imp.getRoi(); |
| 696 | if (roi==null) { |
| 697 | error("The active image does not have a selection."); |
| 698 | return false; |
| 699 | } |
| 700 | int index = list.getSelectedIndex(); |
| 701 | if (index<0 && !showingAll) |
| 702 | return error("Exactly one item in the list must be selected."); |
| 703 | if (index>=0) { |
| 704 | if (clone) { |
| 705 | String name = (String)listModel.getElementAt(index); |
| 706 | Roi roi2 = (Roi)roi.clone(); |
| 707 | if (roi2.getPosition() != PointRoi.POINTWISE_POSITION) |
| 708 | roi2.setPosition(imp); |
| 709 | roi.setName(name); |
| 710 | roi2.setName(name); |
| 711 | rois.set(index, roi2); |
| 712 | } else |
| 713 | rois.set(index, roi); |
| 714 | } |
| 715 | if (record()) Recorder.record("roiManager", "Update"); |
| 716 | updateShowAll(); |
| 717 | return true; |
| 718 | } |
| 719 | |
| 720 | boolean rename(String name2) { |
| 721 | int index = list.getSelectedIndex(); |
no test coverage detected