public HTDraw(HTModel model, HTView view) { drawToHTNodeMap = new Dictionary <HTNode, HTDrawNode>(); this.view = view; this.model = model; HTModelNode root = model.GetRoot(); sOrigin = new HTCoordS(); sMax = new HTCoordS(); ray = new double[4]; ray[0] = model.GetLength(); for (int i = 1; i < ray.Length; i++) { ray[i] = (ray[0] + ray[i - 1]) / (1 + (ray[0] * ray[i - 1])); } if (root.IsLeaf()) { drawRoot = new HTDrawNode(null, root, this); } else { drawRoot = new HTDrawNodeComposite(null, (HTModelNodeComposite)root, this); } return; }
override public String ToString() { String result = base.ToString(); HTModelNode child = null; result += "\n\tChildren :"; for (IEnumerator i = Children(); i.MoveNext();) { child = (HTModelNode)i.Current; result += "\n\t-> " + child.GetName(); } return(result); }
public HTModel(HTNode root) { if (root.IsLeaf()) { this.root = new HTModelNode(root, this); //Debug.WriteLine("root:" + this.root); } else { this.root = new HTModelNodeComposite(root, this); //Debug.WriteLine("root:" + this.root); } this.root.LayoutHyperbolicTree(); }
private void ComputeWeight() { HTModelNode child = null; for (IEnumerator i = Children(); i.MoveNext();) { child = (HTModelNode)i.Current; globalWeight += child.GetWeight(); } if (globalWeight != 0.0) { weight += Math.Log(globalWeight); } }
public HTDrawNode(HTDrawNodeComposite father, HTModelNode node, HTDraw model) { this.father = father; this.node = node; this.model = model; label = new HTNodeLabel(this); ze = new HTCoordE(node.GetCoordinates()); oldZe = new HTCoordE(ze); zs = new HTCoordS(); model.MapNode(node.GetNode(), this); return; }
internal HTDrawNodeComposite(HTDrawNodeComposite father, HTModelNodeComposite node, HTDraw model) : base(father, node, model) { this.node = node; this.children = new ObservableCollection <HTDrawNode>(); this.geodesics = new Dictionary <HTDrawNode, HTGeodesic>(); HTModelNode childNode = null; HTDrawNode child = null; HTDrawNode brother = null; bool first = true; bool second = false; for (IEnumerator i = node.Children(); i.MoveNext();) { childNode = (HTModelNode)i.Current; if (childNode.IsLeaf()) { child = new HTDrawNode(this, childNode, model); } else { child = new HTDrawNodeComposite(this, (HTModelNodeComposite)childNode, model); } AddChild(child); if (first) { brother = child; first = false; second = true; } else if (second) { child.SetBrother(brother); brother.SetBrother(child); brother = child; second = false; } else { child.SetBrother(brother); brother = child; } } }
override public void Layout(double angle, double width, double length) { base.Layout(angle, width, length); if (parent != null) { HTCoordE a = new HTCoordE(Math.Cos(angle), Math.Sin(angle)); HTCoordE nz = new HTCoordE(-z.X, -z.Y); a.Translate(parent.GetCoordinates()); a.Translate(nz); angle = a.Arg(); double c = Math.Cos(width); double A = 1 + length * length; double B = 2 * length; width = Math.Acos((A * c - B) / (A - B * c)); } HTModelNode child = null; HTCoordE dump = new HTCoordE(); int nbrChild = children.Count; double l1 = (0.95 - model.GetLength()); double l2 = Math.Cos((20.0 * Math.PI) / (2.0 * nbrChild + 38.0)); length = model.GetLength() + (l1 * l2); double startAngle = angle - width; for (IEnumerator i = Children(); i.MoveNext();) { child = (HTModelNode)i.Current; double percent = child.GetWeight() / globalWeight; double childWidth = width * percent; double childAngle = startAngle + childWidth; child.Layout(childAngle, childWidth, length); startAngle += 2.0 * childWidth; } }
public HTModelNodeComposite(HTNode node, HTModelNodeComposite parent, HTModel model) : base(node, parent, model) { this.children = new ObservableCollection<HTModelNode>(); HTNode childNode = null; HTModelNode child = null; for (IEnumerator i = node.Children(); i.MoveNext(); ) { childNode = (HTNode)i.Current; if (childNode.IsLeaf()) { child = new HTModelNode(childNode, this, model); //Debug.WriteLine("HTModelNode:" + child); } else { child = new HTModelNodeComposite(childNode, this, model); //Debug.WriteLine("HTModelNodeComposite:" + child); } AddChild(child); } ComputeWeight(); }
public HTModelNodeComposite(HTNode node, HTModelNodeComposite parent, HTModel model) : base(node, parent, model) { this.children = new ObservableCollection <HTModelNode>(); HTNode childNode = null; HTModelNode child = null; for (IEnumerator i = node.Children(); i.MoveNext();) { childNode = (HTNode)i.Current; if (childNode.IsLeaf()) { child = new HTModelNode(childNode, this, model); //Debug.WriteLine("HTModelNode:" + child); } else { child = new HTModelNodeComposite(childNode, this, model); //Debug.WriteLine("HTModelNodeComposite:" + child); } AddChild(child); } ComputeWeight(); }
private void AddChild(HTModelNode child) { children.Add(child); }