type TTreeConnectionStyle = ( csAuto, // Automatic based on tree layout csLine, // Direct straight line csHoriz, // Horizontal then vertical csVert, // Vertical then horizontal csSegments, // Multiple segments with connection points csCurve // Bezier curve );
Connections can have arrows at the start, end, or both ends.
1
Enable Arrows
// Arrow at destination (end)Connection.ArrowTo.Visible := True;// Arrow at source (start)Connection.ArrowFrom.Visible := True;
2
Configure Arrow Style
type TConnectionArrowStyle = ( casNone, // No arrow casSolid, // Filled triangle casLines, // Line arrows (>) casSquare, // Square cap casCircle, // Circle cap casDiamond // Diamond cap );Connection.ArrowTo.Style := casSolid;Connection.ArrowFrom.Style := casLines;
// Add text to connectionConnection.Text.Add('Label');Connection.Text.Add('Multi-line');Connection.Text.Add('Supported');// Or simple textConnection.SimpleText := 'Connection Label';// Text formattingConnection.Font.Color := clBlue;Connection.Font.Style := [fsBold];Connection.HorizTextAlign := htaCenter;Connection.VertTextAlign := vtaCenter;// Text visibilityConnection.Text.Visible := True;
// Set style to use pointsConnection.Style := csSegments;// Add connection pointsConnection.Points.Add(150, 100); // X, Y coordinatesConnection.Points.Add(200, 150);Connection.Points.Add(250, 150);
Connection points support various positioning modes:
type TConnectionPointStyle = ( cpsAutoFrom, // Auto position on source node cpsAutoTo, // Auto position on destination node cpsFromPercent, // Percentage of source size cpsToPercent, // Percentage of destination size cpsFromRel, // Relative to source origin cpsToRel, // Relative to destination origin cpsPrevious, // Relative to previous point cpsNext, // Relative to next point cpsFixed // Fixed pixel position );
// Add point with styleConnection.Points.Add(cpsFromPercent, 50, // 50% from source width cpsFromPercent, 100); // 100% from source height// Relative to previous pointConnection.Points.AddFromPrevious(20, 0); // 20 pixels right// Move pointConnection.Points.Move(0, 10, 5); // Move point 0 by delta X,Y// Delete pointConnection.Points.Delete(1); // Remove point at index 1// Clear all pointsConnection.Points.Clear;
var i: Integer;begin // Iterate all connections from a node for i := 0 to MyNode.Connections.Count - 1 do ProcessConnection(MyNode.Connections[i]); // Find connection to specific node Connection := MyNode.Connections.ToShape(TargetNode); if Assigned(Connection) then ShowMessage('Found connection');end;
var i: Integer;begin // All connections in tree for i := 0 to Tree1.Connections.Count - 1 do begin Connection := Tree1.Connections[i]; ShowMessage(Connection.FromShape.SimpleText + ' -> ' + Connection.ToShape.SimpleText); end;end;
// Delete specific connectionConnection.Free;// Delete connection from nodeMyNode.Connections.DeleteConnection(Connection);// Delete all connections to a nodeMyNode.Connections.DeleteAllTo(TargetNode);
// Hide single connectionConnection.Visible := False;// Hide all connections from a nodeMyNode.Connections.Visible := False;// Show all connectionsfor i := 0 to Tree1.Connections.Count - 1 do Tree1.Connections[i].Visible := True;