ImageJ base code to get access to all the classes and their methods to test new Plugins. https://imagejdocu.tudor.lu/howto/plugins/the_imagej_eclipse_howto
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.0 KiB

3 years ago
  1. var rCmds = newMenu("ROI Menu Tool",
  2. newArray("Set Default Group...", "Set Default Stroke Width...", "-",
  3. "Set Group of Selected ROIs", "Select Group", "-", "Properties..." , "Install Keypad Shortcuts") );
  4. macro "ROI Menu Tool - C037T0d15RT8c12oTfc12i" {
  5. cmd = getArgument();
  6. if (cmd=="Set Default Group...")
  7. setDefaultRoiGroup();
  8. else if (cmd=="Set Default Stroke Width...")
  9. setDefaultRoiStrokeWidth();
  10. else if (cmd=="Set Group of Selected ROIs")
  11. setRoiGroup();
  12. else if (cmd=="Select Group")
  13. selectRoiGroup();
  14. else if (cmd=="Properties...")
  15. properties();
  16. else if (cmd=="Install Keypad Shortcuts")
  17. call("ij.plugin.MacroInstaller.installFromJar", "/macros/RoiMenuTool.txt+");
  18. }
  19. // Numeric keypad shortcuts used to set the default ROI group
  20. macro "Keypad shortcuts for setting default group" { }
  21. macro "Group 0 (none) [n0]" { npad(0); }
  22. macro "Group 1 [n1]" { npad(1); }
  23. macro "Group 2 [n2]" { npad(2); }
  24. macro "Group 3 [n3]" { npad(3); }
  25. macro "Group 4 [n4]" { npad(4); }
  26. macro "Group 5 [n5]" { npad(5); }
  27. macro "Group 6 [n6]" { npad(6); }
  28. macro "Group 7 [n7]" { npad(7); }
  29. macro "Group 8 [n8]" { npad(8); }
  30. macro "Group 9 [n9]" { npad(9); }
  31. function npad(digit) {
  32. Roi.setDefaultGroup(digit);
  33. }
  34. function properties() {
  35. if (selectionType==-1) {
  36. showMessage("Selection required");
  37. exit;
  38. }
  39. run("Properties... ");
  40. }
  41. function setDefaultRoiGroup() {
  42. group = Roi.getDefaultGroup;
  43. Dialog.create("Set Default Group");
  44. Dialog.addNumber("Default group", group);
  45. Dialog.show;
  46. group = Dialog.getNumber();
  47. Roi.setDefaultGroup(group);
  48. call("ij.plugin.frame.Recorder.recordString", "Roi.setDefaultGroup("+group+");\n");
  49. }
  50. function setDefaultRoiStrokeWidth() {
  51. width = Roi.getDefaultStrokeWidth;
  52. Dialog.create("Set Default Stroke Width");
  53. Dialog.addNumber("Default stroke width", width);
  54. Dialog.show;
  55. width = Dialog.getNumber();
  56. Roi.setDefaultStrokeWidth(width);
  57. call("ij.plugin.frame.Recorder.recordString", "Roi.setDefaultStrokeWidth("+width+");\n");
  58. }
  59. function setRoiGroup() {
  60. Dialog.create("Set Group");
  61. Dialog.addString("Group", "1");
  62. Dialog.show;
  63. group = Dialog.getString();
  64. RoiManager.setGroup(group);
  65. if (call("ij.plugin.frame.Recorder.scriptMode")=="true")
  66. call("ij.plugin.frame.Recorder.recordString", "rm.setGroup("+group+");\n");
  67. else
  68. call("ij.plugin.frame.Recorder.recordString", "RoiManager.setGroup("+group+");\n");
  69. }
  70. function selectRoiGroup() {
  71. Dialog.create("Select group");
  72. Dialog.addString("Group", "0");
  73. Dialog.show;
  74. group = Dialog.getString();
  75. RoiManager.selectGroup(group);
  76. if (call("ij.plugin.frame.Recorder.scriptMode")=="true")
  77. call("ij.plugin.frame.Recorder.recordString", "rm.selectGroup("+group+");\n");
  78. else
  79. call("ij.plugin.frame.Recorder.recordString", "RoiManager.selectGroup("+group+");\n");
  80. }