Graph Layout: Do not let nodes pos go < 0

Otherwise they fall off the visible area
This commit is contained in:
Vishesh Handa
2020-09-26 01:13:37 +02:00
parent dcc7459b8f
commit e616d69773

View File

@ -46,6 +46,8 @@ class Graph extends ChangeNotifier {
GraphNodeLayout initLayouter;
final double nodeSize = 50.0;
Graph.fromFolder(NotesFolder folder) {
initLayouter = GraphNodeLayout(maxHeight: 2000, maxWidth: 2000);
@ -318,6 +320,13 @@ bool _updateGraphPositions(Graph g) {
}
print('${node.label} $dx $dy');
if (node.x - dx <= g.nodeSize / 2) {
continue;
}
if (node.y - dy <= g.nodeSize / 2) {
continue;
}
node.x += dx;
node.y += dy;