Browse Source

Fix issue with graph progress bar.

Mikael Capelle 6 years ago
parent
commit
4e541e67cf

+ 2
- 1
src/main/org/insa/graphics/GraphReaderProgressBar.java View File

@@ -37,7 +37,7 @@ public class GraphReaderProgressBar extends JDialog implements GraphReaderObserv
37 37
     private final JProgressBar[] progressBars = new JProgressBar[3];
38 38
 
39 39
     // Current element read, and modulo.
40
-    private int[] counters = new int[] { 0, 0, 0 };
40
+    private int[] counters = new int[]{ 0, 0, 0 };
41 41
     private int[] modulos = new int[3];
42 42
 
43 43
     public GraphReaderProgressBar(JFrame owner) {
@@ -75,6 +75,7 @@ public class GraphReaderProgressBar extends JDialog implements GraphReaderObserv
75 75
     @Override
76 76
     public void notifyEndReading() {
77 77
         setVisible(false);
78
+        dispose();
78 79
     }
79 80
 
80 81
     protected void initProgressBar(int index, int max) {

+ 7
- 7
src/main/org/insa/graphics/MainWindow.java View File

@@ -157,7 +157,7 @@ public class MainWindow extends JFrame {
157 157
         this.currentPalette = this.basicPalette;
158 158
 
159 159
         wccPanel = new AlgorithmPanel(this, WeaklyConnectedComponentsAlgorithm.class,
160
-                "Weakly-Connected Components", new String[] {}, false);
160
+                "Weakly-Connected Components", new String[]{}, false);
161 161
         wccPanel.addStartActionListener(new ActionListener() {
162 162
             @Override
163 163
             public void actionPerformed(ActionEvent e) {
@@ -202,7 +202,7 @@ public class MainWindow extends JFrame {
202 202
         });
203 203
 
204 204
         spPanel = new AlgorithmPanel(this, ShortestPathAlgorithm.class, "Shortest-Path",
205
-                new String[] { "Origin", "Destination" }, true);
205
+                new String[]{ "Origin", "Destination" }, true);
206 206
         spPanel.addStartActionListener(new ActionListener() {
207 207
             @Override
208 208
             public void actionPerformed(ActionEvent e) {
@@ -254,13 +254,12 @@ public class MainWindow extends JFrame {
254 254
             }
255 255
         });
256 256
 
257
-        cpPanel = new AlgorithmPanel(
258
-                this, CarPoolingAlgorithm.class, "Car-Pooling", new String[] { "Origin Car",
259
-                        "Origin Pedestrian", "Destination Car", "Destination Pedestrian" },
257
+        cpPanel = new AlgorithmPanel(this, CarPoolingAlgorithm.class, "Car-Pooling", new String[]{
258
+                "Origin Car", "Origin Pedestrian", "Destination Car", "Destination Pedestrian" },
260 259
                 true);
261 260
 
262 261
         psPanel = new AlgorithmPanel(this, PackageSwitchAlgorithm.class, "Car-Pooling",
263
-                new String[] { "Oribin A", "Origin B", "Destination A", "Destination B" }, true);
262
+                new String[]{ "Oribin A", "Origin B", "Destination A", "Destination B" }, true);
264 263
 
265 264
         // add algorithm panels
266 265
         algoPanels.add(wccPanel);
@@ -580,10 +579,10 @@ public class MainWindow extends JFrame {
580 579
                 reader.addObserver(progressBar);
581 580
                 try {
582 581
                     graph = reader.read();
583
-                    System.out.flush();
584 582
                 }
585 583
                 catch (Exception exception) {
586 584
                     progressBar.setVisible(false);
585
+                    progressBar.dispose();
587 586
                     progressBar = null;
588 587
                     JOptionPane.showMessageDialog(MainWindow.this,
589 588
                             "Unable to read graph from the selected file.");
@@ -593,6 +592,7 @@ public class MainWindow extends JFrame {
593 592
 
594 593
                 // In case of....
595 594
                 progressBar.setVisible(false);
595
+                progressBar.dispose();
596 596
                 progressBar = null;
597 597
 
598 598
                 String info = graph.getMapId();

Loading…
Cancel
Save