|
@@ -44,6 +44,8 @@ import javax.swing.filechooser.FileNameExtensionFilter;
|
44
|
44
|
|
45
|
45
|
import org.insa.algo.AbstractSolution;
|
46
|
46
|
import org.insa.algo.AlgorithmFactory;
|
|
47
|
+import org.insa.algo.carpooling.CarPoolingAlgorithm;
|
|
48
|
+import org.insa.algo.packageswitch.PackageSwitchAlgorithm;
|
47
|
49
|
import org.insa.algo.shortestpath.ShortestPathAlgorithm;
|
48
|
50
|
import org.insa.algo.shortestpath.ShortestPathData;
|
49
|
51
|
import org.insa.algo.shortestpath.ShortestPathGraphicObserver;
|
|
@@ -112,7 +114,7 @@ public class MainWindow extends JFrame {
|
112
|
114
|
|
113
|
115
|
// Algorithm panels
|
114
|
116
|
private final List<AlgorithmPanel> algoPanels = new ArrayList<>();
|
115
|
|
- private final AlgorithmPanel wccPanel, spPanel;
|
|
117
|
+ private final AlgorithmPanel wccPanel, spPanel, cpPanel, psPanel;
|
116
|
118
|
|
117
|
119
|
// Path panel
|
118
|
120
|
private final PathsPanel pathPanel;
|
|
@@ -161,7 +163,7 @@ public class MainWindow extends JFrame {
|
161
|
163
|
this.currentPalette = this.basicPalette;
|
162
|
164
|
|
163
|
165
|
wccPanel = new AlgorithmPanel(this, WeaklyConnectedComponentsAlgorithm.class,
|
164
|
|
- "Weakly-Connected Components", new String[] {}, false, false);
|
|
166
|
+ "Weakly-Connected Components", new String[]{}, false, false);
|
165
|
167
|
wccPanel.addStartActionListener(new ActionListener() {
|
166
|
168
|
@Override
|
167
|
169
|
public void actionPerformed(ActionEvent e) {
|
|
@@ -206,7 +208,7 @@ public class MainWindow extends JFrame {
|
206
|
208
|
});
|
207
|
209
|
|
208
|
210
|
spPanel = new AlgorithmPanel(this, ShortestPathAlgorithm.class, "Shortest-Path",
|
209
|
|
- new String[] { "Origin", "Destination" }, true, true);
|
|
211
|
+ new String[]{ "Origin", "Destination" }, true, true);
|
210
|
212
|
spPanel.addStartActionListener(new ActionListener() {
|
211
|
213
|
@Override
|
212
|
214
|
public void actionPerformed(ActionEvent e) {
|
|
@@ -258,21 +260,35 @@ public class MainWindow extends JFrame {
|
258
|
260
|
}
|
259
|
261
|
});
|
260
|
262
|
|
|
263
|
+ cpPanel = new AlgorithmPanel(
|
|
264
|
+ this, CarPoolingAlgorithm.class, "Car-Pooling", new String[]{ "Origin Car",
|
|
265
|
+ "Origin Pedestrian", "Destination Car", "Destination Pedestrian" },
|
|
266
|
+ true, true);
|
|
267
|
+
|
|
268
|
+ psPanel = new AlgorithmPanel(this, PackageSwitchAlgorithm.class, "Car-Pooling",
|
|
269
|
+ new String[]{ "Oribin A", "Origin B", "Destination A", "Destination B" }, true,
|
|
270
|
+ true);
|
|
271
|
+
|
261
|
272
|
// add algorithm panels
|
262
|
273
|
algoPanels.add(wccPanel);
|
263
|
274
|
algoPanels.add(spPanel);
|
|
275
|
+ algoPanels.add(cpPanel);
|
|
276
|
+ algoPanels.add(psPanel);
|
264
|
277
|
|
265
|
278
|
this.pathPanel = new PathsPanel(this);
|
266
|
279
|
|
267
|
280
|
// Add click listeners to both drawing.
|
268
|
|
- basicDrawing.addDrawingClickListener(spPanel.nodesInputPanel);
|
269
|
|
- mapViewDrawing.addDrawingClickListener(spPanel.nodesInputPanel);
|
270
|
281
|
|
271
|
|
- this.graphChangeListeneres.add(spPanel.nodesInputPanel);
|
272
|
|
- this.graphChangeListeneres.add(spPanel.solutionPanel);
|
|
282
|
+ for (AlgorithmPanel panel: algoPanels) {
|
|
283
|
+ this.basicDrawing.addDrawingClickListener(panel.nodesInputPanel);
|
|
284
|
+ this.mapViewDrawing.addDrawingClickListener(panel.nodesInputPanel);
|
|
285
|
+ this.graphChangeListeneres.add(panel.nodesInputPanel);
|
|
286
|
+ this.graphChangeListeneres.add(panel.solutionPanel);
|
|
287
|
+ this.drawingChangeListeners.add(panel.nodesInputPanel);
|
|
288
|
+ this.drawingChangeListeners.add(panel.solutionPanel);
|
|
289
|
+ }
|
|
290
|
+
|
273
|
291
|
this.graphChangeListeneres.add(pathPanel);
|
274
|
|
- this.drawingChangeListeners.add(spPanel.nodesInputPanel);
|
275
|
|
- this.drawingChangeListeners.add(spPanel.solutionPanel);
|
276
|
292
|
this.drawingChangeListeners.add(pathPanel);
|
277
|
293
|
|
278
|
294
|
// Create action factory.
|
|
@@ -738,19 +754,42 @@ public class MainWindow extends JFrame {
|
738
|
754
|
}));
|
739
|
755
|
|
740
|
756
|
// Shortest path
|
741
|
|
- JMenuItem spItem = new JMenuItem("Shortest Path");
|
|
757
|
+ JMenuItem spItem = new JMenuItem("Shortest-Path");
|
742
|
758
|
spItem.addActionListener(baf.createBlockingAction(new ActionListener() {
|
743
|
759
|
@Override
|
744
|
760
|
public void actionPerformed(ActionEvent e) {
|
745
|
761
|
enableAlgorithmPanel(spPanel);
|
746
|
762
|
}
|
747
|
763
|
}));
|
|
764
|
+
|
|
765
|
+ // Car pooling
|
|
766
|
+ JMenuItem cpItem = new JMenuItem("Car Pooling");
|
|
767
|
+ cpItem.addActionListener(baf.createBlockingAction(new ActionListener() {
|
|
768
|
+ @Override
|
|
769
|
+ public void actionPerformed(ActionEvent e) {
|
|
770
|
+ enableAlgorithmPanel(cpPanel);
|
|
771
|
+ }
|
|
772
|
+ }));
|
|
773
|
+
|
|
774
|
+ // Car pooling
|
|
775
|
+ JMenuItem psItem = new JMenuItem("Package Switch");
|
|
776
|
+ psItem.addActionListener(baf.createBlockingAction(new ActionListener() {
|
|
777
|
+ @Override
|
|
778
|
+ public void actionPerformed(ActionEvent e) {
|
|
779
|
+ enableAlgorithmPanel(psPanel);
|
|
780
|
+ }
|
|
781
|
+ }));
|
|
782
|
+
|
748
|
783
|
graphLockItems.add(wccItem);
|
749
|
784
|
graphLockItems.add(spItem);
|
|
785
|
+ graphLockItems.add(cpItem);
|
|
786
|
+ graphLockItems.add(psItem);
|
750
|
787
|
|
751
|
788
|
algoMenu.add(wccItem);
|
752
|
789
|
algoMenu.addSeparator();
|
753
|
790
|
algoMenu.add(spItem);
|
|
791
|
+ algoMenu.add(cpItem);
|
|
792
|
+ algoMenu.add(psItem);
|
754
|
793
|
|
755
|
794
|
// Create the menu bar.
|
756
|
795
|
JMenuBar menuBar = new JMenuBar();
|