package simphy.script;

import java.util.function.Function;

public class Timer {


	/**Returns name of widget*/
	public String getName() {
		return null;
	}
	
    /**
     * returns current time in seconds shown by timer
     * @return
     */
	public double getTime() {
		return 0;
	};
	
	/**
	 * Sets current time in seconds shown by timer
	 * @param t
	 */
	public void setTime(double t) {
	}

	/**
	 * Resets timer to initial state and starts it running
	 */
	public void reset(){
	}
	
	/**
	 * Stops timer, a timer when stopped does't update itself until  it starts running again via {@link #reset()} or {@link #pause(boolean)}
	 */
	public void stop(){
	}
	
	/**
	 * Pauses or resumes timer
	 * @param paused
	 * @see #reset()
	 * @see #stop()
	 */
	public void pause(boolean paused){
	}
	
	  /**
     * Sets the delay in seconds till next expiration.
     *
     * @param delay in in seconds, setting delay 0 disables timer
     * @throws
     */
    public void setDelay(double delay) {
    }
    
    /**
     * Returns delay in millisec 
     * @return
     */
    public double getDelay(){
    	return 0;
    }
    
    
    /**
     * Returns true if the timer is a continuous firing timer.
     */
    public boolean isContinuous() {
    	return false;
    }

    /**
     * Sets the timer continous mode. A timer in continuous mode must be stopped manually.
     * @param continuous true if the timer should auto restart after firing.
     */
    public void setContinuous(boolean continuous) {
    }
    
    /**
     * Sets the timer in counter mode. A timer in counter mode stops after it ticks specified number of times.
     * @param count number of times timer runs, pass -1 to run it continuously
     */
    public void setTickCount(int count) {
     }
    
    /**
     * Returns max number of times timer will tick
     * @return
     */
    public long getMaxTickCount(){
    	return 0;
    }
 
    /**
     * Returns true if the timer is already running.
     * @return true if the timer is already running.
     */
    public boolean isRunning() {
        return false;
    }
    
    /**
     * returns true if timer is either running or paused and may fire event
     * @return
     */
    public boolean isActive() {
        return false;
    }
    	
  	/**
	 * Sets method to be invoked whenever timer ticks <br>
	 * @param methodText {String} method in specific format as <strong> MethodName(parameters) </strong>
	 * <h3>MathodName:</h3> Name of Global method already defined in script
	 * <h3>parameters:</h3> The event description may contain parameters (in brackets, separated by comma or whitespace characters) as follows:
	 * <ul>
	 * <li> <b> this </b> =The source widget (the object on which the event occurred)
	 * <li> <b> widget name </b> =Another widget in gui identified by the given name
	 * <li> <b> item </b> =The component part on which the event occurred, valid for list item, tree node, table row, combobox choice, and tabbedpane tab
	 * <li> <b> this/name/item .attribute </b> =component's or item's attribute value, defined by the this, widget name, or item string, dot, and the attribute key. 
			Ex. <code> onSelectionChange(this, item.text, this.value) </code>
	 * <li> <b> constant string </b> =The source widget (the object on which the event occurred)
	 * <li> <b> constant value </b> =The source widget (the object on which the event occurred)
	 * <li> <b> constant number </b> =Long numbers end with 'L' character (it ignors case), floats width 'F', doubles have to include a dot character, otherwise it is expected as integer.	 * </ul>
	 */
	public void setAction(String methodText) {
	}

 	/**
	 * Returns method text associated with 'action' for this widget
	 * @return Method Text if assigned else null
	 */
	public String getAction() {
		return null;
	}
	
	/**
	 * Sets the callback function that is invoked whenever timer ticks <br>
	 * function should have current time (Number) as one and only argument which is updated every time the function is invoked. For example <br>
	 * <pre> function callback(time){ 
	 * 	console.print("Timer ticked at "+time);
	 * }
	 * timer.setCallbackFunction(callback);
	 * </pre>
	 * @param callback {Function} function should have current time (Number) as one and only argument which is updated every time the function is invoked 
	 */
	public void setCallbackFunction(Function<Double, Object> callback) {
	}	
	
	/**
	 * Returns callBack function set is any else returns null
	 */
	public Function<Double, Object> getCalllBackFunction() {
		return null;
	}
}
