Changeset 15118
- Timestamp:
- 07/03/17 23:06:13 (7 years ago)
- Location:
- stable
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15029,15040,15044
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views merged: 15029,15040,15044
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.Designer.cs
r14186 r15118 59 59 this.symbolicExpressionTreeChart.Name = "functionTreeChart"; 60 60 this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(407, 367); 61 this.symbolicExpressionTreeChart.Spacing = 5;62 61 this.symbolicExpressionTreeChart.TabIndex = 0; 63 62 this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font(FontFamily.GenericSerif, 8F); -
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs
r11120 r15118 40 40 SecondWalk(layoutRoot, -layoutRoot.Prelim); 41 41 NormalizeCoordinates(layoutNodeMap.Values); 42 if ( height != 0 && width !=0) {42 if (width > 0 && height > 0) { 43 43 FitToBounds(width, height, layoutNodeMap.Values); 44 44 Center(width, height, layoutNodeMap.Values); … … 158 158 if (ymax < y) ymax = y; 159 159 } 160 return new RectangleF(xmin, ymin, xmax + minHorizontalSpacing + NodeWidth, ymax + minVerticalSpacing+ NodeHeight);160 return new RectangleF(xmin, ymin, xmax + NodeWidth, ymax + NodeHeight); 161 161 } 162 162 -
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionGrammarAllowedChildSymbolsControl.Designer.cs
r14186 r15118 70 70 this.symbolicExpressionTreeChart.Name = "allowedChildSymbolsControl"; 71 71 this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(645, 386); 72 this.symbolicExpressionTreeChart.Spacing = 5;73 72 this.symbolicExpressionTreeChart.SuspendRepaint = false; 74 73 this.symbolicExpressionTreeChart.TabIndex = 0; -
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r14186 r15118 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 6Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 37 37 private ILayoutEngine<ISymbolicExpressionTreeNode> layoutEngine; 38 38 39 private const int preferredNodeWidth = 70;40 private const int preferredNodeHeight = 46;41 private int minHorizontalDistance = 30;42 private int minVerticalDistance = 30;43 44 39 public SymbolicExpressionTreeChart() { 45 40 InitializeComponent(); 46 41 this.image = new Bitmap(Width, Height); 47 42 this.stringFormat = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; 48 this.spacing = 5;49 43 this.lineColor = Color.Black; 50 44 this.backgroundColor = Color.White; … … 55 49 56 50 layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) { 57 NodeWidth = preferredNodeWidth,58 NodeHeight = preferredNodeHeight,59 HorizontalSpacing = minHorizontalDistance,60 VerticalSpacing = minVerticalDistance51 NodeWidth = PreferredNodeWidth, 52 NodeHeight = PreferredNodeHeight, 53 HorizontalSpacing = MinimumHorizontalDistance, 54 VerticalSpacing = MinimumVerticalDistance 61 55 }; 62 56 reingoldTilfordToolStripMenuItem.Checked = true; … … 69 63 70 64 #region Public properties 71 private int spacing; 72 public int Spacing { 73 get { return this.spacing; } 74 set { 75 this.spacing = value; 76 this.Repaint(); 65 private int preferredNodeWidth = 70; 66 public int PreferredNodeWidth { 67 get { return preferredNodeWidth; } 68 set { 69 preferredNodeWidth = value; 70 Repaint(); 71 } 72 } 73 74 private int preferredNodeHeight = 46; 75 public int PreferredNodeHeight { 76 get { return preferredNodeHeight; } 77 set { 78 preferredNodeHeight = value; 79 Repaint(); 80 } 81 } 82 83 private int minHorizontalDistance = 30; 84 public int MinimumHorizontalDistance { 85 get { return minHorizontalDistance; } 86 set { 87 minHorizontalDistance = value; 88 Repaint(); 89 } 90 } 91 92 private int minVerticalDistance = 30; 93 public int MinimumVerticalDistance { 94 get { return minVerticalDistance; } 95 set { 96 minVerticalDistance = value; 97 Repaint(); 98 } 99 } 100 101 private int minHorizontalPadding = 20; 102 public int MinimumHorizontalPadding { 103 get { return minHorizontalPadding; } 104 set { 105 minHorizontalPadding = value; 106 Repaint(); 107 } 108 } 109 110 private int minVerticalPadding = 20; 111 public int MinimumVerticalPadding { 112 get { return minVerticalPadding; } 113 set { 114 minVerticalPadding = value; 115 Repaint(); 77 116 } 78 117 } … … 186 225 graphics.Clear(backgroundColor); 187 226 if (tree != null) { 188 DrawFunctionTree(graphics, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance);227 DrawFunctionTree(graphics, PreferredNodeWidth, PreferredNodeHeight, MinimumHorizontalDistance, MinimumVerticalDistance); 189 228 } 190 229 } … … 287 326 actualRoot = tree.Root.GetSubtree(0); 288 327 } 289 290 var visualNodes = layoutEngine.CalculateLayout(actualRoot, Width, Height).ToList(); 328 var visualNodes = layoutEngine.CalculateLayout(actualRoot, Width - MinimumHorizontalPadding, Height - MinimumVerticalPadding).ToList(); 329 // add the padding 330 foreach (var vn in visualNodes) { 331 vn.X += MinimumHorizontalPadding / 2; 332 vn.Y += MinimumVerticalPadding / 2; 333 } 334 291 335 visualTreeNodes = visualNodes.ToDictionary(x => x.Content, x => x); 292 336 visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualTreeNodeConnection>(); … … 321 365 } 322 366 367 private Action<Brush, int, int, int, int> fill; 368 private Action<Pen, int, int, int, int> draw; 323 369 protected void DrawTreeNode(Graphics graphics, VisualTreeNode<ISymbolicExpressionTreeNode> visualTreeNode) { 324 370 graphics.Clip = new Region(new Rectangle(visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width + 1, visualTreeNode.Height + 1)); … … 328 374 using (var nodeLinePen = new Pen(visualTreeNode.LineColor)) 329 375 using (var nodeFillBrush = new SolidBrush(visualTreeNode.FillColor)) { 330 //draw terminal node 331 if (node.SubtreeCount == 0) { 332 graphics.FillRectangle(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height); 333 graphics.DrawRectangle(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height); 376 var x = visualTreeNode.X; 377 var y = visualTreeNode.Y; 378 var w = visualTreeNode.Width - 1; // allow 1px for the drawing of the line 379 var h = visualTreeNode.Height - 1; // allow 1px for the drawing of the line 380 // draw leaf nodes as rectangles and internal nodes as ellipses 381 if (node.SubtreeCount > 0) { 382 fill = graphics.FillEllipse; draw = graphics.DrawEllipse; 334 383 } else { 335 graphics.FillEllipse(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height); 336 graphics.DrawEllipse(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height); 337 } 384 fill = graphics.FillRectangle; draw = graphics.DrawRectangle; 385 } 386 fill(nodeFillBrush, x, y, w, h); 387 draw(nodeLinePen, x, y, w, h); 338 388 //draw name of symbol 339 var text = node.ToString(); 340 graphics.DrawString(text, textFont, textBrush, new RectangleF(visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height), stringFormat); 389 graphics.DrawString(node.ToString(), textFont, textBrush, new RectangleF(x, y, w, h), stringFormat); 341 390 } 342 391 } … … 367 416 Image image = new Bitmap(Width, Height); 368 417 using (Graphics g = Graphics.FromImage(image)) { 369 DrawFunctionTree(g, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance, false);418 DrawFunctionTree(g, PreferredNodeWidth, PreferredNodeHeight, MinimumHorizontalDistance, MinimumVerticalDistance, false); 370 419 } 371 420 image.Save(filename); … … 377 426 using (Metafile file = new Metafile(filename, g.GetHdc())) { 378 427 using (Graphics emfFile = Graphics.FromImage(file)) { 379 DrawFunctionTree(emfFile, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance, false);428 DrawFunctionTree(emfFile, PreferredNodeWidth, PreferredNodeHeight, MinimumHorizontalDistance, MinimumVerticalDistance, false); 380 429 } 381 430 } … … 398 447 399 448 private void reingoldTilfordToolStripMenuItem_Click(object sender, EventArgs e) { 400 minHorizontalDistance = 30;401 minVerticalDistance = 30;402 449 layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) { 403 NodeWidth = preferredNodeWidth,404 NodeHeight = preferredNodeHeight,405 HorizontalSpacing = minHorizontalDistance,406 VerticalSpacing = minVerticalDistance450 NodeWidth = PreferredNodeWidth, 451 NodeHeight = PreferredNodeHeight, 452 HorizontalSpacing = MinimumHorizontalDistance, 453 VerticalSpacing = MinimumVerticalDistance 407 454 }; 408 455 reingoldTilfordToolStripMenuItem.Checked = true; … … 412 459 413 460 private void boxesToolStripMenuItem_Click(object sender, EventArgs e) { 414 minHorizontalDistance = 5;415 minVerticalDistance = 5;416 461 layoutEngine = new BoxesLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees, n => n.GetLength(), n => n.GetDepth()) { 417 NodeWidth = preferredNodeWidth,418 NodeHeight = preferredNodeHeight,419 HorizontalSpacing = minHorizontalDistance,420 VerticalSpacing = minVerticalDistance462 NodeWidth = PreferredNodeWidth, 463 NodeHeight = PreferredNodeHeight, 464 HorizontalSpacing = MinimumHorizontalDistance, 465 VerticalSpacing = MinimumVerticalDistance 421 466 }; 422 467 reingoldTilfordToolStripMenuItem.Checked = false; -
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views merged: 15044
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs
r14186 r15118 187 187 this.treeChart.Name = "treeChart"; 188 188 this.treeChart.Size = new System.Drawing.Size(201, 348); 189 this.treeChart.Spacing = 5;190 189 this.treeChart.SuspendRepaint = false; 191 190 this.treeChart.TabIndex = 0;
Note: See TracChangeset
for help on using the changeset viewer.