Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Edmunds Žagars
Java_course_final
Commits
315970ad
Commit
315970ad
authored
Mar 30, 2018
by
edmundszagars
Browse files
Refactoring getData(ArrayList) method
parent
2799dae9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
13 deletions
+18
-13
src/gui/MainWindow.java
src/gui/MainWindow.java
+12
-8
src/helper/Result.java
src/helper/Result.java
+6
-5
No files found.
src/gui/MainWindow.java
View file @
315970ad
...
...
@@ -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
;
}
...
...
src/helper/Result.java
View file @
315970ad
...
...
@@ -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
();
execution
Result
Time
=
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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment