Changeset 9993
- Timestamp:
- 09/19/13 14:24:47 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.ReingoldTilfordTreeLayout/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r9970 r9993 277 277 layoutEngine.CalculateLayout(); 278 278 var bounds = layoutEngine.Bounds(); 279 double sx = this.Width / bounds.Width;279 double sx = this.Width / (bounds.Width + preferredWidth); 280 280 if (sx > 1) sx = 1; 281 double sy = this.Height / bounds.Height;281 double sy = this.Height / (bounds.Height + preferredHeight); 282 282 if (sy > 1) sy = 1; 283 double dx = (this.Width - bounds.Width ) / 2;283 double dx = (this.Width - bounds.Width + preferredWidth) / 2; 284 284 if (dx < 0) dx = 0; 285 double dy = (this.Height - bounds.Height ) / 2;285 double dy = (this.Height - bounds.Height + preferredHeight) / 2; 286 286 if (dy < 0) dy = 0; 287 var levels = layoutEngine.Nodes.GroupBy(n => n.Value.Level, n => n.Value); 287 288 var levels = layoutNodes.GroupBy(n => n.Level, n => n); 288 289 289 290 foreach (var level in levels) { 290 double width = (level.Max(n => n.X) - level.Min(n => n.X) + preferredWidth); 291 double ssx = this.Width / width; 292 if (ssx > 1) ssx = 1; 291 var nodes = level.ToList(); 292 double min = 0; 293 for (int i = 0; i < nodes.Count - 1; ++i) { 294 var w = (nodes[i + 1].X - nodes[i].X) * sx - preferredWidth; 295 if (w < min) min = w; 296 } 297 if (min > 0) min = 0; 298 293 299 foreach (var layoutNode in level) { 294 var node = layoutNode.Content; 295 var visualNode = visualTreeNodes[node]; 296 visualNode.Width = (int)Math.Round(preferredWidth * ssx); 300 var visualNode = visualTreeNodes[layoutNode.Content]; 301 visualNode.Width = (int)Math.Round(preferredWidth + min) - 2; // -2 to allow enough padding (1px on each side) for the node contour to be drawn 297 302 visualNode.Height = (int)Math.Round(preferredHeight * sy); 298 303 visualNode.X = (int)(Math.Round(layoutNode.X * sx + dx)); … … 301 306 } 302 307 } 308 303 309 graphics.ResetClip(); // reset clip region 310 // draw node connections 304 311 foreach (var visualNode in visualTreeNodes.Values) { 305 312 var node = visualNode.SymbolicExpressionTreeNode;
Note: See TracChangeset
for help on using the changeset viewer.