perspective tree layout

This commit is contained in:
Jan Prochazka
2022-08-27 10:06:06 +02:00
parent 9e3a457ef5
commit fec2df9d2f
5 changed files with 73 additions and 9 deletions

View File

@@ -633,6 +633,17 @@
return settings?.canExport;
}
// export function arrange(skipUndoChain = false) {
// switch (settings?.arrangeAlg) {
// case 'springy':
// arrange_springy(skipUndoChain);
// break;
// case 'tree':
// arrange_tree(skipUndoChain);
// break;
// }
// }
export function arrange(skipUndoChain = false, arrangeAll = true, circleMiddle = { x: 0, y: 0 }) {
const graph = new GraphDefinition();
for (const table of value?.tables || []) {
@@ -653,15 +664,27 @@
graph.initialize();
const layout = GraphLayout
// initial circle layout
.createCircle(graph, circleMiddle)
// simulation with Hook's, Coulomb's and gravity law
.springyAlg()
// move nodes to avoid overlaps
.solveOverlaps()
// view box starts with [0,0]
.fixViewBox();
let layout: GraphLayout;
switch (settings?.arrangeAlg) {
case 'springy':
layout = GraphLayout
// initial circle layout
.createCircle(graph, circleMiddle)
// simulation with Hook's, Coulomb's and gravity law
.springyAlg()
// move nodes to avoid overlaps
.solveOverlaps()
// view box starts with [0,0]
.fixViewBox();
break;
case 'tree':
layout = GraphLayout.createTree(graph, value?.rootDesignerId);
break;
}
if (!layout) {
return;
}
// layout.print();