/** * Removes a jgrapht edge and its visual representation from this graph completely. * * @param edge The edge that will be removed */ private void removeEdge(E edge) { mxICell cell = edgeToCellMap.remove(edge); removeCells(new Object[] { cell }); // remove edge from hashmaps cellToEdgeMap.remove(cell); edgeToCellMap.remove(edge); }
/** * Removes a jgrapht edge and its visual representation from this graph completely. * * @param edge The edge that will be removed */ private void removeEdge(E edge) { mxICell cell = edgeToCellMap.remove(edge); removeCells(new Object[] { cell }); // remove edge from hashmaps cellToEdgeMap.remove(cell); edgeToCellMap.remove(edge); }
@Override public void vertexRemoved(GraphVertexChangeEvent<V> e) { mxICell cell = vertexToCellMap.remove(e.getVertex()); removeCells(new Object[] { cell }); // remove vertex from hashmaps cellToVertexMap.remove(cell); vertexToCellMap.remove(e.getVertex()); // remove all edges that connected to the vertex ArrayList<E> removedEdges = new ArrayList<>(); // first, generate a list of all edges that have to be deleted // so we don't change the cellToEdgeMap.values by deleting while // iterating // we have to iterate over this because the graphT has already // deleted the vertex and edges so we can't query what the edges were for (E edge : cellToEdgeMap.values()) { if (!graphT.edgeSet().contains(edge)) { removedEdges.add(edge); } } // then delete all entries of the previously generated list for (E edge : removedEdges) { removeEdge(edge); } }
@Override public void vertexRemoved(GraphVertexChangeEvent<V> e) { mxICell cell = vertexToCellMap.remove(e.getVertex()); removeCells(new Object[] { cell }); // remove vertex from hashmaps cellToVertexMap.remove(cell); vertexToCellMap.remove(e.getVertex()); // remove all edges that connected to the vertex ArrayList<E> removedEdges = new ArrayList<>(); // first, generate a list of all edges that have to be deleted // so we don't change the cellToEdgeMap.values by deleting while // iterating // we have to iterate over this because the graphT has already // deleted the vertex and edges so we can't query what the edges were for (E edge : cellToEdgeMap.values()) { if (!graphT.edgeSet().contains(edge)) { removedEdges.add(edge); } } // then delete all entries of the previously generated list for (E edge : removedEdges) { removeEdge(edge); } }