Skip to content

Commit 800d659

Browse files
committed
version 3.1
1 parent 43143d4 commit 800d659

27 files changed

+192
-93
lines changed

bin/soundfont/sfx.sf2

3.06 MB
Binary file not shown.

dist/arrayVisualizer.jar

2.89 MB
Binary file not shown.

src/frames/UtilFrame.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,15 +382,26 @@ else if(!this.abstractFrame.isVisible()) {
382382
}
383383

384384
if(speedPromptAllowed) {
385-
try{
386-
double oldRatio = Delays.getSleepRatio();
387-
double newRatio = Double.parseDouble(JOptionPane.showInputDialog(null, "Modify the visual's speed below (Ex. 10 = Ten times faster)", oldRatio));
388-
if(newRatio == 0) throw new Exception("Divide by zero!");
389-
Delays.setSleepRatio(newRatio);
390-
Delays.updateCurrentDelay(oldRatio, Delays.getSleepRatio());
391-
}
392-
catch(Exception e) { //TODO: Display not a number instead of println
393-
System.out.println("Not a number! (" + e.getMessage() + ")");
385+
boolean showPrompt = true;
386+
while(showPrompt) {
387+
try {
388+
double oldRatio = Delays.getSleepRatio();
389+
String userInput = JOptionPane.showInputDialog(null, "Modify the visual's speed below (Ex. 10 = Ten times faster)", oldRatio);
390+
if(userInput == null) {
391+
showPrompt = false;
392+
}
393+
else {
394+
double newRatio = Double.parseDouble(userInput);
395+
if(newRatio == 0) throw new Exception("Divide by zero");
396+
Delays.setSleepRatio(newRatio);
397+
Delays.updateCurrentDelay(oldRatio, Delays.getSleepRatio());
398+
showPrompt = false;
399+
}
400+
}
401+
catch(Exception e) {
402+
showPrompt = true;
403+
JOptionPane.showMessageDialog(null, "Not a number! (" + e.getMessage() + ")", "Error", JOptionPane.ERROR_MESSAGE);
404+
}
394405
}
395406
}
396407
}//GEN-LAST:event_jButton3ActionPerformed

src/main/ArrayManager.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package main;
22

3+
import javax.swing.JOptionPane;
4+
5+
import templates.JErrorPane;
36
import utils.Delays;
47
import utils.Highlights;
58
import utils.Shuffles;
@@ -139,7 +142,7 @@ public void refreshArray(int[] array, int currentLen, ArrayVisualizer ArrayVisua
139142
try {
140143
Thread.sleep(1000);
141144
} catch (InterruptedException e) {
142-
e.printStackTrace();
145+
JErrorPane.invokeErrorMessage(e);
143146
}
144147

145148
ArrayVisualizer.resetAllStatistics();
@@ -153,7 +156,7 @@ public void refreshArray(int[] array, int currentLen, ArrayVisualizer ArrayVisua
153156
try {
154157
Thread.sleep(500);
155158
} catch (InterruptedException e) {
156-
e.printStackTrace();
159+
JErrorPane.invokeErrorMessage(e);
157160
}
158161

159162
ArrayVisualizer.resetAllStatistics();

src/main/ArrayVisualizer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
* - - options to choose timsort minrun
5757
* - - subheadings for sort customizations (e.g. number of buckets for all bucket sorts)
5858
* - - toggle between pointer and black bar
59+
* - - SINE WAVE VISUAL!!!
5960
* - Make:
6061
* - - "Many Similar" distribution ((i / 5) * 5, as an example)
6162
* - - Better names/clean up code in frames/prompts

src/main/SortAnalyzer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import java.util.ArrayList;
55
import java.util.List;
66

7+
import javax.swing.JOptionPane;
8+
79
import io.github.classgraph.ClassGraph;
810
import io.github.classgraph.ClassInfo;
911
import io.github.classgraph.ScanResult;
10-
12+
import templates.JErrorPane;
1113
import templates.Sort;
1214
import utils.Delays;
1315
import utils.Highlights;
@@ -71,7 +73,7 @@ public void analyzeSorts() {
7173
Class<?> sortClass = Class.forName(sortFiles.get(i).getName());
7274
Constructor<?> newSort = sortClass.getConstructor(new Class[] {Delays.class, Highlights.class, Reads.class, Writes.class});
7375
Sort sort = (Sort) newSort.newInstance(this.Delays, this.Highlights, this.Reads, this.Writes);
74-
76+
7577
try {
7678
if(verifySort(sort)) {
7779
if(sort.comparisonBased()) {
@@ -95,10 +97,8 @@ public void analyzeSorts() {
9597
e.printStackTrace();
9698
}
9799
}
98-
} catch (SecurityException e) {
99-
e.printStackTrace();
100-
} catch (IllegalArgumentException e) {
101-
e.printStackTrace();
100+
} catch (SecurityException | IllegalArgumentException e) {
101+
JErrorPane.invokeErrorMessage(e);
102102
}
103103
}
104104

src/prompts/ShufflePrompt.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
package prompts;
66

77
import javax.swing.JFrame;
8+
import javax.swing.JOptionPane;
89

910
import frames.UtilFrame;
1011
import main.ArrayManager;
1112
import templates.Frame;
13+
import templates.JErrorPane;
1214
import utils.Shuffles;
1315

1416
/*
@@ -108,7 +110,7 @@ public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
108110
try {
109111
jList1ValueChanged(evt);
110112
} catch (Exception e) {
111-
e.printStackTrace();
113+
JErrorPane.invokeErrorMessage(e);
112114
}
113115
}
114116
});

src/prompts/SortPrompt.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
package prompts;
66

77
import javax.swing.JFrame;
8+
import javax.swing.JOptionPane;
89

910
import frames.UtilFrame;
1011
import main.ArrayVisualizer;
1112
import templates.Frame;
13+
import templates.JErrorPane;
1214
import threads.RunAllSorts;
1315
import threads.RunComparisonSort;
1416
import threads.RunDistributionSort;
@@ -190,8 +192,7 @@ public void run(){
190192
RunAllSorts RunAllSorts = new RunAllSorts(ArrayVisualizer);
191193
RunAllSorts.ReportAllSorts(array, 0, 0);
192194
} catch (Exception e) {
193-
// TODO Auto-generated catch block
194-
e.printStackTrace();
195+
JErrorPane.invokeErrorMessage(e);
195196
}
196197
}
197198
}.start();
@@ -209,8 +210,7 @@ public void run(){
209210
RunDistributionSort sortThread = new RunDistributionSort(ArrayVisualizer);
210211
sortThread.ReportDistributiveSort(array, selection);
211212
} catch (Exception e) {
212-
// TODO Auto-generated catch block
213-
e.printStackTrace();
213+
JErrorPane.invokeErrorMessage(e);
214214
}
215215
}
216216
}.start();

src/soundfont/SFXFetcher.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package soundfont;
2+
3+
import java.io.InputStream;
4+
5+
final public class SFXFetcher {
6+
private InputStream sfxFile;
7+
8+
public SFXFetcher() {
9+
this.sfxFile = this.getClass().getResourceAsStream("sfx.sf2");
10+
}
11+
12+
public InputStream getSFXFile() {
13+
return this.sfxFile;
14+
}
15+
}

src/soundfont/sfx.sf2

3.06 MB
Binary file not shown.

0 commit comments

Comments
 (0)