Changeset 3929
- Timestamp:
- 06/17/10 17:51:36 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionView.cs
r3904 r3929 35 35 [Content(typeof(SymbolicExpressionTree), false)] 36 36 public partial class SymbolicExpressionView : AsynchronousContentView { 37 private SymbolicExpressionTreeStringFormatter treeFormatter; 38 37 39 public new SymbolicExpressionTree Content { 38 40 get { return (SymbolicExpressionTree)base.Content; } … … 42 44 public SymbolicExpressionView() { 43 45 InitializeComponent(); 46 treeFormatter = new SymbolicExpressionTreeStringFormatter(); 44 47 } 45 48 … … 49 52 textBox.Text = string.Empty; 50 53 else 51 textBox.Text = SymbolicExpression(Content.Root, 0);54 textBox.Text = treeFormatter.Format(Content); 52 55 } 53 56 … … 57 60 textBox.ReadOnly = ReadOnly; 58 61 } 59 60 private static string SymbolicExpression(SymbolicExpressionTreeNode node, int indentLength) {61 StringBuilder strBuilder = new StringBuilder();62 strBuilder.Append(' ', indentLength); strBuilder.Append("(");63 // internal nodes or leaf nodes?64 if (node.SubTrees.Count > 0) {65 // symbol on same line as '('66 strBuilder.AppendLine(node.ToString());67 // each subtree expression on a new line68 // and closing ')' also on new line69 foreach (var subtree in node.SubTrees) {70 strBuilder.AppendLine(SymbolicExpression(subtree, indentLength + 2));71 }72 strBuilder.Append(' ', indentLength); strBuilder.Append(")");73 } else {74 // symbol in the same line with as '(' and ')'75 strBuilder.Append(node.ToString());76 strBuilder.Append(")");77 }78 return strBuilder.ToString();79 }80 62 } 81 63 } -
trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj
r3832 r3929 108 108 <Compile Include="Manipulators\OnePointShaker.cs" /> 109 109 <Compile Include="Manipulators\SymbolicExpressionTreeManipulator.cs" /> 110 <Compile Include="SymbolicExpressionTreeStringFormatter.cs" /> 110 111 <Compile Include="SymbolicExpressionTreeTopLevelNode.cs" /> 111 112 <Compile Include="Crossovers\SubtreeCrossover.cs">
Note: See TracChangeset
for help on using the changeset viewer.