Jgraphx 制作确定性图形
有可能使图形具有确定性吗?我的意思是,例如: 如果我先加一个顶点,然后再加上B,这个图看起来就像我先加上B,然后再加上A一样Jgraphx 制作确定性图形,jgraphx,Jgraphx,有可能使图形具有确定性吗?我的意思是,例如: 如果我先加一个顶点,然后再加上B,这个图看起来就像我先加上B,然后再加上A一样 我目前正在使用mxCompactTreeLayout,但它不能像我希望的那样工作。是的,当然可以,但是您需要自己创建规则,因为它们可能非常特定于您的用例。我从mxGraphComponent.ImportCell继承mxGraphComponent并重写ImportCell-方法,从mxGraphComponent.ImportCell中调用此逻辑,以便在必要时注入关系并
我目前正在使用mxCompactTreeLayout,但它不能像我希望的那样工作。是的,当然可以,但是您需要自己创建规则,因为它们可能非常特定于您的用例。我从mxGraphComponent.ImportCell继承mxGraphComponent并重写
ImportCell
-方法,从mxGraphComponent.ImportCell
中调用此逻辑,以便在必要时注入关系并重新组织图
@Override
public Object[] importCells(Object[] cells, double dx, double dy, Object target, Point location) {
Object[] importedCells = super.importCells(cells, dx, dy, target, location);
for (Object cell : importedCells) {
updateGraphRelationsFor(cell);
}
return importedCells;
}
请注意,我使用从
super.importCells
方法返回的importedCells
调用updateGraphRelationsFor()
,因为它们将在该方法内部克隆。是的,当然,但是您需要自己创建规则,因为它们可能非常特定于您的用例。我从mxGraphComponent.ImportCell继承mxGraphComponent并重写ImportCell
-方法,从mxGraphComponent.ImportCell
中调用此逻辑,以便在必要时注入关系并重新组织图
@Override
public Object[] importCells(Object[] cells, double dx, double dy, Object target, Point location) {
Object[] importedCells = super.importCells(cells, dx, dy, target, location);
for (Object cell : importedCells) {
updateGraphRelationsFor(cell);
}
return importedCells;
}
请注意,我使用从super.importCells
方法返回的importedCells
调用updateGraphRelationsFor()
,因为它们将在该方法内部克隆