Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3929


Ignore:
Timestamp:
06/17/10 17:51:36 (14 years ago)
Author:
abeham
Message:

#1041

  • Added SymbolicExpressionTreeStringFormatter
Location:
trunk/sources
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionView.cs

    r3904 r3929  
    3535  [Content(typeof(SymbolicExpressionTree), false)]
    3636  public partial class SymbolicExpressionView : AsynchronousContentView {
     37    private SymbolicExpressionTreeStringFormatter treeFormatter;
     38
    3739    public new SymbolicExpressionTree Content {
    3840      get { return (SymbolicExpressionTree)base.Content; }
     
    4244    public SymbolicExpressionView() {
    4345      InitializeComponent();
     46      treeFormatter = new SymbolicExpressionTreeStringFormatter();
    4447    }
    4548
     
    4952        textBox.Text = string.Empty;
    5053      else
    51         textBox.Text = SymbolicExpression(Content.Root, 0);
     54        textBox.Text = treeFormatter.Format(Content);
    5255    }
    5356
     
    5760      textBox.ReadOnly = ReadOnly;
    5861    }
    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 line
    68         // and closing ')' also on new line
    69         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     }
    8062  }
    8163}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj

    r3832 r3929  
    108108    <Compile Include="Manipulators\OnePointShaker.cs" />
    109109    <Compile Include="Manipulators\SymbolicExpressionTreeManipulator.cs" />
     110    <Compile Include="SymbolicExpressionTreeStringFormatter.cs" />
    110111    <Compile Include="SymbolicExpressionTreeTopLevelNode.cs" />
    111112    <Compile Include="Crossovers\SubtreeCrossover.cs">
Note: See TracChangeset for help on using the changeset viewer.