Changeset 10531
- Timestamp:
- 03/05/14 10:51:38 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs
r10520 r10531 72 72 Y = (int)Math.Round(x.Y) 73 73 }); 74 } 75 76 public IEnumerable<LayoutNode<T>> GetLayoutNodes() { 77 return nodeMap.Values; 74 78 } 75 79 -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r10520 r10531 50 50 this.backgroundColor = Color.White; 51 51 this.textFont = new Font(FontFamily.GenericSansSerif, 12); 52 // layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> { 53 layoutEngine = new BoxesLayoutEngine<ISymbolicExpressionTreeNode> { 52 layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> { 54 53 NodeWidth = preferredNodeWidth, 55 54 NodeHeight = preferredNodeHeight, … … 107 106 tree = value; 108 107 if (tree != null) { 108 //the layout engine needs to be initialized here so that the visualNodes and the visualLines dictionaries are populated 109 InitializeLayout(); 109 110 Repaint(); 110 111 } … … 235 236 236 237 private void SymbolicExpressionTreeChart_MouseMove(object sender, MouseEventArgs e) { 238 237 239 VisualTreeNode<ISymbolicExpressionTreeNode> visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y); 238 240 if (draggedSymbolicExpressionTree != null && … … 260 262 #endregion 261 263 262 #region methods for painting the symbolic expression tree 263 private void DrawFunctionTree(ISymbolicExpressionTree symbExprTree, Graphics graphics, int preferredWidth, int preferredHeight, int minHDistance, int minVDistance) { 264 var root = symbExprTree.Root; 265 var actualRoot = root.SubtreeCount == 1 ? root.GetSubtree(0) : root; 266 layoutEngine.NodeWidth = preferredWidth; 267 layoutEngine.NodeHeight = preferredHeight; 268 layoutEngine.HorizontalSpacing = minHDistance; 269 layoutEngine.VerticalSpacing = minVDistance; 264 private void InitializeLayout() { 265 var actualRoot = tree.Root.SubtreeCount == 1 ? tree.Root.GetSubtree(0) : tree.Root; 270 266 layoutEngine.Initialize(actualRoot, n => n.Subtrees, n => n.GetLength(), n => n.GetDepth()); 271 layoutEngine.CalculateLayout(Width, Height); 272 267 layoutEngine.CalculateLayout(this.Width, this.Height); 273 268 var visualNodes = layoutEngine.GetVisualNodes().ToList(); 269 //populate the visual nodes and visual connections dictionaries 274 270 visualTreeNodes = visualNodes.ToDictionary(x => x.Content, x => x); 275 271 visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualTreeNodeConnection>(); … … 279 275 } 280 276 } 281 // draw nodes and connections 277 } 278 279 #region methods for painting the symbolic expression tree 280 private void DrawFunctionTree(ISymbolicExpressionTree symbExprTree, Graphics graphics, int preferredWidth, int preferredHeight, int minHDistance, int minVDistance) { 281 //we assume here that the layout has already been initialized when the symbolic expression tree was changed 282 //recalculate layout according to new node widths and spacing 283 layoutEngine.NodeWidth = preferredWidth; 284 layoutEngine.NodeHeight = preferredHeight; 285 layoutEngine.HorizontalSpacing = minHDistance; 286 layoutEngine.VerticalSpacing = minVDistance; 287 layoutEngine.CalculateLayout(Width, Height); 288 var visualNodes = visualTreeNodes.Values; 289 //draw nodes and connections 282 290 foreach (var visualNode in visualNodes) { 283 291 DrawTreeNode(visualNode); … … 375 383 VerticalSpacing = minVerticalDistance 376 384 }; 385 InitializeLayout(); 377 386 Repaint(); 378 387 } … … 385 394 VerticalSpacing = minVerticalDistance 386 395 }; 396 InitializeLayout(); 387 397 Repaint(); 388 398 }
Note: See TracChangeset
for help on using the changeset viewer.