コード例 #1
0
ファイル: Model.cs プロジェクト: BackupTheBerlios/sofia-svn
        private NodeModel _root = null; // the root of the tree's model

        #endregion Fields

        #region Constructors

        /// <summary> Constructor.
        /// </summary>
        /// <param name="root">The root of the real tree.</param>
        public Model(INode root)
        {
            if (root.IsLeaf)
              {
            _root = new NodeModel(root, this);
              }
              else
              {
            _root = new CompositeNodeModel(root, this);
              }
              _root.LayoutHyperbolicTree();
        }
コード例 #2
0
        private EuclidianVector _ze = null; // current euclidian coordinates

        #endregion Fields

        #region Constructors

        /// <summary> Constructor.
        /// </summary>
        /// <param name="parentNode">The father of this node.</param>
        /// <param name="nodeModel">The encapsulated <see cref="NodeModel"/>.</param>
        /// <param name="renderer">The drawing model.</param>
        public NodeView(CompositeNodeView parentNode, NodeModel nodeModel, Renderer renderer)
        {
            _parentNode = parentNode;
            _nodeModel = nodeModel;
            _renderer = renderer;

            this.Opacity = 0.9;
            this.Child = new NodeLabel(this);

            _ze = new EuclidianVector(nodeModel.OriginalCoordinates);
            _oldZe = new EuclidianVector(_ze);
            _screenCoordinates = new ScreenVector();

            // store this object in INode -> NodeView mapping
            renderer.MapNode(nodeModel.Node, this);

            renderer.Children.Add(this);
        }
コード例 #3
0
        /// <summary>Connstructor.
        /// </summary>
        /// <param name="node">The encapsulated INode.</param>
        /// <param name="parent">The parent node.</param>
        /// <param name="model">The tree model using this NodeModel.</param>
        public CompositeNodeModel(INode node, CompositeNodeModel parent, Model model)
            : base(node, parent, model)
        {
            _children = new List<NodeModel>();

            NodeModel __child = null;
            foreach (INode childNode in node.ChildNodes)
            {
                if (childNode.IsLeaf)
                {
                    __child = new NodeModel(childNode, this, model);
                }
                else
                {
                    __child = new CompositeNodeModel(childNode, this, model);
                }
                this.AddChild(__child);
            }

            // here the down of the tree is built, so we can compute the weight
            this.ComputeWeight();
        }
コード例 #4
0
 /// <summary> Adds the <see cref="NodeModel"/> as a children.
 /// </summary>
 /// <param name="child">The child.</param>  
 private void AddChild(NodeModel child)
 {
     _children.Add(child);
 }