Click or drag to resize

TreeDrawing Class

An immutable high-level representation of a drawing of a tree.
Inheritance Hierarchy
SystemObject
  KansasStateUniversity.TreeViewer2TreeDrawing

Namespace:  KansasStateUniversity.TreeViewer2
Assembly:  KansasStateUniversity.TreeViewer2 (in KansasStateUniversity.TreeViewer2.dll) Version: 2.0.0.0 (2.0.0.0)
Syntax
public sealed class TreeDrawing

The TreeDrawing type exposes the following members.

Constructors
  NameDescription
Public methodTreeDrawing
Constructs a drawing of an empty tree.
Public methodTreeDrawing(ITree, Int32)
Constructs a drawing of the given tree. T
Public methodTreeDrawing(ITree, Int32, IColorizer)
Constructs a colorized drawing of the given tree.
Top
Properties
  NameDescription
Public propertyChildrenWidth
Gets the total width of the children in characters.
Public propertyHeight
Gets the height of this tree in text lines.
Public propertyRoot
Gets the root of the tree.
Public propertyRootColor
Gets the color of the root.
Public propertyRootWidth
Gets the width of the root in characters.
Public propertyWidth
Gets the width of this tree in characters.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetDrawing
Returns a TreePanel displaying this drawing using TreePanel.DefaultFont.
Public methodGetDrawing(Font)
Returns a TreePanel displaying this drawing using the given Font.
Public methodGetEnumerator
Returns an IEnumerator giving the children, in order.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Fields
  NameDescription
Public fieldStatic memberHorizontalSeparation
The width in characters of the horizontal separation between two nodes.
Public fieldStatic memberVerticalSeparation
The height in lines of text of the vertical separation between parents and children.
Top
Remarks

This tree representation contains a font-independent description of the size of the drawing along with all the information necessary to draw the tree on a given graphics context using a given font.

A TreeDrawing can be constructed from an implementation of ITree and optionally an implementation of IColorizer. No attempt is made to detect cycles or overlapping subtrees; instead, a parameter to the constructor specifies the maximum height of the tree drawn.

A TreePanel containing a graphical representation can be efficiently obtained from either the GetDrawing() or the GetDrawing(Font) method. These methods return a new TreePanel each time they are called, so they can be used in multiple containers. These components will all share the same TreeDrawing.

Empty trees are not drawn, but if a node contains both empty and nonempty children, the horizontal padding that would surround a node is included for empty children. Consequently, in a binary tree, the line drawn from a node to its left child always angles to the left, and the line drawn from a node to its right child always angles to the right, even when the other child is empty. On the other hand, it may be more difficult to tell which children may be empty in trees with other branching factors.

The children, each of which is a TreeDrawing, can be obtained using the GetEnumerator() method. This method returns a System.Collections.IEnumerator of the children. This method allows a C# foreach construct to iterate through the children.

See Also