Je souhaite ajouter un nouveau sommet dans un graphique existant. Je créé une nouvelle cellule et je suis tenté de reconnecté mon bord, mais mon graphique ne met pas à jour (pour les bords)Insérer un sommet à l'intérieur d'un graphique
Ceci est mon code:
mxGraph graph = editor.getGraph();
mxCell selectedElt = (mxCell) graph.getSelectionCell();
Object cells[] = { selectedElt };
if (selectedElt.isEdge()) {
// cell is an edge, so we have source and target
System.out.println("Source : " + selectedElt.getSource().getId());
System.out.println("Target : " + selectedElt.getTarget().getId());
} else {
// edge before
mxCell beforeEdge = (mxCell) selectedElt.getEdgeAt(0);
// edge after
mxCell afterEdge = (mxCell) selectedElt.getEdgeAt(1);
// moving down the selected cell
graph.moveCells(cells, 0, 50);
// create a new vertex
GraphStyle graphStyle = new GraphStyle(graph);
mxCell cell = new mxCell("AAM",
new mxGeometry(selectedElt.getGeometry().getX(), selectedElt.getGeometry().getY(), 80, 50),
graphStyle.getCalculatorStyleName());
cell.setVertex(true);
beforeEdge.setTarget(cell);
graph.insertEdge(graph.getDefaultParent(), "e33", "", cell, selectedElt);
graph.addCell(cell);
graph.repaint();
}
C'est déjà wrapp mais je montre juste la partie du code qui ne fonctionne pas;). Mais c'est du travail !! Donc merci: D – amandine