import ij.*; import ij.plugin.filter.PlugInFilter; import ij.process.*; import ij.gui.*; import java.awt.*; import java.awt.geom.*; import java.awt.image.*; import java.util.*; import ij.plugin.*; public class Dotted_Line implements PlugInFilter { ImagePlus imp; ImageCanvas canvas; Graphics2D g2; static double width = 2; static String dashpattern = "12, 12"; float[] dashvalues; public int setup(String arg, ImagePlus imp) { if (IJ.versionLessThan("1.31i")) return DONE; IJ.register(Dotted_Line.class); this.imp = imp; if (!isSelection()) { IJ.showMessage("Dotted Line", "Image with selection required."); return DONE; } else return DOES_ALL+NO_CHANGES; } public void run(ImageProcessor ip) { Undo.setup(Undo.TYPE_CONVERSION, imp); Integer id = new Integer(imp.getID()); ImageWindow win = imp.getWindow(); win.addWindowListener(win); canvas = win.getCanvas(); draw(); } //Gets the values for the width and the dash pattern public void userinput() { GenericDialog gd = new GenericDialog("Dotted Line Tool"); gd.addNumericField("Line Width", width, 2); gd.addStringField("Dash Pattern", dashpattern); gd.showDialog(); width = gd.getNextNumber(); //Convert String values into dashvalues float array dashpattern = gd.getNextString(); StringTokenizer st = new StringTokenizer(dashpattern , ", \t"); int tokens = st.countTokens(); dashvalues = new float[tokens]; for(int i=0; i