Fix issue with ProgressBar for loading graphs.

This commit is contained in:
Holt59 2018-03-14 21:30:37 +01:00
parent 25e35b9bc4
commit ec9cd9c601
2 changed files with 9 additions and 11 deletions

View File

@ -1,7 +1,6 @@
package org.insa.graphics; package org.insa.graphics;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import javax.swing.Box; import javax.swing.Box;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
@ -38,7 +37,7 @@ public class GraphReaderProgressBar extends JDialog implements GraphReaderObserv
private final JProgressBar[] progressBars = new JProgressBar[3]; private final JProgressBar[] progressBars = new JProgressBar[3];
// Current element read, and modulo. // Current element read, and modulo.
private int[] counters = new int[]{ 0, 0, 0 }; private int[] counters = new int[] { 0, 0, 0 };
private int[] modulos = new int[3]; private int[] modulos = new int[3];
public GraphReaderProgressBar(JFrame owner) { public GraphReaderProgressBar(JFrame owner) {
@ -63,13 +62,8 @@ public class GraphReaderProgressBar extends JDialog implements GraphReaderObserv
} }
pane.add(Box.createVerticalGlue()); pane.add(Box.createVerticalGlue());
pane.setPreferredSize(new Dimension(300, 120));
setContentPane(pane); setContentPane(pane);
pack(); pack();
} }
@Override @Override

View File

@ -157,7 +157,7 @@ public class MainWindow extends JFrame {
this.currentPalette = this.basicPalette; this.currentPalette = this.basicPalette;
wccPanel = new AlgorithmPanel(this, WeaklyConnectedComponentsAlgorithm.class, wccPanel = new AlgorithmPanel(this, WeaklyConnectedComponentsAlgorithm.class,
"Weakly-Connected Components", new String[]{}, false, false); "Weakly-Connected Components", new String[] {}, false, false);
wccPanel.addStartActionListener(new ActionListener() { wccPanel.addStartActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -202,7 +202,7 @@ public class MainWindow extends JFrame {
}); });
spPanel = new AlgorithmPanel(this, ShortestPathAlgorithm.class, "Shortest-Path", spPanel = new AlgorithmPanel(this, ShortestPathAlgorithm.class, "Shortest-Path",
new String[]{ "Origin", "Destination" }, true, true); new String[] { "Origin", "Destination" }, true, true);
spPanel.addStartActionListener(new ActionListener() { spPanel.addStartActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -255,12 +255,12 @@ public class MainWindow extends JFrame {
}); });
cpPanel = new AlgorithmPanel( cpPanel = new AlgorithmPanel(
this, CarPoolingAlgorithm.class, "Car-Pooling", new String[]{ "Origin Car", this, CarPoolingAlgorithm.class, "Car-Pooling", new String[] { "Origin Car",
"Origin Pedestrian", "Destination Car", "Destination Pedestrian" }, "Origin Pedestrian", "Destination Car", "Destination Pedestrian" },
true, true); true, true);
psPanel = new AlgorithmPanel(this, PackageSwitchAlgorithm.class, "Car-Pooling", psPanel = new AlgorithmPanel(this, PackageSwitchAlgorithm.class, "Car-Pooling",
new String[]{ "Oribin A", "Origin B", "Destination A", "Destination B" }, true, new String[] { "Oribin A", "Origin B", "Destination A", "Destination B" }, true,
true); true);
// add algorithm panels // add algorithm panels
@ -592,6 +592,10 @@ public class MainWindow extends JFrame {
return; return;
} }
// In case of....
progressBar.setVisible(false);
progressBar = null;
String info = graph.getMapId(); String info = graph.getMapId();
if (graph.getMapName() != null && !graph.getMapName().isEmpty()) { if (graph.getMapName() != null && !graph.getMapName().isEmpty()) {
// The \u200e character is the left-to-right mark, we need to avoid issue with // The \u200e character is the left-to-right mark, we need to avoid issue with