I am not regular java programmer.i need this on uregent
Thnx in advance.
Code: Select all
import javax.swing.*;
import java.lang.String;
import org.jfree.chart.*;
import org.jfree.data.xy.*;
import org.jfree.data.*;
import java.awt.image.*;
import org.jfree.chart.plot.*;
import org.jfree.chart.renderer.xy.*;
public class LineGraph extends JPanel implements Runnable{
JFreeChart innochart;
XYDataset innoDataset;
XYSeries innoSeries;
JLabel innoLabel;
Thread thread;
public LineGraph()
{
this.setBackground(java.awt.Color.white);
innoLabel = new JLabel();
this.add(innoLabel);
thread = new Thread(this);
thread.start();
}
double i = 0;
public void run(){
//xy series for a inno
innoSeries = new XYSeries("Network");
for(i = 0; i < 6; i = i + 0.1)
{
innoSeries.add(i, java.lang.Math.random());
}
while (true) {
if(i < 6)
{
//adding random data to graph
innoSeries.add(i, java.lang.Math.random() );
innoSeries.add(i+0.1, 0 );
i = i + 0.1;
}
if(i >= 6)
{
i =0.0;
}
innoDataset = new XYSeriesCollection(innoSeries);
innochart = ChartFactory.createXYAreaChart
("NETWORK USAGE", // Title
"X", // X-Axis label
"Y", // Y-Axis label
innoDataset, // Dataset
org.jfree.chart.plot.PlotOrientation.VERTICAL,
true, // Show legend
true,
true
);
//change the color of the plot
XYPlot plot = innochart.getXYPlot();
XYAreaRenderer rr = (XYAreaRenderer) plot.getRenderer();
rr.setSeriesPaint(0, new java.awt.Color(155, 155, 192));
innochart.setBackgroundPaint(java.awt.Color.white);
BufferedImage image = innochart.createBufferedImage(400,180);
innoLabel.setIcon(new ImageIcon(image));
try {
thread.currentThread().sleep(3000);
} // End of try.
catch(InterruptedException e) {
} // End of catch.
repaint();
}
}
public static void main (String args[]){
LineGraph panel = new LineGraph();
JFrame frame = new JFrame();
frame.setSize(500,400);
frame.getContentPane().add(panel);
frame.setVisible(true);
}
}