Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Mandelbrot上进行流体缩放?_Java_Swing - Fatal编程技术网

Java 如何在Mandelbrot上进行流体缩放?

Java 如何在Mandelbrot上进行流体缩放?,java,swing,Java,Swing,我试图在我的Mandelbrot集上实现自动缩放,但它看起来真的很落后,我不知道如何解决它。plotPoints函数绘制Mandelbrot,并在构造函数中每隔10毫秒调用一次。这是我的密码: import java.awt.Graphics; import javax.swing.Timer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.Buffer

我试图在我的Mandelbrot集上实现自动缩放,但它看起来真的很落后,我不知道如何解决它。
plotPoints
函数绘制Mandelbrot,并在构造函数中每隔10毫秒调用一次。这是我的密码:

import java.awt.Graphics;
import javax.swing.Timer;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import javax.swing.JFrame;

public class MendelbrotMain extends JFrame {

    private final int MAX_ITER = 570;
    private double ZOOM = 150;
    private BufferedImage I;
    private double zx, zy, j, k, tmp;

    public MendelbrotMain() {
        super("Mandelbrot Set");
        setBounds(100, 100, 800, 600);
        setResizable(false);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        I = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
        plotPoints();
        Timer t = new Timer(10, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                plotPoints();
                ZOOM+=100;
            }
        });
        t.setRepeats(true);
        t.start();
    }

    public void plotPoints(){
        for (int y = 0; y < getHeight(); y++) {
            for (int x = 0; x < getWidth(); x++) {
                zx = zy = 0;
                int iter = MAX_ITER;
                j = (x - 400) / ZOOM;
                k = (y - 300) / ZOOM;
                while (zx * zx + zy * zy < 4 && iter > 0) {
                    tmp = zx * zx - zy * zy + j;
                    zy = 2.0 * zx * zy + k;
                    zx = tmp;
                    iter--;
                }
                I.setRGB(x, y, iter | (iter << 8));
            }
        }
        validate();
        repaint();
    }

    @Override
    public void paint(Graphics g) {
        g.drawImage(I, 0, 0, this);
    }

    public static void main(String[] args) {
        new MendelbrotMain().setVisible(true);
    }
}
导入java.awt.Graphics;
导入javax.swing.Timer;
导入java.awt.event.ActionEvent;
导入java.awt.event.ActionListener;
导入java.awt.image.buffereImage;
导入javax.swing.JFrame;
公共类MendelbrotMain扩展JFrame{
私人最终int MAX_ITER=570;
私人双变焦=150;
私有缓冲映像I;
私人双zx、zy、j、k、tmp;
公共门德尔布罗特曼{
超级(“Mandelbrot集”);
立根(100100800600);
可设置大小(假);
setDefaultCloseOperation(关闭时退出);
I=新的BuffereImage(getWidth(),getHeight(),BuffereImage.TYPE_INT_RGB);
plotPoints();
计时器t=新计时器(10,新ActionListener(){
已执行的公共无效操作(操作事件e){
plotPoints();
缩放+=100;
}
});
t、 设置重复(真);
t、 start();
}
公共点(){
对于(int y=0;y0){
tmp=zx*zx-zy*zy+j;
zy=2.0*zx*zy+k;
zx=tmp;
国际热核聚变实验堆;
}

I.setRGB(x,y,iter |)(iter你能在10毫秒内计算曼德尔布罗特吗?一个好的方法,请参阅
javafx
demos中的
MandelbrotSet
。你能在10毫秒内计算曼德尔布罗特吗?一个好的方法,请参阅
javafx
demos中的
MandelbrotSet