package triana.tools;

UWCC_HEADER

import triana.ocl.*;
import triana.types.*;
import triana.gui.windows.*;
import triana.gui.panels.*;
import java.awt.*;
import java.awt.event.*;
import triana.util.*;
import triana.gui.*;

/**
 * A NAME_OF_UNIT unit to ..
 *
 * @version VERSION DATE
 * @author AUTHOR
 */
public class NAME_OF_UNIT extends Unit {

    // some examples of parameters

    public int PARAM_NAME;

    /**
     * The UnitPanel for NAME_OF_UNIT
     */
    IntScrollerWindow myPanel;
 
    int min = MIN;
    int max = MAX;
    String parameterName = "PARAM_NAME";    
 
    /**
     **********************************************
     *** USER CODE of NAME_OF_UNIT goes here    ***
     **********************************************
     */
    public void process() throws Exception {         
        PROCESS_FUNCTION_CODE
        }

    /** 
     * Initialses information specific to NAME_OF_UNIT. 
     */
    public void init() {
        super.init();

        setResizableInputs(INRESIZE);
        setResizableOutputs(OUTRESIZE);

        // set these to true if your unit can process double-precision
        // arrays
        setRequireDoubleInputs(false);
        setCanProcessDoubleArrays(false);

        PARAM_NAME = CURRENT;

        myPanel = new IntScrollerWindow();
        myPanel.setObject(this, "SCROLLER_TEXT");
        myWindow.setParameterName(parameterName);                        
        myPanel.setValues(MIN, MAX, PARAM_NAME);
        }

    /**
     * Called when the reset button is pressed within the MainTriana Window
     */
    public void reset() {
        super.reset();
        }

    /**
     * Called when the stop button is pressed within the MainTriana Window
     */
    public void stopping() {
        super.stopping();
        }

    /**
     * Called when the start button is pressed within the MainTriana Window
     */
    public void starting() {
        super.starting();
        }

    /**
     * Saves NAME_OF_UNIT's parameters.
     */
    public void saveParameters() {      
        saveParameter(parameterName, PARAM_NAME);
        saveParameter("minimum", min);
        saveParameter("maximum", max);
        }

    /**
     * Used to set each of NAME_OF_UNIT's parameters.
     */
    public void setParameter(String name, String value) {
        if (name.equals(parameterName)) {
            PARAM_NAME = strToDouble(value);
            }
        else if (name.equals("minimum")) 
            min = strToDouble(value);
        else if (name.equals("maximum")) 
            max = strToDouble(value);
        }

    /**
     * Used to update the widget in this unit's user interface that is
     * used to control the given parameter name. 
     */
    public void updateWidgetFor(String name) {
        myWindow.setValues(min,max,PARAM_NAME);
        myWindow.updateWidgets();
        }

    /**
     *
     * @return a string containing the names of the types allowed 
     * to be input to NAME_OF_UNIT, each separated by a white space.
     */
    public String inputTypes() {
        return "INPUT_TYPES";
        }

    /**
     * @return a string containing the names of the types output
     * from NAME_OF_UNIT, each separated by a white space.
     */
    public String outputTypes() {
        return "OUTPUT_TYPES";
        }

    /**
     * This returns a <b>brief!</b> description of what the unit does. The
     * text here is shown in a pop up window when the user puts the mouse
     * over the unit icon for more than a second.
     */
    public String getPopUpDescription() {
        return "Put NAME_OF_UNIT's brief description here";
        }

    /**
     *
     * @returns the location of the help file for this unit.  
     */
    public String getHelpFile() {
        return "HELP_FILE";
        }

    /**
     * @return NAME_OF_UNIT's parameter window sp that Grid 
     * can move and display it.
     */
    public UnitPanel myParameterPanel() {
        return myPanel;
        }
     }







