GraphTreeLayoutStrategy class base
A layout strategy that arranges nodes in a hierarchical tree structure.
Key features:
- Configurable direction for tree expansion
- Root node selection via rootNodeId or rootNodeSelector
- Customizable sibling ordering with siblingNodeComparator
Example:
// Arrange nodes top-to-bottom with root at the top
final layout = GraphTreeLayoutStrategy(
direction: GraphTreeLayoutDirection.topToBottom,
rootNodeId: rootNode.id,
siblingNodeComparator: (a, b) {
// Order siblings by their labels
return a['label'].compareTo(b['label']);
},
);
return GraphView(
graph: graph,
layoutStrategy: layout,
);
- Inheritance
-
- Object
- GraphLayoutStrategy
- GraphTreeLayoutStrategy
Constructors
-
GraphTreeLayoutStrategy.new({required GraphTreeLayoutDirection direction, int? seed, EdgeInsets padding = const EdgeInsets.all(100), List<
GraphNodeLayoutPosition> nodePositions = const [], GraphId? rootNodeId, GraphTreeLayoutRootNodeSelector? rootNodeSelector, GraphTreeLayoutSiblingNodeComparator? siblingNodeComparator}) - Creates a tree layout strategy with required direction and optional configuration.
Properties
- direction → GraphTreeLayoutDirection
-
ツリーの展開方向
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isHorizontal → bool
-
Whether the layout expands horizontally (left-to-right or right-to-left).
no setter
-
nodePositions
→ List<
GraphNodeLayoutPosition> -
List of predefined node positions.
finalinherited
- padding → EdgeInsets
-
Padding around the layout area.
finalinherited
- random → Random
-
Random number generator initialized with seed.
finalinherited
- rootNodeId → GraphId?
-
ルートノードのID
final
- rootNodeSelector → GraphTreeLayoutRootNodeSelector?
-
Callback for selecting the root node.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seed → int?
-
Optional seed for reproducible random number generation.
finalinherited
- siblingNodeComparator → GraphTreeLayoutSiblingNodeComparator?
-
Callback for determining the order of sibling nodes at each level.
final
Methods
-
baseEquals(
covariant GraphLayoutStrategy oldStrategy) → bool -
Compares basic layout properties for equality.
inherited
-
getNodePosition(
GraphNode node) → GraphNodeLayoutPosition? -
Gets the predefined position for a node, if any exists.
inherited
-
getNodeSize(
GraphNode node) → Size? -
Retrieves the current size of a node.
inherited
-
isNodeFixed(
GraphNode node) → bool -
Checks if a node's position should remain fixed during layout.
inherited
-
isSameStrategy(
GraphLayoutStrategy other) → bool -
Checks if the given strategy is of the same type as this one.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
performLayout(
Graph graph, Size size) → void -
Calculates and applies node positions based on the layout algorithm.
override
-
positionNode(
GraphNode node, Offset position) → void -
Positions a node at the specified coordinates.
inherited
-
shouldRelayout(
covariant GraphTreeLayoutStrategy oldStrategy) → bool -
Determines if the layout needs to be recalculated.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited