We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2a9071a commit 3e339beCopy full SHA for 3e339be
README.md
@@ -5,8 +5,14 @@ By @Alimov-8👨🏻💻 and @Rustam-Z👨🏼💻
5
Updated: December 5, 2020
6
7
### References:
8
+- https://clementmihailescu.github.io/Sorting-Visualizer/
9
+
10
- https://www.geeksforgeeks.org/java-swing-jmenubar/
11
12
- https://stackoverflow.com/questions/31094904/jmenu-not-appearing-until-window-is-resized
13
-- https://stackoverflow.com/questions/4716372/java-how-do-i-close-a-jframe-while-opening-another-one
14
+- https://stackoverflow.com/questions/4716372/java-how-do-i-close-a-jframe-while-opening-another-one
15
16
+- https://www.youtube.com/watch?v=RxjXC1SM1A4
17
18
+- https://stackoverflow.com/questions/4246351/creating-random-colour-in-java
Sorting.java
@@ -75,7 +75,7 @@ else if (e.getSource() == jbtMerge)
75
else if (e.getSource() == jbtBubble)
76
System.out.println("jbtBubble button clicked");
77
else if (e.getSource() == jbtInsertion) {
78
- sortAlgo.initSorter(); // Sorting algotithm
+ sortAlgo.insertionSort(); // Sorting algotithm
79
sortAlgo.initShuffler();
80
}
81
else if (e.getSource() == jbtSelection)
SortingAlgorithm.java
@@ -27,11 +27,18 @@ public class SortingAlgorithm extends JPanel {
27
public void paintComponent(Graphics g) {
28
super.paintComponent(g);
29
30
+ Random random = new Random(); // Random
31
32
// Drawing the rectangles
33
Graphics2D g2d = (Graphics2D)g;
- g2d.setColor(Color.CYAN);
34
Rectangle2D.Float bar;
35
36
for(int i = 0; i < SIZE; i++ ) {
37
+ final float hue = random.nextFloat();
38
+ final float saturation = 0.9f;//1.0 for brilliant, 0.0 for dull
39
+ final float luminance = 1.0f; //1.0 for brighter, 0.0 for black
40
41
+ g2d.setColor(Color.getHSBColor(hue, saturation, luminance));
42
bar = new Rectangle2D.Float(i * BAR_WIDTH, 0, BAR_WIDTH, bar_height[i]);
43
g2d.fill(bar); // g2d.draw(bar);
44
@@ -47,7 +54,7 @@ public void paintComponent(Graphics g) {
47
54
g2d.fill(bar);
48
55
49
56
50
- public void initSorter() {
57
+ public void insertionSort() {
51
58
/*Insertion sort algorithm*/
52
59
53
60
sorter = new SwingWorker<>() {
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments