mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 19:36:25 +08:00
Graph Layout: Do not let nodes pos go < 0
Otherwise they fall off the visible area
This commit is contained in:
@ -46,6 +46,8 @@ class Graph extends ChangeNotifier {
|
|||||||
|
|
||||||
GraphNodeLayout initLayouter;
|
GraphNodeLayout initLayouter;
|
||||||
|
|
||||||
|
final double nodeSize = 50.0;
|
||||||
|
|
||||||
Graph.fromFolder(NotesFolder folder) {
|
Graph.fromFolder(NotesFolder folder) {
|
||||||
initLayouter = GraphNodeLayout(maxHeight: 2000, maxWidth: 2000);
|
initLayouter = GraphNodeLayout(maxHeight: 2000, maxWidth: 2000);
|
||||||
|
|
||||||
@ -318,6 +320,13 @@ bool _updateGraphPositions(Graph g) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print('${node.label} $dx $dy');
|
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.x += dx;
|
||||||
node.y += dy;
|
node.y += dy;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user