Remove one-time method from MaiNWindow.

This commit is contained in:
Holt59 2018-03-05 22:42:49 +01:00
parent c4b4455287
commit bd01aadeb1

View File

@ -184,7 +184,17 @@ public class MainWindow extends JFrame {
wccAlgorithm.addObserver(new WeaklyConnectedComponentTextObserver(printStream));
}
launchWeaklyConnectedComponentsThread(wccAlgorithm);
// We love Java...
final WeaklyConnectedComponentsAlgorithm copyAlgorithm = wccAlgorithm;
launchThread(new Runnable() {
@Override
public void run() {
AbstractSolution solution = copyAlgorithm.run();
wccPanel.solutionPanel.addSolution(solution, false);
wccPanel.solutionPanel.setVisible(true);
wccPanel.setEnabled(true);
}
});
}
});
@ -220,7 +230,15 @@ public class MainWindow extends JFrame {
spAlgorithm.addObserver(new ShortestPathTextObserver(printStream));
}
launchShortestPathThread(spAlgorithm);
final ShortestPathAlgorithm copyAlgorithm = spAlgorithm;
launchThread(new Runnable() {
@Override
public void run() {
ShortestPathSolution solution = copyAlgorithm.run();
displayShortestPathSolution(solution);
spPanel.setEnabled(true);
}
});
}
});
@ -356,30 +374,6 @@ public class MainWindow extends JFrame {
spPanel.solutionPanel.setVisible(true);
}
private void launchWeaklyConnectedComponentsThread(
WeaklyConnectedComponentsAlgorithm wccAlgorithm) {
launchThread(new Runnable() {
@Override
public void run() {
AbstractSolution solution = wccAlgorithm.run();
wccPanel.solutionPanel.addSolution(solution, false);
wccPanel.solutionPanel.setVisible(true);
wccPanel.setEnabled(true);
}
});
}
private void launchShortestPathThread(ShortestPathAlgorithm spAlgorithm) {
launchThread(new Runnable() {
@Override
public void run() {
ShortestPathSolution solution = spAlgorithm.run();
displayShortestPathSolution(solution);
spPanel.setEnabled(true);
}
});
}
/**
* Notify all listeners that a new graph has been loaded.
*/