//                 Plot Cos and Sin Graphs using the Simplegraph
//                 Graph class.


import gov.noaa.pmel.sgt.cplab.*;        // Import the SimpleGraph class
import java.awt.Color;                   // Import awt color definitions.

public class CosSinPlot{               

    public static void main(String args[]){   // Main program

	final int POINTS=100;                 // Number of points in graph

	//      Delare graph object and set up

	SimpleGraph myGraph = new SimpleGraph("A Cos/Sin Graph",
					      "angle","Radians",
					      "Displacement","No units");

	DataSet cosData = new DataSet();      // DataSet for cos data

	//                 Calcualte Cos data points
	for(int i = 0; i < POINTS; i++){
	    double angle = 4.0*Math.PI*(double)i/(double)POINTS; 
	    cosData.addPoint(angle, Math.cos(angle));  // Add to DataSet
     }
	cosData.setColor(Color.red);          // Set colo(u)r of data        
	myGraph.addData(cosData,"Cos");       // add DataSet to graph

	DataSet sinData = new DataSet();      // New DataSet for Sin data

	//                Calculate Sin data points

	for(int i = 0; i < POINTS; i++){
	    double angle = 4.0*Math.PI*(double)i/(double)POINTS; 
	    sinData.addPoint(angle, Math.sin(angle));  // Add to DataSet
     }
	sinData.setColor(Color.green);      // Set colo(u)r 
	myGraph.addData(sinData,"Sine");    // add DataSet to graph

	myGraph.showGraph();                // Show the combined graph
    }
}
