Changeset 11120 for stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/Formatters
- Timestamp:
- 07/07/14 16:55:50 (10 years ago)
- Location:
- stable
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 10496,10499,10520-10523,10531,10561,10564-10565,10799-10800,10862,10885,10953,10956,11065
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/Formatters/SymbolicExpressionTreeLatexFormatter.cs
r10520 r11120 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Globalization; 25 26 using System.Linq; … … 36 37 {"StartSymbol","RPB"} 37 38 }; 38 private readonly ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(); 39 40 private readonly ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> layoutEngine; 39 41 40 42 public SymbolicExpressionTreeLatexFormatter() 41 43 : base("LaTeX/PDF Formatter", "Formatter for symbolic expression trees for use with latex package tikz.") { 42 layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> {44 layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) { 43 45 HorizontalSpacing = 2, 44 46 VerticalSpacing = 2, … … 57 59 58 60 public string Format(ISymbolicExpressionTree symbolicExpressionTree) { 59 layoutEngine.Reset();60 61 var root = symbolicExpressionTree.Root; 61 62 var actualRoot = root.SubtreeCount == 0 ? root.GetSubtree(0) : root; 62 layoutEngine.Initialize(actualRoot, x => x.Subtrees); 63 layoutEngine.CalculateLayout(); 64 var nodeCoordinates = layoutEngine.GetCoordinates(); 63 var nodeCoordinates = layoutEngine.CalculateLayout(actualRoot).ToDictionary(n => n.Content, n => new PointF(n.X, n.Y)); 65 64 var sb = new StringBuilder(); 66 65 var nl = Environment.NewLine;
Note: See TracChangeset
for help on using the changeset viewer.