if (obj instanceof mxCell) {
mxCell cell = (mxCell) obj;
SimpleVertex sv = new SimpleVertex();
int width = (int) Math.round(cell.getGeometry().getWidth());
int height = (int) Math.round(cell.getGeometry().getHeight());
VertexExt ve = new VertexExt(cell.getGeometry().getPoint(), width, height);
sv.setVertexext(ve);
sv.setProperty("id", cell.getId());
sg.addVertex(sv);
vertexes.put(cell, sv);
}
}
for (Object obj : graph.getChildEdges(parent)) {
if (obj instanceof mxCell) {
mxCell cell = (mxCell) obj;
SimpleEdge se = new SimpleEdge(vertexes.get(cell.getSource()), vertexes.get(cell.getTarget()));
se.setProperty("id", cell.getId());
sg.addEdge(se);
}
}
MultiLayerLayouter.layout(sg);
mxCell someCell = ((mxCell)vertexes.keySet().toArray()[0]);
double xscale = someCell.getGeometry().getWidth() / (vertexes.get(someCell).getVertexext().getWidth() - .5);
double yscale = someCell.getGeometry().getHeight() / (vertexes.get(someCell).getVertexext().getHeight() - .5);
for (Object obj : sg.getVertices()) {
if (obj instanceof SimpleVertex) {
SimpleVertex sv = (SimpleVertex) obj;
for (mxCell vertex: vertexes.keySet()) {
if (vertex.getId().equals(sv.getProperty("id"))) {
VertexExt ve = sv.getVertexext();
mxGeometry vertexGeometry = vertex.getGeometry();
super.setVertexLocation(vertex, ve.getLeftTop().getX()*xscale, ve.getLeftTop().getY()*yscale);
}
}
}
}