mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 13:23:58 +00:00
arrange with initial positions
This commit is contained in:
@@ -442,6 +442,8 @@
|
|||||||
nodes[table.designerId] = node;
|
nodes[table.designerId] = node;
|
||||||
node.width = rect.right - rect.left;
|
node.width = rect.right - rect.left;
|
||||||
node.height = rect.bottom - rect.top;
|
node.height = rect.bottom - rect.top;
|
||||||
|
node.initX = (rect.right + rect.left) / 2;
|
||||||
|
node.initY = (rect.bottom + rect.top) / 2;
|
||||||
// console.log('RECT', rect);
|
// console.log('RECT', rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,9 +65,10 @@ class Vector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Node {
|
class Node {
|
||||||
// must be set by renderer
|
|
||||||
width: number = 0;
|
width: number = 0;
|
||||||
height: number = 0;
|
height: number = 0;
|
||||||
|
initX: number = null;
|
||||||
|
initY: number = null;
|
||||||
|
|
||||||
constructor(public id: number, public data: {}) {}
|
constructor(public id: number, public data: {}) {}
|
||||||
}
|
}
|
||||||
@@ -196,7 +197,11 @@ export class ForceDirectedLayout {
|
|||||||
point(node) {
|
point(node) {
|
||||||
if (!(node.id in this.nodePoints)) {
|
if (!(node.id in this.nodePoints)) {
|
||||||
var mass = node.data.mass !== undefined ? node.data.mass : MASS;
|
var mass = node.data.mass !== undefined ? node.data.mass : MASS;
|
||||||
this.nodePoints[node.id] = new ForceDirectedPoint(Vector.random(), mass, node);
|
this.nodePoints[node.id] = new ForceDirectedPoint(
|
||||||
|
node.initX && node.initY ? new Vector(node.initX, node.initY) : Vector.random(),
|
||||||
|
mass,
|
||||||
|
node
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.nodePoints[node.id];
|
return this.nodePoints[node.id];
|
||||||
|
|||||||
Reference in New Issue
Block a user