The balloon tree layout tries to compact the drawing area of the tree by placing the vertices in balloons around the tree root. It produces straight line tree drawings.
Following is a brief description of its properties:
To experiment with the layout just change its properties from the property grid and click the Layout button.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.DataStructures;
using Nevron.Nov.Diagram;
using Nevron.Nov.Diagram.Layout;
using Nevron.Nov.Diagram.Shapes;
using Nevron.Nov.Dom;
using Nevron.Nov.Editors;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NBalloonTreeLayoutExample";
// Create the NOV example and its controls
NWidget exampleContent = CreateExampleContent();
NWidget exampleControls = CreateExampleControls();
if (exampleControls != null)
{
exampleControls.PreferredWidth = 300;
}
// Place the example and its controls in a pair box
NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
pairBox.FillMode = ENStackFillMode.First;
pairBox.FitMode = ENStackFitMode.First;
pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);
// Host the example in the form
NNovWidgetHost host = new NNovWidgetHost(pairBox);
host.Dock = DockStyle.Fill;
Controls.Add(host);
}
#endregion
#region Example
public NWidget CreateExampleContent()
{
// Create a simple drawing
NDrawingViewWithRibbon drawingViewWithRibbon = new NDrawingViewWithRibbon();
m_DrawingView = drawingViewWithRibbon.View;
m_DrawingView.Document.HistoryService.Pause();
try
{
InitDiagram(m_DrawingView.Document);
}
finally
{
m_DrawingView.Document.HistoryService.Resume();
}
return drawingViewWithRibbon;
}
public NWidget CreateExampleControls()
{
m_Layout.Changed += OnLayoutChanged;
NStackPanel stack = new NStackPanel();
// property editor
NEditor editor = NDesigner.GetDesigner(m_Layout).CreateStandaloneEditor(m_Layout);
stack.Add(new NGroupBox("Properties", editor));
NButton arrangeButton = new NButton("Arrange Diagram");
arrangeButton.Click += OnArrangeButtonClick;
stack.Add(arrangeButton);
// items stack
NStackPanel itemsStack = new NStackPanel();
// NOTE: For Tree layouts we provide the user with the ability to generate random tree diagrams so that he/she can test the layouts
NButton randomTree1Button = new NButton("Random Tree (max 6 levels, max 3 branch nodes)");
randomTree1Button.Click += OnRandomTree1ButtonClick;
itemsStack.Add(randomTree1Button);
NButton randomTree2Button = new NButton("Random Tree (max 8 levels, max 2 branch nodes)");
randomTree2Button.Click += OnRandomTree2ButtonClick;
itemsStack.Add(randomTree2Button);
stack.Add(new NGroupBox("Items", itemsStack));
return stack;
}
public string GetExampleDescription()
{
return @"
The balloon tree layout tries to compact the drawing area of the tree
by placing the vertices in balloons around the tree root.
It produces straight line tree drawings.
Following is a brief description of its properties:
-
ParentChildSpacing - the preferred spacing between a parent and a child
vertex in the layout direction. The real spacing may be different for some nodes,
because the layout does not allow overlapping.
-
VertexSpacing - the minimal spacing between 2 nodes in the layout.
If set to 0, the nodes may touch each other.
-
ChildWedge - the sector angle (measured in degrees) for the children
of each vertex.
-
RootWedge - the sector angle (measured in degrees) for the children
of the root vertex.
-
StartAngle - the start angle for the children of the root vertex, measured in
degrees anticlockwise from the x-axis.
To experiment with the layout just change its properties from the property grid and click the Layout button.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Balloon Tree Layout", "https://www.nevron.com/docs/openvision/diagram-balloon-tree-layout.html"),
("Layouts Overview", "https://www.nevron.com/docs/openvision/diagram-drawing-layouts-overview.html"),
("Graph Regions and Regions Layouts", "https://www.nevron.com/docs/openvision/diagram-graph-regions-and-region-layouts.html"),
};
}
private void InitDiagram(NDrawingDocument drawingDocument)
{
// Hide ports
drawingDocument.Content.ScreenVisibility.ShowPorts = false;
// Create a template graph
NGenericTreeTemplate tree = new NGenericTreeTemplate();
tree.EdgeUserClass = NDR.StyleSheetNameConnectors;
tree.Levels = 4;
tree.BranchNodes = 4;
tree.HorizontalSpacing = 10;
tree.VerticalSpacing = 10;
tree.ConnectorType = ENConnectorShape.RoutableConnector;
tree.VertexShape = VertexShape;
tree.VertexSize = VertexSize;
tree.Create(drawingDocument);
// Arrange diagram
ArrangeDiagram(drawingDocument);
// Fit active page
drawingDocument.Content.ActivePage.ZoomMode = ENZoomMode.Fit;
}
#endregion
#region Implementation
///
/// Arranges the shapes in the active page.
///
///
private void ArrangeDiagram(NDrawingDocument drawingDocument)
{
// get all top-level shapes that reside in the active page
NPage activePage = drawingDocument.Content.ActivePage;
NList shapes = activePage.GetShapes(false);
// create a layout context and use it to arrange the shapes using the current layout
NDrawingLayoutContext layoutContext = new NDrawingLayoutContext(drawingDocument, activePage);
m_Layout.Arrange(shapes.CastAll