fix: Group some problem!
todo: Group next problem!
This commit is contained in:
parent
4f393f6573
commit
eb4013c413
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||
|
||||
import com.mxgraph.io.mxCodec;
|
||||
import com.mxgraph.model.mxCell;
|
||||
import com.mxgraph.model.mxGeometry;
|
||||
import com.mxgraph.model.mxGraphModel;
|
||||
import com.mxgraph.model.mxICell;
|
||||
import com.mxgraph.model.mxIGraphModel;
|
||||
|
@ -59,6 +60,11 @@ public class Graph {
|
|||
groupCell.cell.setConnectable(false);
|
||||
groupCell.cell.setVertex(true);
|
||||
groupCell.isGroup = true;
|
||||
|
||||
mxGeometry geometry = new mxGeometry();
|
||||
geometry.add(graph.graph.getGraphBounds());
|
||||
groupCell.cell.setGeometry(geometry);
|
||||
|
||||
}
|
||||
|
||||
for (final Object _cell : _cells) {
|
||||
|
@ -125,14 +131,13 @@ public class Graph {
|
|||
if(isInGroup) {
|
||||
cloned.cell.setParent(groupCell.cell);
|
||||
mxICell parent = cloned.cell.getParent();
|
||||
System.out.println(parent);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isInGroup) {
|
||||
cells.add(groupCell);
|
||||
cells.add(0, groupCell);
|
||||
}
|
||||
|
||||
return cells;
|
||||
|
@ -156,32 +161,44 @@ public class Graph {
|
|||
final List<mxCellCloned> cellCloneds2 = mxCellCloned.clone(g2, isInGroup);
|
||||
|
||||
|
||||
HashMap<String, Object> groupmap = new HashMap<String, Object>();
|
||||
HashMap<String, Object> groupmap1 = new HashMap<String, Object>();
|
||||
|
||||
cellCloneds1.forEach(cloned -> {
|
||||
|
||||
mxICell parent = cloned.cell.getParent();
|
||||
if (parent != null) {
|
||||
|
||||
Object np = groupmap.get(parent.getId());
|
||||
|
||||
Object np = groupmap1.get(parent.getId());
|
||||
if(np != null) {
|
||||
graph.getMXGraph().addCell(cloned.cell, np);
|
||||
Object add = graph.getMXGraph().addCell(cloned.cell);
|
||||
((mxCell)add).setParent((mxCell)np);
|
||||
} else {
|
||||
System.out.println("x");
|
||||
}
|
||||
|
||||
} else {
|
||||
Object groupcell = graph.getMXGraph().addCell(cloned.cell);
|
||||
groupmap.put(cloned.cell.getId(), groupcell);
|
||||
groupmap1.put(cloned.cell.getId(), groupcell);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
HashMap<String, Object> groupmap2 = new HashMap<String, Object>();
|
||||
cellCloneds2.forEach(cloned -> {
|
||||
if (cloned.cell.getParent() != null) {
|
||||
graph.getMXGraph().addCell(cloned.cell, cloned.cell.getParent());
|
||||
mxICell parent = cloned.cell.getParent();
|
||||
if (parent != null) {
|
||||
|
||||
Object np = groupmap2.get(parent.getId());
|
||||
if(np != null) {
|
||||
Object add = graph.getMXGraph().addCell(cloned.cell);
|
||||
((mxCell)add).setParent((mxCell)np);
|
||||
} else {
|
||||
System.out.println("x");
|
||||
}
|
||||
|
||||
} else {
|
||||
graph.getMXGraph().addCell(cloned.cell);
|
||||
Object groupcell = graph.getMXGraph().addCell(cloned.cell);
|
||||
groupmap2.put(cloned.cell.getId(), groupcell);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user