• PUDN用户
    了解作者
  • Java
    开发工具
  • 8KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 565
    下载次数
  • 2005-09-02 06:21
    上传日期
应用java Applet 开发的实时曲线图
curvedemo.rar
内容介绍
/* * Project: myProjectTest * Author: lidl * Auditor: * *模拟夏季气温曲线 * * Modification History * Date Type Author Description * --------------------------------------------------- * 2004-6-2 Created lidl * */ package test.chris.graphic; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.geom.Point2D; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; import javax.swing.JApplet; import javax.swing.JPanel; import com.chris.graphic.Curve; /** * @author lidl * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class TestLineGraphic extends JApplet { private Curve lineGraphic ; public TestLineGraphic() { super() ; lineGraphic=new Curve() ; init() ; } private void initLineGraphic() { //夏季气温曲线 lineGraphic.setBaseParam(31,1,45,20,1,1) ; lineGraphic.setRightStr("模拟夏季月气温曲线图") ; SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月"); long miliSeconds = System.currentTimeMillis() ; lineGraphic.setLeftStr(df.format(new Date(miliSeconds))) ; //设置x,y轴显示单位 lineGraphic.setXUnit("(日)") ; lineGraphic.setYUnit("(度)") ; lineGraphic.setXdisFrequency(2); lineGraphic.setYdisFrequency(2); //拉长X轴 lineGraphic.setXScaleAdjust(1) ; lineGraphic.setYScaleAdjust(0.6) ; lineGraphic.setWarningValue(32) ; Random rm =new Random() ; Point2D[] points= new Point2D[31]; //产生模拟数据 for (int i=1; i<=31; i++) { double yValue =rm.nextDouble()*40 ; points[i-1]=new Point2D.Double(i,yValue>=20?yValue:yValue+20); } lineGraphic.updateLine(points) ; } /* (non-Javadoc) * @see java.applet.Applet#init() */ public void init() { super.init(); initLineGraphic() ; ((JPanel)getContentPane()).add(lineGraphic,BorderLayout.CENTER) ; ((JPanel)getContentPane()).setPreferredSize(new Dimension(500,300)) ; //setSize(new Dimension(500,300)) ; } }
评论
    相关推荐