Im working on a code that shows a full graph and uses Dijkstra’s algoritm to show the shortest path. But the problem is: it doesnt simply visaluizate things, they're all editable and interactible.
I just need to visualize "the graph" and no to: move, edit, add, or make any interaqction with nodes and/or edges.
In this simple Jframe is where I've been trying to eliminate those interactions. But i have been failing:
public class Actions extends JFrame {
private mxGraph graph;
private mxGraphComponent graphComponent;
public Actions() {
super("JGraph - labyrinth");
initGUI();
}
private void initGUI() {
setSize(800,600);
setLocationRelativeTo(null);
graph = new mxGraph();
graphComponent = new mxGraphComponent(graph);
graphComponent.setPreferredSize(new Dimension(400, 400));
getContentPane().add(graphComponent);
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
graph.insertVertex(parent, null, "TEST", 30, 80, 100, 50);
graph.getModel().endUpdate();
}
}
So this program generates a node with the "TEST" String as name. The problem is: i can interact with this single node, i can move it everywhere, i can make many new edges as i want from the "TEST" node. And i dont want that, i just want to visaluizate my graph, no to interact with it.
EDIT: I managed to make the node unmovable, but I can still create / interact with its edges. This is the code i added:
graph.setCellsLocked(true);
graph.setVertexLabelsMovable(false);
graph.setEdgeLabelsMovable(false);