|
@@ -17,23 +17,19 @@ public class Render extends Canvas implements Runnable, MouseListener, |
|
|
public static int width;
|
|
|
public static int width;
|
|
|
public static int height;
|
|
|
public static int height;
|
|
|
public static int scale;
|
|
|
public static int scale;
|
|
|
public int fps_now;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int fps_now;
|
|
|
public boolean paused;
|
|
|
public boolean paused;
|
|
|
public String rule;
|
|
|
public String rule;
|
|
|
public boolean reset;
|
|
|
public boolean reset;
|
|
|
|
|
|
|
|
|
private Grid _grid;
|
|
|
private Grid _grid;
|
|
|
private int[] _pixels;
|
|
|
private int[] _pixels;
|
|
|
|
|
|
|
|
|
private BufferedImage _image;
|
|
|
private BufferedImage _image;
|
|
|
|
|
|
|
|
|
private long _lastTick;
|
|
|
private long _lastTick;
|
|
|
private String[] _rules;
|
|
|
private String[] _rules;
|
|
|
private JFrame _frame;
|
|
|
private JFrame _frame;
|
|
|
|
|
|
|
|
|
private JButton pauseButton;
|
|
|
private JButton pauseButton;
|
|
|
|
|
|
|
|
|
private Random random = new Random();
|
|
|
private Random random = new Random();
|
|
|
|
|
|
|
|
|
public Render(int width, int height, Grid g, String[] rules) {
|
|
|
public Render(int width, int height, Grid g, String[] rules) {
|
|
@@ -80,15 +76,13 @@ public class Render extends Canvas implements Runnable, MouseListener, |
|
|
|
|
|
|
|
|
private void setFrame() {
|
|
|
private void setFrame() {
|
|
|
JMenuBar menuBar = new JMenuBar();
|
|
|
JMenuBar menuBar = new JMenuBar();
|
|
|
JMenu menuMain = new JMenu("Menu");
|
|
|
|
|
|
JMenu menuAlgo = new JMenu("Algorithms");
|
|
|
JMenu menuAlgo = new JMenu("Algorithms");
|
|
|
for (String rule : _rules) {
|
|
|
for (String rule : _rules) {
|
|
|
JMenuItem menuAlgoItem = new JMenuItem(rule);
|
|
|
JMenuItem menuAlgoItem = new JMenuItem(rule);
|
|
|
menuAlgo.add(menuAlgoItem);
|
|
|
menuAlgo.add(menuAlgoItem);
|
|
|
menuAlgoItem.addActionListener(this);
|
|
|
menuAlgoItem.addActionListener(this);
|
|
|
}
|
|
|
}
|
|
|
menuMain.add(menuAlgo);
|
|
|
|
|
|
menuBar.add(menuMain);
|
|
|
|
|
|
|
|
|
menuBar.add(menuAlgo);
|
|
|
|
|
|
|
|
|
pauseButton = new JButton("Pause");
|
|
|
pauseButton = new JButton("Pause");
|
|
|
pauseButton.setActionCommand("pause");
|
|
|
pauseButton.setActionCommand("pause");
|
|
|