package vnt;
/**
 * Template_Plugin.java - v1.0
 * Began: July 1, 2005
 * Last Updated: July 21, 2005 
 * 
 * Copyright (C) 2005 - Michael D. Miller - mdm162@truman.edu
 * Truman State University
 * 100 E. Normal
 * Kirksville, MO - 63501
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

import ij.*;
import ij.gui.*;
import java.awt.*;
import java.awt.Color.*;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;
import java.io.*;
import ij.io.*;
import java.lang.String.*;
import java.lang.Math.*;
import ij.plugin.filter.*;

/**
 * <p>Generic example of how to write a plugin for ImageJ.</p>
 * 
 * @author Michael Miller - Truman State University
 * @version 1.0
 * @since 1.0
 */
public class Template_Plugin extends VascularNetworkToolkit implements PlugInFilter {

    /**
    * Specifies the preconditions for the plug-in.
    * If this method succeeds then run() is called.
    *
    * <p>Pre: ImageJ is running and an 8-bit grayscale image is open. The plug-in was just activated.
    * <br />Post: Either an argument was processed, the image was not saved to a local folder, or the plug-in is cleared to run on the image.
    * @param arg Required by the interface. The argument list passed to the plug-in.
    * @param imp Required by the interface. The ImagePlus datastructure holding (among other things) information to grab path and filename.
    * @return If DONE is returned, ImageJ quits without run()'ing the plug-in. Otherwise, the plug-in signals to ImageJ that this plugin only handles 8-bit (256 grayscale) and will not change the original image.
    * @see #run
    */
    public int setup(String arg, ImagePlus ip) {
        if (arg.equals("about")) { 
            showAbout("Template Plug-in","  * An example plug-in that demonstrates how a plug-in should be written.  (Copyright 2005. Michael Miller mdm162@truman.edu)");
            return DONE; // exit without run()
        }

        boolean processImage = getFileInformation(ip);
        if (!processImage) {
            IJ.error("Must have a file path. Please save this image to a local folder.");
            return DONE; // exit without run()
        }
                    
        return DOES_8G+NO_CHANGES; // success, run()
    }

    /**
     * This is called if the setup() was successful. 
     *  
     * <p>Pre: The image was cleared to run by the setup() method.
     * <br />Post: Something operation is performed. 
     * @param bp Required by the interface. The access information to the original image.
     * @see #setup
     */
    public void run(ImageProcessor bp){ 
        // get the width and height information
        getDimensions(bp);
        // content goes here
        return;
    }
}