1
1
package graphics ;
2
2
3
- import algorithm .Algorithm ;
4
- import algorithm .BitonicSort ;
5
- import algorithm .BubbleSort ;
6
- import algorithm .CoctailSort ;
7
- import algorithm .CombSort ;
8
- import algorithm .CycleSort ;
9
- import algorithm .HeapSort ;
10
- import algorithm .InsertionSort ;
11
- import algorithm .IterativeQuickSort ;
12
- import algorithm .RecursiveMergeSort ;
13
- import algorithm .MergeSort ;
14
- import algorithm .OddEvenSort ;
15
- import algorithm .PancakeSort ;
16
- import algorithm .QuickSort ;
17
- import algorithm .RecursiveBubbleSort ;
18
- import algorithm .RecursiveInsertionSort ;
19
- import algorithm .RecursiveQuickSort ;
20
- import algorithm .SelectionSort ;
21
- import algorithm .ShellSort ;
22
- import algorithm .StoogeSort ;
3
+ import algorithm .*;
23
4
import java .io .BufferedReader ;
24
5
import java .io .File ;
25
6
import java .io .FileReader ;
32
13
import javafx .event .ActionEvent ;
33
14
import javafx .fxml .FXML ;
34
15
import javafx .fxml .Initializable ;
16
+ import javafx .geometry .Pos ;
35
17
import javafx .scene .control .Button ;
36
18
import javafx .scene .control .ChoiceBox ;
37
19
import javafx .scene .control .Label ;
@@ -56,13 +38,13 @@ public class GuiController implements Initializable {
56
38
private Button restoreB ;
57
39
58
40
private List <Double > list ;
59
- private int wid = 10 ;
60
- private int hei = 10 ;
41
+ private double wid = 10 ;
42
+ private double hei = 10 ;
61
43
private Stage stage ;
62
44
private FileChooser fileChooser ;
63
45
private Algorithm algorithm ;
64
46
private double min ;
65
- private final double multiplier = 1.1 ;
47
+ private final double multiplier = 1.5 ;
66
48
private File openedFile ;
67
49
68
50
@ Override
@@ -71,7 +53,8 @@ public void initialize(URL url, ResourceBundle rb) {
71
53
"Insertion sort" , "Iterative quick sort" , "Merge sort" , "Odd-Even sort" , "Pancake sort" ,
72
54
"Quick sort" , "Recursive bubble sort" , "Recursive insertion sort" , "Recursive merge sort" , "Recursive Quick sort" ,
73
55
"Selection sort" , "Shell sort" , "Stooge sort" );
74
- // sortingAlgorithm.getItems().addAll("Quick sort end", "Recursive Quick sort end");
56
+ // sortingAlgorithm.getItems().add("Quick sort");
57
+ sortingAlgorithm .setValue ("Quick sort" );
75
58
startB .setDisable (true );
76
59
list = new ArrayList <>();
77
60
}
@@ -84,8 +67,8 @@ public void calculateSizeMultipliers() {
84
67
} else {
85
68
min = Math .abs (min );
86
69
}
87
- wid = ( int ) ( display .getWidth () / list .size () );
88
- hei = ( int ) ( display .getHeight () / ((double ) Collections .max (list ) + multiplier * min ) );
70
+ wid = display .getWidth () / list .size ();
71
+ hei = display .getHeight () / ((double ) Collections .max (list ) + multiplier * min );
89
72
}
90
73
}
91
74
@@ -100,8 +83,10 @@ public void drawArray() {
100
83
display .getChildren ().add (r );
101
84
Label label = new Label (list .get (i ).toString ());
102
85
label .setFont (new Font (16 ));
103
- label .setLayoutX (wid * i + wid / 3 );
86
+ label .setLayoutX (wid * i );
104
87
label .setLayoutY ((display .getHeight ()) - (hei * (list .get (i ) + multiplier * min )) / 2 );
88
+ label .setPrefWidth (wid );
89
+ label .setAlignment (Pos .CENTER );
105
90
display .getChildren ().add (label );
106
91
}
107
92
}
@@ -155,7 +140,7 @@ private void loadFromFile() {
155
140
}
156
141
}
157
142
}
158
-
143
+
159
144
@ FXML
160
145
private void loadArray (ActionEvent event ) {
161
146
// create fileChooser to open txt file
0 commit comments