Skip to content

Commit

Permalink
saving to merge to master, small edits
Browse files Browse the repository at this point in the history
  • Loading branch information
KelBell1009 committed Sep 24, 2017
1 parent 3b160c6 commit e397cee
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 deletions.
Binary file added images/cellsociety.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 23 additions & 9 deletions src/cellsociety_team04/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@
public class Driver extends Application {

private static final String TITLE = "Cell Society";
private boolean segregationWindow = false;
private boolean segregationRunning = false;
private boolean watorWindow = false;
private boolean watorRunning = false;
private boolean fireWindow = false;
private boolean fireRunning = false;
private boolean gameoflifeWindow = false;
private boolean gameoflifeRunning = false;

private Stage menuStage;
private Stage simulationStage;
private Window menu = new MenuWindow();
private Window segregation = new SegregationWindow();
private Window wator = new WatorWindow();
private Window fire = new FireWindow();
private Window gameoflife = new GameOfLifeWindow();

/**
* Displays the menu in the window
Expand All @@ -47,11 +45,27 @@ public void start(Stage stage) {
menuStage = stage;
menuStage.setTitle(TITLE);

Window menu = new MenuWindow();
menuStage.setScene(menu.getScene());
menuStage.show();

setupSimulation();
//runSimulation();
}


private void setupSimulation() {
simulationStage = new Stage();
//TODO use title from xml file...
simulationStage.setTitle("Simulation");
}

/* private void runSimulation() {
// TODO Auto-generated method stub
if (segregation.getWindowOpen()) {
}
}
*/
/**
* Start of the program
*/
Expand Down
27 changes: 13 additions & 14 deletions src/cellsociety_team04/MenuWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;

public class MenuWindow extends Window {

Expand All @@ -27,23 +28,24 @@ public MenuWindow() {
userInteraction();
}

@Override
public void setupScene() {
addButtons();
addTitle();
}

private void userInteraction() { //http://www.java2s.com/Code/Java/JavaFX/AddClickactionlistenertoButton.htm
for (int i = 0; i < buttons.size(); i ++) {
Button button = buttons.get(i);
button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
//TODO need to have new stage open instead

}
});
}
}

@Override
public void setupScene() {
addButtons();
addTitle();
}

private void addButtons() { //https://stackoverflow.com/questions/40883858/how-to-evenly-distribute-elements-of-a-javafx-vbox
//http://docs.oracle.com/javafx/2/ui_controls/button.htm
Image segregationImage = new Image(getClass().getClassLoader().getResourceAsStream("segregation.png"));
Expand All @@ -68,20 +70,17 @@ private void addButtons() { //https://stackoverflow.com/questions/40883858/how-t

for (int i = 0; i < buttons.size(); i++) {
Button button = buttons.get(i);
//System.out.println(button);
button.setLayoutX(BUTTONOFFSET + buttons.get(i).getWidth() + i*buttonPadding);
button.setLayoutY(HEIGHT*2/3);
myRoot.getChildren().add(button);
}
}

private void addTitle() {
Text text = new Text();
text.setFont(new Font(75));
text.setWrappingWidth(WIDTH);
text.setTextAlignment(TextAlignment.CENTER);
text.setText("Cell Society");
text.setY(HEIGHT/4);
myRoot.getChildren().add(text);
Image titleImage = new Image(getClass().getClassLoader().getResourceAsStream("cellsociety.png"));
ImageView title = new ImageView(titleImage);
title.setLayoutX(WIDTH/2-title.getBoundsInLocal().getWidth()/2);
title.setLayoutY(HEIGHT*1/3-title.getBoundsInLocal().getHeight()/2);
myRoot.getChildren().add(title);
}
}
2 changes: 0 additions & 2 deletions src/cellsociety_team04/SegregationWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public class SegregationWindow extends SimulationWindow {

public SegregationWindow() {
super();


}


Expand Down
19 changes: 15 additions & 4 deletions src/cellsociety_team04/SimulationWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public abstract class SimulationWindow extends Window {
protected double cellSize;

protected List<Button> buttons;
private List<String> buttonNames = new ArrayList<String>(Arrays.asList("Start", "Step"));


protected boolean windowOpen = false;
protected boolean simulationRunning = false;

Expand Down Expand Up @@ -72,7 +71,7 @@ private void addTitle() {
}

private void addSlider() {

//TODO
}

public GridPane addGridPane() { //https://stackoverflow.com/questions/35367060/gridpane-of-squares-in-javafx
Expand All @@ -91,5 +90,17 @@ public GridPane addGridPane() { //https://stackoverflow.com/questions/35367060/g
return grid;
}


public boolean getWindowOpen() {
return windowOpen;
}
public void setWindowOpen(boolean b) {
windowOpen = b;
}

public boolean getSimulationRunning() {
return simulationRunning;
}
public void setSimulationRunning(boolean b) {
simulationRunning = b;
}
}

0 comments on commit e397cee

Please sign in to comment.