Is there anyway i can a run auto-layout on graph edges only? I have a lot of fixed vertexes that i do not want to move/rearrange, but i do want to fix edges that overlap my cell/vertexes. Is there any way to do this?
Asked
Active
Viewed 397 times
1 Answers
0
The layouts, namely mxIGraphLayout
implementations, concern themselves with visible cells only, and they access those via the mxGraph
object API. So the proper solution is to subclass mxGraph
and override the isCellVisible(Object cell)
method according to your needs. This way you'd create an alternate view of your graph.
Of course, you can also change the actual cell visibility in the model (graph.getModel().setVisible(cell, false)
) and restore it back after the layout execution. But that seems like a hack.
Alternatively you could subclass the layout class itself and override these methods:
public boolean isVertexMovable(Object vertex)
{
return graph.isCellMovable(vertex);
}
public boolean isVertexIgnored(Object vertex)
{
return !graph.getModel().isVertex(vertex)
|| !graph.isCellVisible(vertex);
}
public boolean isEdgeIgnored(Object edge)
{
mxIGraphModel model = graph.getModel();
return !model.isEdge(edge) || !graph.isCellVisible(edge)
|| model.getTerminal(edge, true) == null
|| model.getTerminal(edge, false) == null;
}

Vsevolod Golovanov
- 4,068
- 3
- 31
- 65