use of increment.simulator.Machine in project CSCI-6461-Simulator by lkstc112233.
the class Main method start.
@Override
public void start(Stage primaryStage) throws Exception {
Font.loadFont(getClass().getResource("/res/font/Menlo.ttf").toExternalForm(), 10);
machine = new MachineWrapper(new Machine());
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/res/fxml/FrontPanel.fxml"));
Parent root = fxmlLoader.load();
fxmlLoader.<FrontPanelController>getController().setMachine(machine);
FrontPanelController controller = fxmlLoader.getController();
Scene scene = new Scene(root);
scene.getStylesheets().add("/res/css/background.css");
primaryStage.setScene(scene);
primaryStage.setTitle("CSCI 6461 Simulator Front Panel");
primaryStage.getScene().setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent keyEvent) {
controller.keyHandler(keyEvent);
System.out.println(keyEvent.getCode());
primaryStage.getScene().setOnKeyReleased(event -> {
});
}
});
primaryStage.show();
}
use of increment.simulator.Machine in project CSCI-6461-Simulator by lkstc112233.
the class NewMain method start.
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Virtual Machine");
machine = new MachineWrapper(new Machine());
mapping = new HashMap<>();
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
for (int j = 0; j < 3; ++j) {
ColumnConstraints cc = new ColumnConstraints();
cc.setPercentWidth(100 / 3.);
grid.getColumnConstraints().add(cc);
}
for (int j = 0; j < 6; ++j) {
RowConstraints cc = new RowConstraints();
cc.setPercentHeight(100 / 6.);
grid.getRowConstraints().add(cc);
}
grid.setHgap(50);
grid.setVgap(10);
grid.setPadding(new Insets(50, 50, 50, 50));
Scene scene = new Scene(grid, 800, 600);
primaryStage.setScene(scene);
grid.add(getBox(grid, "Tick: ", machine.getTickProperty().asString()), 0, 0);
grid.add(getBox(grid, "PC: ", machine.getProgramCounterProperty()), 0, 1);
grid.add(getBox(grid, "BUS: ", machine.getBusProperty()), 0, 2);
grid.add(getBox(grid, "MAR: ", machine.getMemoryAddressRegisterProperty()), 0, 3);
grid.add(getBox(grid, "MBR: ", machine.getMemoryBufferRegisterProperty()), 0, 4);
grid.add(getBox(grid, "IR: ", machine.getInstructionRegisterProperty()), 0, 5);
grid.add(getBox(grid, "GPRF: ", machine.getGeneralPurposeRegisterFileProperty()), 1, 0, 1, 2);
grid.add(getBox(grid, "IRF: ", machine.getIndexRegisterFileProperty()), 1, 2, 1, 2);
grid.add(getBox(grid, "Control Unit: ", machine.getControlUnitProperty()), 1, 4);
grid.add(getScrollBox(grid, "Memory: ", machine.getMemoryProperty()), 2, 0, 1, 6);
automaticTick = new Timeline(new KeyFrame(Duration.millis(1), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
machine.tick();
}
}));
automaticTick.setCycleCount(Timeline.INDEFINITE);
HBox buttons = new HBox();
buttons.setSpacing(10);
grid.add(buttons, 0, 6, 3, 1);
Button btn = new Button("Tick");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
machine.tick();
}
});
buttons.getChildren().add(btn);
btn = new Button("Auto tick on/off");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (Status.RUNNING == automaticTick.getStatus())
automaticTick.pause();
else
automaticTick.play();
}
});
buttons.getChildren().add(btn);
btn = new Button("Show magic panel");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
getControlPanel().show();
}
});
buttons.getChildren().add(btn);
btn = new Button("Show front panel");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
getFrontPanel().show();
}
});
buttons.getChildren().add(btn);
btn = new Button("Show screen panel");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
getScreenPanel().show();
}
});
buttons.getChildren().add(btn);
scene.getStylesheets().add("/res/css/background.css");
primaryStage.show();
}
Aggregations