diff --git a/src/berack96/sim/util/graph/view/edge/EdgeListener.java b/src/berack96/sim/util/graph/view/edge/EdgeListener.java index fee506a..eb7609e 100644 --- a/src/berack96/sim/util/graph/view/edge/EdgeListener.java +++ b/src/berack96/sim/util/graph/view/edge/EdgeListener.java @@ -54,7 +54,8 @@ public abstract class EdgeListener implements GraphListener VertexComponent source = componentPressed.get(); VertexComponent destination = graphPanel.getVertexAt(e.getPoint()); - if (!graphPanel.getGraph().containsEdge(source.vertex.getValue(), destination.vertex.getValue())) + if (!graphPanel.getGraph().containsEdge(source.vertex.getValue(), destination.vertex.getValue()) + && !source.vertex.equals(destination.vertex)) graphPanel.addEdge(source, destination, buildNewEdge(source.vertex, destination.vertex)); } catch (Exception ignore) { } @@ -78,12 +79,11 @@ public abstract class EdgeListener implements GraphListener public void keyPressed(KeyEvent e) { if (edge.get() != null && Character.isDigit(e.getKeyChar())) { string.append(e.getKeyChar()); - if (!edge.get().source.equals(edge.get().destination)) - try { - graphPanel.modEdge(edge.get().source, edge.get().destination, buildEdgeFrom(string.toString())); - graphPanel.repaint(); - } catch (Exception ignored) { - } + try { + graphPanel.modEdge(edge.get().source, edge.get().destination, buildEdgeFrom(string.toString())); + graphPanel.repaint(); + } catch (Exception ignored) { + } } else { try {