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

Method installMenu

ij/src/main/java/ij/gui/Toolbar.java:1822–1853  ·  view source on GitHub ↗
(int tool)

Source from the content-addressed store, hash-verified

1820 }
1821
1822 void installMenu(int tool) {
1823 Program pgm = macroInstaller.getProgram();
1824 Hashtable h = pgm.getMenus();
1825 if (h==null) return;
1826 String[] commands = (String[])h.get(names[tool]);
1827 if (commands==null)
1828 return;
1829 if (menus[tool]==null) {
1830 menus[tool] = new PopupMenu("");
1831 GUI.scalePopupMenu(menus[tool]);
1832 add(menus[tool] );
1833 } else
1834 menus[tool].removeAll();
1835 for (int i=0; i<commands.length; i++) {
1836 if (commands[i].equals("-"))
1837 menus[tool].addSeparator();
1838 else if (commands[i].startsWith("-"))
1839 menus[tool].addSeparator();
1840 else {
1841 boolean disable = commands[i].startsWith("*");
1842 String command = commands[i];
1843 if (disable)
1844 command = command.substring(1);
1845 MenuItem mi = new MenuItem(command);
1846 if (disable)
1847 mi.setEnabled(false);
1848 mi.addActionListener(this);
1849 menus[tool].add(mi);
1850 }
1851 }
1852 if (tool==current) setTool(RECTANGLE);
1853 }
1854
1855 /** Used by the MacroInstaller class to install a set of macro tools. */
1856 public void addMacroTool(String name, MacroInstaller macroInstaller, int id) {

Callers 1

addToolMethod · 0.95

Calls 13

getMenusMethod · 0.95
scalePopupMenuMethod · 0.95
setToolMethod · 0.95
getProgramMethod · 0.80
startsWithMethod · 0.80
substringMethod · 0.80
setEnabledMethod · 0.80
addActionListenerMethod · 0.80
addMethod · 0.65
getMethod · 0.45
removeAllMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected