old my interface
This commit is contained in:
parent
94eb62a29a
commit
7fcb3b27be
|
|
@ -12,7 +12,6 @@ import javax.swing.event.ChangeEvent;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
import backend.Simulator;
|
import backend.Simulator;
|
||||||
import backend.World;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
|
|
@ -36,13 +35,9 @@ public class MyInterface extends JFrame {
|
||||||
private JLabel speedLabel;
|
private JLabel speedLabel;
|
||||||
private JPanelDraw panelDraw;
|
private JPanelDraw panelDraw;
|
||||||
private Simulator mySimu=null;
|
private Simulator mySimu=null;
|
||||||
private World myWorld;
|
|
||||||
private JSlider randSlider;
|
private JSlider randSlider;
|
||||||
private JSlider speedSlider;
|
private JSlider speedSlider;
|
||||||
private JLabel clickLabel;
|
private JLabel clickLabel;
|
||||||
public JSlider getRandSlider() {
|
|
||||||
return randSlider;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the frame.
|
* Create the frame.
|
||||||
|
|
@ -180,9 +175,8 @@ public class MyInterface extends JFrame {
|
||||||
randSlider.setMaximum(100);
|
randSlider.setMaximum(100);
|
||||||
randSlider.setPreferredSize(new Dimension(30,200));
|
randSlider.setPreferredSize(new Dimension(30,200));
|
||||||
panelRight.add(randSlider);
|
panelRight.add(randSlider);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JButton btnBorder = new JButton("Toggle Border");
|
JButton btnBorder = new JButton("Toggle Border");
|
||||||
btnBorder.addActionListener(new ActionListener() {
|
btnBorder.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
|
@ -204,8 +198,6 @@ public class MyInterface extends JFrame {
|
||||||
clickLabel = new JLabel("click : X");
|
clickLabel = new JLabel("click : X");
|
||||||
panelRight.add(clickLabel);
|
panelRight.add(clickLabel);
|
||||||
clickLabel.setText("click : " + mySimu.clickActionName());
|
clickLabel.setText("click : " + mySimu.clickActionName());
|
||||||
|
|
||||||
myWorld = new World(100,100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -229,12 +221,10 @@ public class MyInterface extends JFrame {
|
||||||
|
|
||||||
public void instantiateSimu() {
|
public void instantiateSimu() {
|
||||||
if(mySimu==null) {
|
if(mySimu==null) {
|
||||||
mySimu = new Simulator(this, 100, 100);
|
mySimu = new Simulator(this);
|
||||||
panelDraw.setSimu(mySimu);
|
panelDraw.setSimu(mySimu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void clicButtonGo() {
|
public void clicButtonGo() {
|
||||||
this.instantiateSimu();
|
this.instantiateSimu();
|
||||||
|
|
@ -275,16 +265,9 @@ public class MyInterface extends JFrame {
|
||||||
public void generateRandomBoard() {
|
public void generateRandomBoard() {
|
||||||
this.instantiateSimu();
|
this.instantiateSimu();
|
||||||
float chanceOfLife = ((float)randSlider.getValue())/((float)randSlider.getMaximum());
|
float chanceOfLife = ((float)randSlider.getValue())/((float)randSlider.getMaximum());
|
||||||
JPanelDraw panelDraw = getPanelDessin();
|
mySimu.generateRandom(chanceOfLife);
|
||||||
mySimu.generateRandomWorld(chanceOfLife, panelDraw);
|
|
||||||
panelDraw.repaint();
|
panelDraw.repaint();
|
||||||
}
|
}
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
|
||||||
float chanceOfLife = ((float) randSlider.getValue()) / ((float)randSlider.getMaximum());
|
|
||||||
mySimu.generateRandomWorld(chanceOfLife, panelDraw);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void changeSpeed() {
|
public void changeSpeed() {
|
||||||
if(mySimu != null) {
|
if(mySimu != null) {
|
||||||
|
|
@ -296,7 +279,7 @@ public class MyInterface extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clicLoadFileButton() {
|
public void clicLoadFileButton() {
|
||||||
Simulator loadedSim = new Simulator(this, 100, 100);
|
Simulator loadedSim = new Simulator(this);
|
||||||
String fileName=SelectFile();
|
String fileName=SelectFile();
|
||||||
ArrayList<String> stringArray = new ArrayList<String>();
|
ArrayList<String> stringArray = new ArrayList<String>();
|
||||||
if (fileName.length()>0) {
|
if (fileName.length()>0) {
|
||||||
|
|
@ -324,9 +307,10 @@ public class MyInterface extends JFrame {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//trying to make the baseworld
|
||||||
//to integrate the baseworld
|
//to integrate the baseworld
|
||||||
public void clicLoadFileButtonCSV(String fileName) {
|
public void clicLoadFileButtonCSV(String fileName) {
|
||||||
Simulator loadedSim = new Simulator(this, 100, 100);
|
Simulator loadedSim = new Simulator(this);
|
||||||
//String fileName="baseworld.csv";
|
//String fileName="baseworld.csv";
|
||||||
ArrayList<String> stringArray = new ArrayList<String>();
|
ArrayList<String> stringArray = new ArrayList<String>();
|
||||||
if (fileName.length()>0) {
|
if (fileName.length()>0) {
|
||||||
|
|
@ -371,7 +355,7 @@ public class MyInterface extends JFrame {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
mySimu.rules.loadRule(stringArray);
|
mySimu.loadRule(stringArray);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -470,11 +454,5 @@ public class MyInterface extends JFrame {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue