Commit 315970ad authored by edmundszagars's avatar edmundszagars
Browse files

Refactoring getData(ArrayList) method

parent 2799dae9
......@@ -7,6 +7,7 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
......@@ -27,8 +28,6 @@ public class MainWindow extends Application {
@Override
public void start(Stage primaryStage) {
results.add(new Result(new double[]{1,1,1,1},new double[]{1,1,1,1},01111));
Label label = new Label("Select file location: ");
TextField fileLocation = new TextField();
......@@ -64,16 +63,22 @@ public class MainWindow extends Application {
mergeSortCheckBox.setText("Merge sort");
mergeSortCheckBox.setSelected(true);
TableColumn dataColumn = new TableColumn("Data");
TableColumn<Result,Double> dataColumn = new TableColumn("Data");
dataColumn.setMinWidth(300);
TableColumn resultDataColumn = new TableColumn("Result");
dataColumn.setCellValueFactory(new PropertyValueFactory<>("startData"));
TableColumn<Result,Double> resultDataColumn = new TableColumn("Result");
resultDataColumn.setMinWidth(300);
TableColumn timeColumn = new TableColumn("Time");
resultDataColumn.setCellValueFactory(new PropertyValueFactory<>("resultData"));
TableColumn<Result,Long> timeColumn = new TableColumn("Time");
timeColumn.setMinWidth(100);
timeColumn.setCellValueFactory(new PropertyValueFactory<>("executionResultTime"));
table = new TableView<>();
table.setItems(getResults(results));
table.getColumns().addAll(dataColumn,resultDataColumn,timeColumn);
//table.setItems(getResults(results));
Button startButton = new Button("Run tests");
startButton.setOnAction(event -> {
......@@ -85,10 +90,8 @@ public class MainWindow extends Application {
e.printStackTrace();
}
if(bubbleSortCheckBox.isSelected()){
double[] ar = dataFromCSV.getDoubleArrayFromListItem((ArrayList) list.get(0));
double[] resultarr = BubbleSort.bubbleSort(ar);
System.out.println(BubbleSort.getBubbleSortExecutionResult());
}
});
......@@ -113,6 +116,7 @@ public class MainWindow extends Application {
public ObservableList<Result> getResults(ArrayList<Result> resultArrayList){
ObservableList<Result> results = FXCollections.observableArrayList();
results.add(new Result(new double[]{1,1,1,1},new double[]{1,1,1,1}));
results.addAll(this.results);
return results;
}
......
......@@ -7,29 +7,30 @@ public class Result {
private double[] resultData;
private long executionStartTime;
private long executionEndTime;
private long executionResultTime;
public Result(){
public Result() {
this.startData = new double[]{};
this.resultData = new double[]{};
this.executionStartTime = 0;
this.executionEndTime = 0;
}
public Result(double[] startData, double[] resultData,long executionTime){
public Result(double[] startData, double[] resultData) {
this.startData = startData;
this.resultData = resultData;
executionTime = getExecutionTime();
executionResultTime = getExecutionTime();
}
public void setExecutionStartTime() {
this.executionStartTime = System.currentTimeMillis();
}
public void setExecutionEndTime(){
public void setExecutionEndTime() {
this.executionEndTime = System.currentTimeMillis();
}
public long getExecutionTime(){
public long getExecutionTime() {
return this.executionEndTime - this.executionStartTime;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment