Results 1 to 2 of 2
 12202010, 08:48 PM #1Member
 Join Date
 Dec 2010
 Posts
 17
 Rep Power
 0
graph continues to emerge each time the coordinates is calculated
hello, please i need your help please help me
I want the window remains open and the graph continues to emerge each time the coordinates is calculated the first step: the window opens and there's just ordinate and abscissa. the second stage: once the factorial function computes factorial (k = 2) then the window displays the graph (k = 1, fact (k = 1) = 1) (k = 2, fact (k = 2) = 2) (the line) (as it did the update to the window and it displays the line and the window remains open after the factorial function computes factorial (k = 3) while the window displays the graph (k = 2, fact (k = 2) = 2) (k = 3, fact (k = 3) = 6) (line) ex ..
/*I do not want the loop
you then you calculate the poster I want to draw each time for giving and its factorial k
*/
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;
public class GraphingData11 extends JPanel {
final int PAD = 20;
/*3 variables to draw the line
(k = 1, fact (k = 1) = 1) (k = 2, fact (k = 2) = 2)*/
static int multi=1;static int multi1;static int k;
/*factorial function*/
public static double factorial(int N){
multi=1;
for (int i = 1; i <= N; i++){multi = multi*i;}
System.out.println(multi);
return multi;}
/*a function that calculates the factorial of k = 1 to 100, and I draw the graph
for each k*/
public static double FUNCTION(){
int k=1;multi1=0;
while (k<=100){factorial(k);
/*can not with the method paintComponent (Graphics g)
paintComponent (Graphics g) I want to call the paintComponent (Graphics g) each time with new cords (k = 1, fact (k = 1) = 1) (k = 2, fact (k = 2) = 2 ) fact (k = 1) is variable and MULTI1 fact (k = 2) is the multivariable
*/
// wait for a while and then compute factorial k(
////////////////////////////////////////////
t0 = System.currentTimeMillis ();
do {t1 = System.currentTimeMillis ();} while (t1  t0 <10000);
///////////////////////////////////////
multi1=multi;
k=k+1;}
return 0;}
/*I do not want the loop
you then you calculate the poster I want to draw each time for giving and its factorial k
*/
//the function that draws the dots and lines
protected void paintComponent1(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASIN G,RenderingHints.VALUE_ANTIALIAS_ON);
int w = getWidth(); // Window Width
// Window height
int h = getHeight();
// draw axis.
g2.draw(new Line2D.Double(PAD, PAD, PAD, hPAD));
// draw horizontal axis.
g2.draw(new Line2D.Double(PAD, hPAD, wPAD, hPAD));
// line color
g2.setPaint(Color.red);
// draw the line
g2.draw(new Line2D.Double(PAD + (20*(k1)),h  (PAD +multi1), PAD + (20*(k)), h  (PAD + multi)));
// color dot
g2.setPaint(Color.red);
// draw point
g2.fill(new Ellipse2D.Double(PAD +(20*(k1)),h  (PAD + multi1),2,2));
}
public static void main(String[] args) {
FUNCTION();
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new GraphingData11());
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
}
}
I give you another example as the task manager>Performance
you see the pattern I want my program to do exactly
In fact I want the same result (a visual standpoint), but I used what has already been drawn before, just by adding new lines ...
please i need your help ,please

Same as your post from yesterday, so I'm locking this post. And still you refuse to use code tags, why?
Similar Threads

Draw graph calculated by the cord at the same time
By khiat in forum New To JavaReplies: 13Last Post: 02012011, 02:34 AM 
he graph continues to emerge each time the coordinates is calculated
By khiat in forum New To JavaReplies: 0Last Post: 12192010, 02:50 PM 
real time graph plotting in swing
By elsanthosh in forum AWT / SwingReplies: 1Last Post: 11222010, 05:06 PM 
Java program: ISBN calculated by other 9 digits?
By SNFA in forum New To JavaReplies: 5Last Post: 10092010, 05:22 AM 
Drawing 2D multi axis graph with option to get the coordinates of 2 points (user sel)
By saachin2005 in forum New To JavaReplies: 5Last Post: 10012010, 09:26 PM
Bookmarks