Implements the Edit>Selection>Properties command. With the alt key down and a multipoint selection, shows the point counts instead.
(String title, ImagePlus imp)
| 832 | /** Implements the Edit>Selection>Properties command. |
| 833 | * With the alt key down and a multipoint selection, shows the point counts instead. */ |
| 834 | boolean setProperties(String title, ImagePlus imp) { |
| 835 | if (imp == null) return false; //should never happen (called only from 'run', where imp!=null) |
| 836 | Roi roi = imp.getRoi(); |
| 837 | if ((roi instanceof PointRoi) && Toolbar.getMultiPointMode() && IJ.altKeyDown()) { |
| 838 | ((PointRoi)roi).displayCounts(); |
| 839 | return true; |
| 840 | } |
| 841 | Frame f = WindowManager.getFrontWindow(); |
| 842 | if (f!=null && f.getTitle().indexOf("3D Viewer")!=-1) |
| 843 | return false; |
| 844 | if (roi==null) { |
| 845 | IJ.error("This command requires a selection."); |
| 846 | return false; |
| 847 | } |
| 848 | String name = roi.getName(); |
| 849 | if (name==null) name = ""; |
| 850 | int position = roi.getPosition(); |
| 851 | int group = roi.getGroup(); |
| 852 | Color color = roi.getStrokeColor(); |
| 853 | Color fillColor = roi.getFillColor(); |
| 854 | int width = (int)roi.getStrokeWidth(); |
| 855 | RoiProperties rp = new RoiProperties(title, imp, roi); |
| 856 | boolean ok = rp.showDialog(); |
| 857 | if (IJ.recording()) { |
| 858 | boolean groupChanged = false; |
| 859 | String name2 = roi.getName(); |
| 860 | if (name2==null) name2 = ""; |
| 861 | int position2 = roi.getPosition(); |
| 862 | int group2 = roi.getGroup(); |
| 863 | if (group2!=group) groupChanged=true; |
| 864 | Color color2 = roi.getStrokeColor(); |
| 865 | Color fillColor2 = roi.getFillColor(); |
| 866 | int width2 = (int)roi.getStrokeWidth(); |
| 867 | if (Recorder.scriptMode()) { |
| 868 | Recorder.recordCall("roi = imp.getRoi();"); |
| 869 | if (name2!=name) |
| 870 | Recorder.recordCall("roi.setName(\""+name2+"\");"); |
| 871 | if (position2!=position) |
| 872 | Recorder.recordCall("roi.setPosition("+position2+");"); |
| 873 | if (group2!=group) |
| 874 | Recorder.recordCall("roi.setGroup("+group2+");"); |
| 875 | if (width2!=width) |
| 876 | Recorder.recordCall("roi.setStrokeWidth("+width2+");"); |
| 877 | if (color2!=color && !groupChanged) |
| 878 | Recorder.recordCall("roi.setStrokeColor("+getColor(color2)+");"); |
| 879 | if (fillColor2!=fillColor) |
| 880 | Recorder.recordCall("roi.setFillColor("+getColor(fillColor2)+");"); |
| 881 | Recorder.recordCall("imp.draw();"); |
| 882 | } else { |
| 883 | if (name2!=name) |
| 884 | Recorder.record("Roi.setName", name2); |
| 885 | if (groupChanged) |
| 886 | Recorder.record("Roi.setGroup", group2); |
| 887 | if (position2!=position) |
| 888 | Recorder.record("Roi.setPosition", position2); |
| 889 | if (color2!=color && !groupChanged) |
| 890 | Recorder.record("Roi.setStrokeColor", Colors.colorToString(color2)); |
| 891 | if (fillColor2!=fillColor) |
no test coverage detected