@Override public void mouseReleased(MouseEvent mouse) { // if(visualizeButton.isSelected())return; if (selectionMode.isSelected()) { if (selectedNode != null) { if (selectedNode instanceof Machine) { ui.attributesPanel.machineAP.setInfo((Machine) selectedNode); ui.attributesPanel.informationPanelCardLayout.show( ui.attributesPanel.informationPanel, Constants.machineAPCode); } else if (selectedNode instanceof Primary) { ui.attributesPanel.primaryAP.setInfo((Primary) selectedNode); ui.attributesPanel.informationPanelCardLayout.show( ui.attributesPanel.informationPanel, Constants.primaryAPCode); } else { System.out.println("Unidentified node type."); } } else if (selectedEdge != null) { ui.attributesPanel.edgeAP.setInfo(selectedEdge); ui.attributesPanel.informationPanelCardLayout.show( ui.attributesPanel.informationPanel, Constants.edgeAPCode); } else { ui.attributesPanel.informationPanelCardLayout.show( ui.attributesPanel.informationPanel, Constants.nullAPCode); } } else if (edgeMode.isSelected()) { toNode = getSelectedNode(mouse); if (fromNode != null && toNode != null && fromNode != toNode) { if (!fromNode.adjacent.contains(new Edge(fromNode, toNode))) { // System.out.println("Adding a new edge between " + fromNode + " -> " + toNode); Edge edge1 = new Edge(fromNode, toNode); Edge edge2 = new Edge(toNode, fromNode); fromNode.addAdjacentEdge(edge1); toNode.addAdjacentEdge(edge2); } } } repaint(); }