Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 java Graphing
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
andy_tok




PostPosted: Thu Jan 11, 2007 5:46 pm   Post subject: java Graphing

Hi!
I tried to graph a parabola like y=x^2 by connecting points use Line2D.double but the resolution is pretty low. What's the better way? or I made a mistake somewhere?
Thanks

import java.applet.*;
import java.awt.*;
import java.awt.geom.*;
public class Gra2D extends Applet
{

public void paint (Graphics g)
{
Graphics2D t=(Graphics2D)g;
t.setColor(Color.black);
double x=0.00;
double y=0.00;
while(x<=500&&y<=500)
{
double xp=x+0.001;
double yp=xp*xp;
Line2D.Double ln= new Line2D.Double(x,y,xp,yp);
t.draw(ln);
x=xp;
y=yp;
}
} // paint method
} // Gra2D class
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: