http://imagej.273.s1.nabble.com/Plugins-that-don-t-run-from-Compile-and-Run-tp3693072p3693074.html
Thanks, Wayne. And thanks also for the new hyperstack navigation
>The first line in the plugin ("package ij.plugin;") needs to be
>replaced with "import ij.plugin.*;".
>
>-wayne
>
>On Apr 6, 2009, at 4:57 PM, Bill Mohler wrote:
>
>>I am hoping to make a modified version of HyperStackReducer, a
>>plugin that is bundled with and installed in the current version of
>>ImagJ.
>>
>>When I find the source code at
>>
http://rsb.info.nih.gov/ij/docs/source/ij/plugin/HyperStackReducer.java.html
>>and copy the code and save it in a file called
>>HyperStackReducer.java,
>>I get no errors, but nothing happens.
>>
>>Running the same plugin from the Image>Hyperstacks>Reduce
>>Dimensionality... menu, however, it works exactly as expected from
>>the code.
>>
>>The opening lines of the plugin are:
>>
>>package ij.plugin;
>>import ij.*;
>>import ij.gui.*;
>>import ij.process.*;
>>import ij.measure.Calibration;
>>import java.awt.*;
>>import java.util.Vector;
>>
>>/** Implements the Image/HyperStacks/Reduce Dimensionality command. */
>>public class HyperStackReducer implements PlugIn, DialogListener {
>> ImagePlus imp;
>> int channels1, slices1, frames1;
>> int channels2, slices2, frames2;
>> double imageSize;
>> static boolean keep = true;
>> /** Default constructor */
>> public HyperStackReducer() {
>> }
>>
>> /** Constructs a HyperStackReducer using the specified source image. */
>> public HyperStackReducer(ImagePlus imp) {
>> this.imp = imp;
>> }
>>
>> public void run(String arg) {
>> imp = IJ.getImage();
>> if (!(imp.isHyperStack() || imp.isComposite())) {
>> IJ.error("Reducer", "HyperStack required");
>> return;
>> }
>> int width = imp.getWidth();
>>.
>>.
>>.
>>
>>I have tried a few variations to the code including
>> public void run(String arg) {
>> imp = ij.WindowManager.getCurrentImage();
>>...
>>but get the same result.
>>It seems that the plugin is not even executing, because running it
>>from the installed menu command gives an error if there is no image
>>open or if the current image is not of the correct type. My
>>efforts with "Compile and Run..." don't even give the errors in
>>such situations.
>>
>>Am I un aware or forgetting some magic that's needed to get a
>>plugin to execute on the current image? I am still quite new to
>>java code, but I can't find what I'm missing. Are the constructors
>>the problem?
>>
>>Thanks for any help!
>>Bill
>>
>>
>>--
>>William A. Mohler
>>Associate Professor
>>Dept. of Genetics and Developmental Biology
>>University of Connecticut Health Center
>>MC-3301
>>263 Farmington Ave.
>>Farmington, CT 06030-3301
>>
>>
[hidden email]
>>Mobile: (860) 985-2719
>>alt. mobile: (860) 331-8514
>>skype: wmohler
>>
>>Office: (860) 679-1833, room E2029
>>Lab: (860) 679-1834, room E2032
>>Fax: (314) 689-1833
>>
>>G&DB dept. ofc.: (860) 679-8350
>>G&DB dept. fax : (860) 679-8345
>>
http://genetics.uchc.edu/Faculty/Mohler/Mohler.html>>P Think before you print