I am trying to center the graph using mxGraph on the center of the graph canvas, and I am writing:
mxGraphComponent comp = ...; // this is my mxGraph component
comp.setCenterPage(true);
But the graph content position does not change at all. Do I have to do something more to center it. I am using it after using the listener to center the graph on cells which works without any problem (I provided a button for the user to recenter the graph if he wants to). For example:
mxGraphComponent comp = ...; // this is my mxGraph component
mxCell cell = ...; // this is my cell
comp.scrollCellToVisible(cell, true);
Please not that I don't need to center the graph component in its container, I want to center the graph canvas on the center of the graph.
Never mind, I had to use the following method:
mxGraphComponent comp = ...; // this is my mxGraph component
comp.setScrollToCenter(true);