Hi,
I am jahan, i just started java applets and i was trying to draw a graph. The idea i am using is based on drawLine(xmin,ymin,xmax,ymax). I wanted to get a graph for sinx which is proving to be difficult. i used following syntax to implement my idea:
import java.awt.*;
import java.applet.*;
public class graphic extends Applet {
Button button1;
public void init() {
}
public void paint(Graphics g) {
Button button1 = new Button("Plot");
add(button1);
g.setColor(Color.blue);
g.drawLine(600,0,600,1000); // x-axis
g.drawLine(0,350,1400,350);// y-axis
for (int i=0;i<=1000;i++)
{
g.drawLine(i,(int)Math.sin(i),i,(int)Math.sin(i));//Suppose to give me a graph
//even tho at random location
}
}
}
But result of this code is just a straight line along x-axis , the only thing which comes to my mind is about using cast in here when i did (int)Math.sinx, it is giving me strange value. It cud be because all the value below 0.5 are taken as 0 and above 0.5 are taken as 1.So if anyone can suggest me a way to solve this problem.