java生成图表的问题
有如下代码:
// 随机生成并初始化数据
public void init()
{
preClose = 1000+Math.random() * 1500; // 初始化昨日收盘指数
max = preClose;
min = preClose;
for (int i = 0; i < counter; i++)
{
if (i == 0)
{
if (Math.random() > 0.5)
yPoint[i] = preClose + Math.random() * 10;
else
yPoint[i] = preClose - Math.random() * 10;
volume[i] = (int)(10000 * (1+Math.random() * 5));
}
else
{
if (Math.random() > 0.5)
{
if ((yPoint[i - 1] + Math.random() * 3) >= preClose * 1.018)
yPoint[i] = yPoint[i - 1] - Math.random() * 3;
else
yPoint[i] = yPoint[i - 1] + Math.random() * 3;
}
else
{
if ((yPoint[i - 1] - Math.random() * 3) <= preClose * 0.982)
yPoint[i] = yPoint[i - 1] + Math.random() * 3;
else
yPoint[i] = yPoint[i - 1] - Math.random() * 3;
}
if (Math.random() > 0.5)
volume[i] = volume[i - 1] + (int)(Math.random() * 10000);
else
volume[i] = volume[i - 1] - (int)(Math.random() * 10000);
if (volume[i] >= 100000)
volume[i] -= 10000+(int)(Math.random() * 5000);
if (volume[i] <= 10000)
volume[i] += 10000+(int)(Math.random() * 5000);
}
if (i == 0)
{
open = yPoint[i];
}
else if (i == counter - 1)
{
close = yPoint[i];
}
如何使得// 随机生成并初始化数据 这一块变成从mysql 数据库中读取数据并且使用数据库中数据绘制呢?请高手们指教啊,谢谢了,分不多了,就10分了啊~!