I have recently started using JFreechart recently
I am adding a point to the series in Jfreechart (scatter chart) and then putting the thread to sleep for 3 seconds. I want to simultaneously show the point on the jfreechart. The above logic is in a loop, so i want a delay of 3 secs before plotting the next point.
The problem i am facing is, the point is not displayed on the chart immediately, only once the entire loop is executed all the points are shown.
I have also called revalidate and refresh but its not working.
Can anyone please please help me...I am not able to find the solution.
Below is my code :-
do {
double valX1,valY1;
valX1 = fRandom.nextGaussian();
valY1 = fRandom.nextGaussian();
double valX = Math.round(valX1 * 100.0) / 100.0;
double valY = Math.round(valY1 * 100.0) / 100.0;
double ptx1 = ((valX - xc) * tankRange)/1000;
double pty1 = ((valY - yc) * tankRange)/1000;
ptx=Math.round(ptx1 * 100.0) / 100.0;
pty=Math.round(pty1 * 100.0) / 100.0;
if ((ptx >= -(Et.getTurretWd()/2) && ptx <= Et.getTurretWd()/2) && (pty >= -(Et.getTurretHt()/2) && pty <= (Et.getTurretHt()/2))){
hitCnt++;
series.add(ptx, pty);
chartPanel.repaint();
chartPanel.revalidate();
isHit = true;
//insert into rounds table with flag as 'H' and exit the loop
try {
String strqry1 = "Insert into RoundDet (ShootId,TankID,HitMiss, XCoord, YCoord, Createddate, Modifieddate) values (" + shootid + "," + Ot.Tankid + ", 'H' ," + ptx + "," + pty + ",'" + sqlDate + "' ,'" + sqlDate +"')";
System.out.println(strqry1);
stmt.execute(strqry1);
} catch (SQLException e) {
e.printStackTrace();
} finally {
}
break;
} else {
series1.add(ptx, pty);
chartPanel.repaint();
chartPanel.revalidate();
}
Thanks, Peter
Refresh Jchart Issue
Refresh Jchart Issue
Lay ma giam gia Lazada tai MHR
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm