GroupAnnotation class
A group annotation that automatically surrounds and contains a set of nodes.
Group annotations create visual boundaries around related nodes, making it easier to organize complex workflows. They feature:
- Automatic sizing based on contained nodes
- Customizable title and color
- Automatic position updates when nodes move
- Support for moving all contained nodes together
- Typically rendered behind nodes (negative z-index)
Groups maintain node dependencies and automatically recalculate their bounds when dependent nodes are moved, resized, or added/removed.
Example
final group = controller.annotations.createGroupAnnotation(
id: 'group-1',
title: 'Data Processing',
nodeIds: {'node1', 'node2', 'node3'},
nodes: controller.nodes,
color: Colors.blue,
padding: EdgeInsets.all(20),
);
controller.annotations.addAnnotation(group);
- Inheritance
-
- Object
- Annotation
- GroupAnnotation
Constructors
-
GroupAnnotation({required String id, required Offset position, required String title, EdgeInsets padding = const EdgeInsets.all(20), Color color = Colors.blue, int zIndex = -1, bool isVisible = true, bool selected = false, bool isInteractive = true, required Set<
String> dependencies, Offset offset = Offset.zero, Map<String, dynamic> metadata = const {}}) -
GroupAnnotation.fromJsonMap(Map<
String, dynamic> json) -
Creates a GroupAnnotation from a JSON map.
factory
Properties
- bounds → Rect
-
Automatically calculated bounding rectangle for hit testing.
no setterinherited
- currentColor → Color
-
The current color value (non-reactive).
no setter
- currentIsVisible → bool
-
The current visibility state (non-reactive).
no setterinherited
- currentPosition → Offset
-
The current logical position value (non-reactive).
no setterinherited
- currentSelected → bool
-
The current selection state (non-reactive).
no setterinherited
- currentTitle → String
-
The current title value (non-reactive).
no setter
- currentVisualPosition → Offset
-
The current visual (snapped) position value (non-reactive).
no setterinherited
- currentZIndex → int
-
The current z-index value (non-reactive).
no setterinherited
-
dependencies
→ ObservableSet<
String> -
Reactive observable set of node IDs this annotation depends on.
no setterinherited
- hasAnyDependencies → bool
-
Whether this annotation has any node dependencies.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
Unique identifier for this annotation.
finalinherited
- isInteractive → bool
-
Whether this annotation responds to user interactions.
finalinherited
-
isVisible
→ Observable<
bool> -
Reactive observable for the annotation's visibility state.
no setterinherited
-
metadata
→ Map<
String, dynamic> -
Additional metadata for custom data storage.
finalinherited
-
observableColor
→ Observable<
Color> -
Reactive observable for the group's color.
no setter
-
observableTitle
→ Observable<
String> -
Reactive observable for the group's title.
no setter
- offset → Offset
-
Offset from dependent node position (for following annotations).
finalinherited
- padding → EdgeInsets
-
The padding around contained nodes.
final
-
position
→ Observable<
Offset> -
Reactive observable for the annotation's logical position.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
selected
→ Observable<
bool> -
Reactive observable for the annotation's selection state.
no setterinherited
- size → Size
-
The dimensions of the annotation for automatic hit testing.
no setteroverride
- type → String
-
The type of annotation (e.g., 'sticky', 'group', 'marker').
finalinherited
-
visualPosition
→ Observable<
Offset> -
Reactive observable for the annotation's visual position.
no setterinherited
-
zIndex
→ Observable<
int> -
Reactive observable for the annotation's z-index (rendering order).
no setterinherited
Methods
-
addDependency(
String nodeId) → void -
Adds a node dependency to this annotation.
inherited
-
buildWidget(
BuildContext context) → Widget -
Builds the visual representation of the annotation.
override
-
clearDependencies(
) → void -
Clears all node dependencies from this annotation.
inherited
-
containsPoint(
Offset point) → bool -
Automatic hit testing based on position and size.
inherited
-
copyWith(
{String? id, String? title, EdgeInsets? padding, Color? color, int? zIndex, bool? isVisible, bool? isInteractive, Set< String> ? dependencies, Map<String, dynamic> ? metadata}) → GroupAnnotation - Creates a copy of this group annotation with optional property overrides.
-
fromJson(
Map< String, dynamic> json) → void -
Deserializes JSON data into this annotation.
override
-
hasDependency(
String nodeId) → bool -
Checks if this annotation depends on a specific node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeDependency(
String nodeId) → void -
Removes a node dependency from this annotation.
inherited
-
setPosition(
Offset newPosition) → void -
Sets the annotation's logical position.
inherited
-
setSelected(
bool selected) → void -
Sets the annotation's selection state.
inherited
-
setVisible(
bool visible) → void -
Sets the annotation's visibility state.
inherited
-
setVisualPosition(
Offset snappedPosition) → void -
Updates the visual position (used for rendering with grid snapping).
inherited
-
setZIndex(
int newZIndex) → void -
Sets the annotation's z-index (rendering order).
inherited
-
toJson(
) → Map< String, dynamic> -
Serializes this annotation to JSON.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
updateCalculatedSize(
Size newSize) → void - Updates the group's calculated size.
-
updateColor(
Color newColor) → void - Updates the group's color.
-
updateTitle(
String newTitle) → void - Updates the group's title.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited