zoukankan      html  css  js  c++  java
  • StdDraw绘图

    相关内容:

    1.Timer:定时器

    2.StdDraw绘图工具

    3.动态显示

    代码实现:

    package drawpicture;

    import com.algs4.stdlib.StdDraw;

    import java.util.Random;
    import java.util.Timer;
    import java.util.TimerTask;

    public class TimerDraw {
    public static int j=50;
    static Timer timer;
    private static int N=100;
    private static Random ran=new Random();
    public static void main(String[] args) throws Exception{
    timer = new Timer();
    StdDraw.setXscale(0,N);
    StdDraw.setYscale(0,N*N);
    //执行任务
    timer.schedule(new TimerDraw.DrawTask(), 1000, 1000);
    }

    static class DrawTask extends TimerTask {
    @Override
    public void run() {
    int i=0;
    for (; i < N; ++i) {
    StdDraw.filledRectangle(i,0,1,i*ran.nextInt(100));
    }
    try{
    Thread.sleep(500);
    }catch(Exception e){
    e.printStackTrace();
    }
    j+=10;
    if(j==100){
    timer.cancel();
    //事件到达 保留图像
    }else {
    StdDraw.clear();
    }
    }
    }
    }

    资源:
    https://share.weiyun.com/5kLvDQS
    https://share.weiyun.com/5LRwSxS
  • 相关阅读:
    DRF(四)
    DRF----------(三)
    DRF--------(二)
    DRF(一)
    VUE(四)
    VUE(三)
    VUE(二)
    DRF 序列化组件 模型层中参数补充
    django中基于python3.6使用容联发送短信
    django-jwt token校验源码简析
  • 原文地址:https://www.cnblogs.com/ssMellon/p/6422519.html
Copyright © 2011-2022 走看看