MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / setProperties

Method setProperties

ij/src/main/java/ij/plugin/Selection.java:834–901  ·  view source on GitHub ↗

Implements the Edit>Selection>Properties command. With the alt key down and a multipoint selection, shows the point counts instead.

(String title, ImagePlus imp)

Source from the content-addressed store, hash-verified

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)

Callers 1

runMethod · 0.95

Calls 15

getMultiPointModeMethod · 0.95
altKeyDownMethod · 0.95
getFrontWindowMethod · 0.95
errorMethod · 0.95
getNameMethod · 0.95
getPositionMethod · 0.95
getGroupMethod · 0.95
getStrokeColorMethod · 0.95
getFillColorMethod · 0.95
getStrokeWidthMethod · 0.95
showDialogMethod · 0.95
recordingMethod · 0.95

Tested by

no test coverage detected