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
     private final JProgressBar[] progressBars = new JProgressBar[3];
37
     private final JProgressBar[] progressBars = new JProgressBar[3];
38
 
38
 
39
     // Current element read, and modulo.
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
     private int[] modulos = new int[3];
41
     private int[] modulos = new int[3];
42
 
42
 
43
     public GraphReaderProgressBar(JFrame owner) {
43
     public GraphReaderProgressBar(JFrame owner) {
75
     @Override
75
     @Override
76
     public void notifyEndReading() {
76
     public void notifyEndReading() {
77
         setVisible(false);
77
         setVisible(false);
78
+        dispose();
78
     }
79
     }
79
 
80
 
80
     protected void initProgressBar(int index, int max) {
81
     protected void initProgressBar(int index, int max) {

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

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

Loading…
Cancel
Save