Example #1
0
        private IView _view = null; // the view using this drawing model

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="model">The tree model to draw.</param>
        /// <param name="view">The view using this drawing model.</param>
        public Renderer(Model model, IView view)
        {
            // initialize mapping
            _nodeViewMap = new Dictionary<INode, NodeView>();

            _view = view;
            _model = model;

            _screenPlaneOrigin = new ScreenVector();
            _screenPlaneMaxPoint = new ScreenVector();

            _ray = new double[4];
            _ray[0] = model.Length;

            for (int i = 1; i < _ray.Length; i++)
            {
                _ray[i] = (_ray[0] + _ray[i - 1]) / (1 + (_ray[0] * _ray[i - 1]));
            }

            NodeModel __rootNodeModel = model.Root;
            if (__rootNodeModel.IsLeaf)
            {
                _rootNodeView = new NodeView(null, __rootNodeModel, this);
            }
            else
            {
                _rootNodeView = new CompositeNodeView(null, (CompositeNodeModel)__rootNodeModel, this);
            }

            this.Background = new LinearGradientBrush(Colors.Black, Colors.DarkBlue, 90);

            CompositionTarget.Rendering += UpdatePosition;
        }
Example #2
0
        private NodeView _node = null; // represented node

        #endregion Fields

        #region Constructors

        /// <summary> Constructor.
        /// </summary>
        /// <param name="node">The represented node.</param>
        public NodeLabel(NodeView node)
        {
            _node = node;
            this.Content = _node.NodeName;
            this.HorizontalAlignment = HorizontalAlignment.Center;
            this.VerticalAlignment = VerticalAlignment.Center;
            this.FontFamily = new FontFamily("Arial");
            this.FontSize = 11;
            this.Padding = new Thickness(1);
        }
Example #3
0
 /// <summary> Translate the hyperbolic tree
 /// so that the given node  is put at the origin of the hyperbolic tree.
 /// </summary>
 /// <param name="node">The given <see cref="HtDrawNode"/></param>
 public void TranslateToOrigin(NodeView node)
 {
     _view.StopMouseListening();
     _velocity     = new EuclidianVector(node.Coordinates);
     _animatedNode = node;
 }
 /// <summary> Adds the <see cref="NodeView"/> as a children.
 /// </summary>
 /// <param name="child">The child.</param>
 private void AddChild(NodeView child)
 {
     _childNodes.Add(child);
     _geodesics.Add(child, new Geodesic(Coordinates, child.Coordinates));
 }
Example #5
0
 private void UpdatePosition(object sender, EventArgs e)
 {
     if (_animatedNode != null)
     {
         _velocity.X *= 0.90;
         _velocity.Y *= 0.90;
         if (_velocity.D() > 0.01)
             this.Translate(_animatedNode.OldCoordinates, _velocity);
         else
         {
             _animatedNode = null;
             this.EndTranslation();
             _view.StartMouseListening();
         }
     }
 }
Example #6
0
 /// <summary> Translate the hyperbolic tree 
 /// so that the given node  is put at the origin of the hyperbolic tree.        
 /// </summary>
 /// <param name="node">The given <see cref="HtDrawNode"/></param>
 public void TranslateToOrigin(NodeView node)
 {
     _view.StopMouseListening();
     _velocity = new EuclidianVector(node.Coordinates);
     _animatedNode = node;
 }
Example #7
0
 /// <summary> Maps a <see cref="IHtNode"/> to a <see cref="HtDrawNode"/>.
 /// Used for backwards finding a <see cref="HtDrawNode"/> instance for a given
 /// <see cref="IHtNode"/>.
 /// </summary>
 /// <param name="htNode">The <see cref="IHtNode"/></param>
 /// <param name="drawNode">the <see cref="HtDrawNode"/> for the given <see cref="IHtNode"/></param>
 public void MapNode(INode htNode, NodeView drawNode)
 {
     _nodeViewMap.Add(htNode, drawNode);
 }