package jmslexamples;
import java.awt.Color;

import com.softsynth.jmsl.MusicJob;

/** 
 * TextJob.java
 * 
 * A MusicJob subclass that has a drawing canvas on which it can draw
 * messages.  For testing scheduling without having to
 * hear anything.
 *
 * @author Phil Burk and Nick Didkovsky
 */
/*
 * (C) 1997 Phil Burk and Nick Didkovsky, All Rights Reserved
 * JMSL is based upon HMSL (C) Phil Burk, Larry Polansky and David Rosenboom.
 */

public class TextJob extends MusicJob {

	// some private data
	private DrawingCanvas myCanvas; // where to draw
	private String myMsg; // what this job will print to the applet every time it fires
	boolean state = true;
	private Color color;

	// Constructor method, runs when "new" is called.
	TextJob(DrawingCanvas can, String s, double sec) {
		super();
		setRepeatPause(sec);
		setRepeats(10000);
		myCanvas = can;
		myMsg = s;
	}

	/** return the "state" of the TextJob, used for reversing color, for example */
	public boolean getState() {
		return state;
	}

	/** reverse the boolean state of the TextJob */
	public void reverseState() {
		state = !state;
	}

	/** set the drawing color */
	public void setColor(Color kolor) {
		color = kolor;
	}

	/** paint TextJob's private message to canvas */
	public void printMsg() {
		myCanvas.printMsg(myMsg, color);
	}
}