Link inputs directly to MainWindow to avoid issue when loading new graph/redrawing.

This commit is contained in:
Holt59
2018-02-25 20:16:10 +01:00
parent b192bb4f07
commit 1f06fc1eec
4 changed files with 41 additions and 165 deletions

View File

@@ -22,10 +22,8 @@ import javax.swing.border.EmptyBorder;
import org.insa.algo.shortestpath.ShortestPathAlgorithm;
import org.insa.algo.shortestpath.ShortestPathAlgorithmFactory;
import org.insa.algo.shortestpath.ShortestPathData.Mode;
import org.insa.graph.Graph;
import org.insa.graph.Node;
import org.insa.graphics.NodesInputPanel.InputChangedEvent;
import org.insa.graphics.drawing.Drawing;
public class ShortestPathPanel extends JPanel {
@@ -89,7 +87,7 @@ public class ShortestPathPanel extends JPanel {
};
// Input panels for node.
private NodesInputPanel nodesInputPanel;
protected NodesInputPanel nodesInputPanel;
// Component that can be enabled/disabled.
private ArrayList<JComponent> components = new ArrayList<>();
@@ -97,7 +95,7 @@ public class ShortestPathPanel extends JPanel {
// Start listeners
List<ActionListener> startActionListeners = new ArrayList<>();
public ShortestPathPanel(Drawing drawing, Graph graph) {
public ShortestPathPanel(MainWindow mainWindow) {
super();
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
@@ -124,7 +122,7 @@ public class ShortestPathPanel extends JPanel {
components.add(algoSelect);
// Add inputs for node.
this.nodesInputPanel = new NodesInputPanel(drawing, graph);
this.nodesInputPanel = new NodesInputPanel(mainWindow);
this.nodesInputPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
nodesInputPanel.addTextField("Origin: ", new Color(57, 172, 115));
nodesInputPanel.addTextField("Destination: ", new Color(255, 77, 77));