Hi Everyone,
Does anyone know what the commands are that can be passed to IJ.doCommand(String command)? Are there constants defined somewhere or some type of naming scheme? I'm trying to run the ThresholdAdjuster from my class when the user clicks a button. My class extends PlugInFrame. My idea is to just use IJ.doCommand("Threshold"), but that isn't working. I've also tried IJ.runPlugIn("ThresholdAdjuster", null), but that doesn't appear to do anything? Thanks in advance for any tips. Carl Trapani |
Hi,
Have you try with the empty string, IJ.runPlugIn("ThresholdAdjuster", "") It work with my plugin. Hendrix On Wed, Aug 13, 2008 at 3:52 PM, Carl Trapani <[hidden email]> wrote: > Hi Everyone, > > Does anyone know what the commands are that can be passed to > IJ.doCommand(String command)? Are there constants defined somewhere or some > type of naming scheme? > > I'm trying to run the ThresholdAdjuster from my class when the user clicks a > button. My class extends PlugInFrame. My idea is to just use > IJ.doCommand("Threshold"), but that isn't working. I've also tried > IJ.runPlugIn("ThresholdAdjuster", null), but that doesn't appear to do > anything? > > Thanks in advance for any tips. > Carl Trapani > |
In reply to this post by Carl Trapani - SkyTop Software
On Aug 13, 2008, at 3:52 PM, Carl Trapani wrote:
> Hi Everyone, > > Does anyone know what the commands are that can be passed to > IJ.doCommand(String command)? Are there constants defined somewhere or > some type of naming scheme? IJ.run() and IJ.doCommand() can be passed any ImageJ menu command. Use the Plugins>Utilities>List Commands (or Find Commands in v1.41) command to get a list of all the menu commands. You can also get a command name by running the command with the recorder running. Both IJ.run() and IJ.doCommand() run the specified command but IJ.run() does not return until the command finishes whereas IJ.doCommand() runs the command in a separate thread and returns immediately. You can use use either IJ.run("Threshold...") or IJ.doCommand("Threshold...") to open the Threshold window. -wayne > I'm trying to run the ThresholdAdjuster from my class when the user > clicks a button. My class extends PlugInFrame. My idea is to just use > IJ.doCommand("Threshold"), but that isn't working. I've also tried > IJ.runPlugIn("ThresholdAdjuster", null), but that doesn't appear to do > anything? > > Thanks in advance for any tips. > Carl Trapani > |
Wayne Rasband wrote:
> Use the Plugins>Utilities>List Commands (or Find Commands in v1.41) > command to get a list of all the menu commands. You can also get a > command name by running the command with the recorder running. Excellent! Thanks Wayne. Thanks also for an amazing tool! > Both IJ.run() and IJ.doCommand() run the specified command but > IJ.run() does not return until the command finishes whereas > IJ.doCommand() runs the command in a separate thread and returns > immediately. You can use use either IJ.run("Threshold...") or > IJ.doCommand("Threshold...") to open the Threshold window. > > -wayne For anyone else out there, here is a code snippet that may be useful (or may not). It appears that the buttons for ThresholdAdjuster are inside a panel: ThresholdAdjuster ta = (ThresholdAdjuster)IJ.runPlugIn(ThresholdAdjuster.class.getName(), null); //Now I have a reference to ThresholdAdjuster Component[] comps = ta.getComponents(); IJ.write("There are " + comps.length + " components in ThresholdAdjuster."); for (Component c : comps) { IJ.write("Component " + c.getName()); if (c instanceof Button) { Button b = (Button) c; b.setVisible(false); IJ.write("Found Button " + b.getLabel() + " and setVisible(false)."); } else if (c instanceof JButton) { JButton b = (JButton) c; b.setVisible(false); IJ.write("Found Button " + b.getText() + " and setVisible(false)."); } Output: There are 7 components in ThresholdAdjuster. Component canvas0 Component scrollbar0 Component label0 Component scrollbar1 Component label1 Component choice0 Component panel0 Carl Trapani |
Free forum by Nabble | Edit this page |