Dear everyone
I have a number of plugins which worked fine with ImageJ versions up to and including v.1.37, but haven't worked with versions after that. Instead I get an error message which says "Plugin or class not found" - even though the directory containing the class file (and also the java file, although I realize that it is not necessary) for that plugin is in ImageJ/Plugins for that version. Did something about the placement of plugins change? I would be very grateful if someone could explain the problem, and (hopefully) help me to put it right. Many thanks Geoff P.S. An example is (note ColorPanel.class is also present in this plugin directory): import ij.plugin.filter.PlugInFilter; import ij.*; import ij.gui.*; import ij.process.*; import ij.measure.*; import ij.util.Tools; import java.awt.*; import java.awt.event.*; import java.util.*; import java.lang.Math; /** This plugin implements the Spatial Command */ public class Spatial_resolution implements PlugInFilter { private ImagePlus imp; private static double xscale = 5.000E-1; private static double yscale = 5.000E-1; private static boolean newWindow = false; private static boolean interpolate = false; private static boolean processStack = true; private static String title = "Untitled"; private Vector fields; private boolean duplicateScale = true; private static double xdimension = 0.000E0; private static double ydimension = 0.000E0; private Vector newDims; private Vector newDimx = new Vector(); private Vector newDimy = new Vector(); private Vector choices = new Vector(); private static String scaleMethod = new String(); private static double xscaleup = 2.000E0; private static double yscaleup = 2.000E0; public int setup(String arg, ImagePlus imp) { this.imp = imp; IJ.register(Spatial_resolution.class); if (imp!=null) { Roi roi = imp.getRoi(); if (roi!=null && !roi.isArea()) imp.killRoi(); // ignore any line selection } return DOES_8G; } public void run(ImageProcessor ip) { getDimensions(ip); newDimensions(xdimension, ydimension); if (!showDialog()) return; ip.setInterpolate(interpolate); imp.startTiming(); try { scale(ip); scaleup(ip); } catch(OutOfMemoryError o) { IJ.outOfMemory("Scale"); } IJ.showProgress(1.0); } // Retrieve image dimensions. public boolean getDimensions(ImageProcessor ip) { //int w = ip.getWidth(); //int h = ip.getHeight(); //IJ.showMessage("Dimensions","Width = " + w + ", Height = " + h); // works. xdimension = (double)ip.getWidth(); ydimension = (double)ip.getHeight(); return true; } public void newDimensions(double x, double y) { double threshold = 2.000E1; String choice = new String(); double tempx = x; double tempy = y; Double Dx = new Double(tempx); Double Dy = new Double(tempy); newDimx.add(Dx); newDimy.add(Dy); choice = tempx + " Pixels x " + tempy + " Lines"; choices.add(choice); do { //tempx = tempx / 2.000E0; //tempy = tempy / 2.000E0; tempx = tempx / 2D; tempy = tempy / 2D; Dx = new Double(tempx); Dy = new Double(tempy); newDimx.add(Dx); newDimy.add(Dy); choice = tempx + " Pixels x " + tempy + " Lines"; choices.add(choice); } //while ( (tempx+tempy)/2.0 > threshold && tempx%2 != 1 && tempy%2 != 1 ); while ( (tempx+tempy)/2D > threshold && tempx%2 != 1 && tempy%2 != 1 ); } void scale(ImageProcessor ip) { ip.scale(xscale, yscale); //ip.scale(6.250E-2, 6.250E-2); imp.killRoi(); } void scaleup(ImageProcessor ip) { ip.scale(xscaleup, yscaleup); //ip.scale(1.600E1, 1.600E1); imp.killRoi(); } boolean showDialog() { boolean isStack = imp.getStackSize()>1; GenericDialog gd = new GenericDialog("Scale"); fields = gd.getNumericFields(); String[] stringArray = new String[ choices.size()]; Object[] objects = choices.toArray(); for ( int i = 0; i < objects.length; i++ ) stringArray[i] = ( String )objects[i]; gd.addChoice("Spatial", stringArray, (String)choices.elementAt(0)); gd.showDialog(); if (gd.wasCanceled()) return false; scaleMethod = gd.getNextChoice(); if (gd.invalidNumber()) { IJ.error("X or Y scale are invalid."); return false; } for (int i = 0; i < choices.size(); i++) { if (scaleMethod.equals( (String)choices.elementAt(i) )) { double iter = (double)i; // Compute x and y scale. //xscale = yscale = 1.000E0 / Math.pow(2.000E0, iter); xscale = yscale = 1D / Math.pow(2D, iter); /* // Attempt to add greater precision...to no avail. if (xscale == 1.0) xscale = 1.000E0; else if (xscale == 0.5) xscale = 5.000E-1; else if (xscale == 0.25) xscale = 2.500E-1; else if (xscale == 0.125) xscale = 1.250E-1; else if (xscale == 0.0625) xscale = 6.250E-2; else xscale = 6.250E-2; // Min */ // Compute x and y scale. //xscaleup = yscaleup = Math.pow(2.000E0, iter); xscaleup = yscaleup = Math.pow(2D, iter); /* // Attempt to add greater precision...to no avail. if (xscaleup == 1.0) xscaleup = 1.000E0; else if (xscaleup == 2.0) xscaleup = 2.000E0; else if (xscaleup == 4.0) xscaleup = 4.000E0; else if (xscaleup == 8.0) xscaleup = 8.000E0; else if (xscaleup == 16.0) xscaleup = 1.600E1; else xscaleup = 1.600E1; // Max */ //xscale = yscale = 6.250E-2; //xscaleup = yscaleup = 1.600E1; IJ.showMessage("Scale: down/up", "down: " + xscale + ", up: " + xscaleup); } } return true; } } |
Hi Geoff,
I tried your plugin with my installation of ImageJ v1.44f, and it compiles and runs just fine. So whatever is going on with your "plugin or class not found" error is likely to be an ImageJ configuration issue rather than a problem with recent versions of ImageJ. Have you tried downloading a fresh ImageJ distribution from the web site? Have you tried using Fiji? -Curtis On Tue, Sep 14, 2010 at 9:22 PM, Dougherty, Geoff <[hidden email] > wrote: > Dear everyone > > I have a number of plugins which worked fine with ImageJ versions up to and > including v.1.37, but haven't worked with versions after that. Instead I get > an error message which says "Plugin or class not found" - even though the > directory containing the class file (and also the java file, although I > realize that it is not necessary) for that plugin is in ImageJ/Plugins for > that version. > > Did something about the placement of plugins change? > > I would be very grateful if someone could explain the problem, and > (hopefully) help me to put it right. > > Many thanks > > Geoff > > > > P.S. An example is (note ColorPanel.class is also present in this plugin > directory): > > import ij.plugin.filter.PlugInFilter; > import ij.*; > import ij.gui.*; > import ij.process.*; > import ij.measure.*; > import ij.util.Tools; > import java.awt.*; > import java.awt.event.*; > import java.util.*; > import java.lang.Math; > /** This plugin implements the Spatial Command */ > public class Spatial_resolution implements PlugInFilter > { > private ImagePlus imp; > private static double xscale = 5.000E-1; > private static double yscale = 5.000E-1; > private static boolean newWindow = false; > private static boolean interpolate = false; > private static boolean processStack = true; > private static String title = "Untitled"; > private Vector fields; > private boolean duplicateScale = true; > private static double xdimension = 0.000E0; > private static double ydimension = 0.000E0; > private Vector newDims; > private Vector newDimx = new Vector(); > private Vector newDimy = new Vector(); > private Vector choices = new Vector(); > private static String scaleMethod = new String(); > private static double xscaleup = 2.000E0; > private static double yscaleup = 2.000E0; > > public int setup(String arg, ImagePlus imp) > { > this.imp = imp; > IJ.register(Spatial_resolution.class); > if (imp!=null) > { > Roi roi = imp.getRoi(); > if (roi!=null && !roi.isArea()) > imp.killRoi(); // ignore any line selection > } > return DOES_8G; > } > > public void run(ImageProcessor ip) > { > getDimensions(ip); > newDimensions(xdimension, ydimension); > if (!showDialog()) > return; > ip.setInterpolate(interpolate); > imp.startTiming(); > try > { > scale(ip); > scaleup(ip); > } > catch(OutOfMemoryError o) > { > IJ.outOfMemory("Scale"); > } > IJ.showProgress(1.0); > } > > // Retrieve image dimensions. > public boolean getDimensions(ImageProcessor ip) > { > //int w = ip.getWidth(); > //int h = ip.getHeight(); > //IJ.showMessage("Dimensions","Width = " + w + ", Height = " + h); // > works. > xdimension = (double)ip.getWidth(); > ydimension = (double)ip.getHeight(); > return true; > } > > public void newDimensions(double x, double y) > { > double threshold = 2.000E1; > String choice = new String(); > double tempx = x; > double tempy = y; > Double Dx = new Double(tempx); > Double Dy = new Double(tempy); > newDimx.add(Dx); > newDimy.add(Dy); > choice = tempx + " Pixels x " + tempy + " Lines"; > choices.add(choice); > do > { > //tempx = tempx / 2.000E0; > //tempy = tempy / 2.000E0; > tempx = tempx / 2D; > tempy = tempy / 2D; > Dx = new Double(tempx); > Dy = new Double(tempy); > newDimx.add(Dx); > newDimy.add(Dy); > choice = tempx + " Pixels x " + tempy + " Lines"; > choices.add(choice); > } > //while ( (tempx+tempy)/2.0 > threshold && tempx%2 != 1 && tempy%2 != 1 > ); > while ( (tempx+tempy)/2D > threshold && tempx%2 != 1 && tempy%2 != 1 ); > } > > void scale(ImageProcessor ip) > { > ip.scale(xscale, yscale); > //ip.scale(6.250E-2, 6.250E-2); > imp.killRoi(); > } > > void scaleup(ImageProcessor ip) > { > ip.scale(xscaleup, yscaleup); > //ip.scale(1.600E1, 1.600E1); > imp.killRoi(); > } > > boolean showDialog() > { > boolean isStack = imp.getStackSize()>1; > GenericDialog gd = new GenericDialog("Scale"); > fields = gd.getNumericFields(); > String[] stringArray = new String[ choices.size()]; > Object[] objects = choices.toArray(); > for ( int i = 0; i < objects.length; i++ ) > stringArray[i] = ( String )objects[i]; > gd.addChoice("Spatial", stringArray, (String)choices.elementAt(0)); > gd.showDialog(); > if (gd.wasCanceled()) > return false; > scaleMethod = gd.getNextChoice(); > if (gd.invalidNumber()) > { > IJ.error("X or Y scale are invalid."); > return false; > } > for (int i = 0; i < choices.size(); i++) > { > if (scaleMethod.equals( (String)choices.elementAt(i) )) > { > double iter = (double)i; > // Compute x and y scale. > //xscale = yscale = 1.000E0 / Math.pow(2.000E0, iter); > xscale = yscale = 1D / Math.pow(2D, iter); > /* > // Attempt to add greater precision...to no avail. > if (xscale == 1.0) xscale = 1.000E0; > else if (xscale == 0.5) xscale = 5.000E-1; > else if (xscale == 0.25) xscale = 2.500E-1; > else if (xscale == 0.125) xscale = 1.250E-1; > else if (xscale == 0.0625) xscale = 6.250E-2; > else xscale = 6.250E-2; // Min > */ > // Compute x and y scale. > //xscaleup = yscaleup = Math.pow(2.000E0, iter); > xscaleup = yscaleup = Math.pow(2D, iter); > /* > // Attempt to add greater precision...to no avail. > if (xscaleup == 1.0) xscaleup = 1.000E0; > else if (xscaleup == 2.0) xscaleup = 2.000E0; > else if (xscaleup == 4.0) xscaleup = 4.000E0; > else if (xscaleup == 8.0) xscaleup = 8.000E0; > else if (xscaleup == 16.0) xscaleup = 1.600E1; > else xscaleup = 1.600E1; // Max > */ > //xscale = yscale = 6.250E-2; > //xscaleup = yscaleup = 1.600E1; > IJ.showMessage("Scale: down/up", "down: " + xscale + ", up: " + > xscaleup); > } > } > return true; > } > } > |
Curtis
I solved it. The sub-directory had a period in its name ("Ch.2 Plugins"). Although this worked in v1.37, it isn't allowed in v1.4+. Taking that period out got everything working again. Many thanks Geoff ________________________________________ From: ImageJ Interest Group [[hidden email]] on behalf of Curtis Rueden [[hidden email]] Sent: Wednesday, September 29, 2010 2:25 PM To: [hidden email] Subject: Re: Plugins not working with latest versions of imageJ Hi Geoff, I tried your plugin with my installation of ImageJ v1.44f, and it compiles and runs just fine. So whatever is going on with your "plugin or class not found" error is likely to be an ImageJ configuration issue rather than a problem with recent versions of ImageJ. Have you tried downloading a fresh ImageJ distribution from the web site? Have you tried using Fiji? -Curtis On Tue, Sep 14, 2010 at 9:22 PM, Dougherty, Geoff <[hidden email] > wrote: > Dear everyone > > I have a number of plugins which worked fine with ImageJ versions up to and > including v.1.37, but haven't worked with versions after that. Instead I get > an error message which says "Plugin or class not found" - even though the > directory containing the class file (and also the java file, although I > realize that it is not necessary) for that plugin is in ImageJ/Plugins for > that version. > > Did something about the placement of plugins change? > > I would be very grateful if someone could explain the problem, and > (hopefully) help me to put it right. > > Many thanks > > Geoff > > > > P.S. An example is (note ColorPanel.class is also present in this plugin > directory): > > import ij.plugin.filter.PlugInFilter; > import ij.*; > import ij.gui.*; > import ij.process.*; > import ij.measure.*; > import ij.util.Tools; > import java.awt.*; > import java.awt.event.*; > import java.util.*; > import java.lang.Math; > /** This plugin implements the Spatial Command */ > public class Spatial_resolution implements PlugInFilter > { > private ImagePlus imp; > private static double xscale = 5.000E-1; > private static double yscale = 5.000E-1; > private static boolean newWindow = false; > private static boolean interpolate = false; > private static boolean processStack = true; > private static String title = "Untitled"; > private Vector fields; > private boolean duplicateScale = true; > private static double xdimension = 0.000E0; > private static double ydimension = 0.000E0; > private Vector newDims; > private Vector newDimx = new Vector(); > private Vector newDimy = new Vector(); > private Vector choices = new Vector(); > private static String scaleMethod = new String(); > private static double xscaleup = 2.000E0; > private static double yscaleup = 2.000E0; > > public int setup(String arg, ImagePlus imp) > { > this.imp = imp; > IJ.register(Spatial_resolution.class); > if (imp!=null) > { > Roi roi = imp.getRoi(); > if (roi!=null && !roi.isArea()) > imp.killRoi(); // ignore any line selection > } > return DOES_8G; > } > > public void run(ImageProcessor ip) > { > getDimensions(ip); > newDimensions(xdimension, ydimension); > if (!showDialog()) > return; > ip.setInterpolate(interpolate); > imp.startTiming(); > try > { > scale(ip); > scaleup(ip); > } > catch(OutOfMemoryError o) > { > IJ.outOfMemory("Scale"); > } > IJ.showProgress(1.0); > } > > // Retrieve image dimensions. > public boolean getDimensions(ImageProcessor ip) > { > //int w = ip.getWidth(); > //int h = ip.getHeight(); > //IJ.showMessage("Dimensions","Width = " + w + ", Height = " + h); // > works. > xdimension = (double)ip.getWidth(); > ydimension = (double)ip.getHeight(); > return true; > } > > public void newDimensions(double x, double y) > { > double threshold = 2.000E1; > String choice = new String(); > double tempx = x; > double tempy = y; > Double Dx = new Double(tempx); > Double Dy = new Double(tempy); > newDimx.add(Dx); > newDimy.add(Dy); > choice = tempx + " Pixels x " + tempy + " Lines"; > choices.add(choice); > do > { > //tempx = tempx / 2.000E0; > //tempy = tempy / 2.000E0; > tempx = tempx / 2D; > tempy = tempy / 2D; > Dx = new Double(tempx); > Dy = new Double(tempy); > newDimx.add(Dx); > newDimy.add(Dy); > choice = tempx + " Pixels x " + tempy + " Lines"; > choices.add(choice); > } > //while ( (tempx+tempy)/2.0 > threshold && tempx%2 != 1 && tempy%2 != 1 > ); > while ( (tempx+tempy)/2D > threshold && tempx%2 != 1 && tempy%2 != 1 ); > } > > void scale(ImageProcessor ip) > { > ip.scale(xscale, yscale); > //ip.scale(6.250E-2, 6.250E-2); > imp.killRoi(); > } > > void scaleup(ImageProcessor ip) > { > ip.scale(xscaleup, yscaleup); > //ip.scale(1.600E1, 1.600E1); > imp.killRoi(); > } > > boolean showDialog() > { > boolean isStack = imp.getStackSize()>1; > GenericDialog gd = new GenericDialog("Scale"); > fields = gd.getNumericFields(); > String[] stringArray = new String[ choices.size()]; > Object[] objects = choices.toArray(); > for ( int i = 0; i < objects.length; i++ ) > stringArray[i] = ( String )objects[i]; > gd.addChoice("Spatial", stringArray, (String)choices.elementAt(0)); > gd.showDialog(); > if (gd.wasCanceled()) > return false; > scaleMethod = gd.getNextChoice(); > if (gd.invalidNumber()) > { > IJ.error("X or Y scale are invalid."); > return false; > } > for (int i = 0; i < choices.size(); i++) > { > if (scaleMethod.equals( (String)choices.elementAt(i) )) > { > double iter = (double)i; > // Compute x and y scale. > //xscale = yscale = 1.000E0 / Math.pow(2.000E0, iter); > xscale = yscale = 1D / Math.pow(2D, iter); > /* > // Attempt to add greater precision...to no avail. > if (xscale == 1.0) xscale = 1.000E0; > else if (xscale == 0.5) xscale = 5.000E-1; > else if (xscale == 0.25) xscale = 2.500E-1; > else if (xscale == 0.125) xscale = 1.250E-1; > else if (xscale == 0.0625) xscale = 6.250E-2; > else xscale = 6.250E-2; // Min > */ > // Compute x and y scale. > //xscaleup = yscaleup = Math.pow(2.000E0, iter); > xscaleup = yscaleup = Math.pow(2D, iter); > /* > // Attempt to add greater precision...to no avail. > if (xscaleup == 1.0) xscaleup = 1.000E0; > else if (xscaleup == 2.0) xscaleup = 2.000E0; > else if (xscaleup == 4.0) xscaleup = 4.000E0; > else if (xscaleup == 8.0) xscaleup = 8.000E0; > else if (xscaleup == 16.0) xscaleup = 1.600E1; > else xscaleup = 1.600E1; // Max > */ > //xscale = yscale = 6.250E-2; > //xscaleup = yscaleup = 1.600E1; > IJ.showMessage("Scale: down/up", "down: " + xscale + ", up: " + > xscaleup); > } > } > return true; > } > } > |
Free forum by Nabble | Edit this page |