Chinaunix

标题: java怎么做实时曲线? [打印本页]

作者: PHPstupid    时间: 2005-03-08 16:36
标题: java怎么做实时曲线?
用JAVA能不能做像股份行情那样实时变化的图像呢?如果行的话,哪个高人给个思路.
作者: wolfg    时间: 2005-03-08 18:16
标题: java怎么做实时曲线?
applet
作者: jamesbang2003    时间: 2005-03-08 22:00
标题: java怎么做实时曲线?
先写了一部分:
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;



/**
* @author Administrator
*
* To change the template for this generated type comment go to
* Window&ampreferences&Java&Code Generation&Code and Comments
*/
public class SineTest
{
        public static void main(String args[])
        {
                SineFrame frame = new SineFrame();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.show();
        }
}

class SineFrame extends JFrame
{
        public SineFrame()
        {
                setTitle("SineTest";
                setSize(300,400);
               
                p = new MyPanel();
               
                Container t = getContentPane();
                t.add(p);
        }
       
        private MyPanel p;
}

class MyPanel extends JPanel
{
        public MyPanel()
        {
                setSize(1000,1000);
                this.setBackground(Color.WHITE);
                System.out.println(this.getWidth());
                System.out.println(this.getHeight());
        }
       
        public void paint(Graphics g)
        {
                super.paint(g);
                int x1 = 100, y1 = 0, x2 = 100, y2 = 0;
                g.setColor(Color.RED);
                int counter = 0;
                while(counter <= 8192)
                {
                        x1 = 100;
                        y1 = 0;
                        x2 = 100;
                        y2 = (int) (100*Math.sin(counter*Math.PI/8192));
                        g.drawLine(x1,y1,x2,y2);
                        y1 = y2;
                        counter++;
                }
        }
       
        private Graphics gg;
}
完善了再都贴上来,一切讨论
作者: jamesbang2003    时间: 2005-03-08 22:05
标题: java怎么做实时曲线?
你可以做个标记,画图的部作成一个循环的形势,在数据更新之后设置个标记,循环里面判断标记是否设置,如是,则画图,不是则继续循环,尝试一下,应该可以的




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2