Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5416


Ignore:
Timestamp:
02/03/11 17:16:31 (14 years ago)
Author:
gkronber
Message:

Merged changes to symbolic expression encoding related to refactoring text-based export formats for symbolic expression trees. #1152 #1270 #1314

Location:
trunk/sources
Files:
1 added
1 deleted
4 edited
2 copied

Legend:

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

    r3742 r5416  
    4646    private void InitializeComponent() {
    4747      this.textBox = new System.Windows.Forms.TextBox();
     48      this.formattersComboBox = new System.Windows.Forms.ComboBox();
     49      this.formatterLabel = new System.Windows.Forms.Label();
    4850      this.SuspendLayout();
    4951      //
    5052      // textBox
    5153      //
    52       this.textBox.Dock = System.Windows.Forms.DockStyle.Fill;
    53       this.textBox.Location = new System.Drawing.Point(0, 0);
     54      this.textBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     55                  | System.Windows.Forms.AnchorStyles.Left)
     56                  | System.Windows.Forms.AnchorStyles.Right)));
     57      this.textBox.BackColor = System.Drawing.Color.White;
     58      this.textBox.Location = new System.Drawing.Point(3, 30);
    5459      this.textBox.Multiline = true;
    5560      this.textBox.Name = "textBox";
    56       this.textBox.Size = new System.Drawing.Size(150, 150);
     61      this.textBox.ReadOnly = true;
     62      this.textBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
     63      this.textBox.Size = new System.Drawing.Size(475, 282);
    5764      this.textBox.TabIndex = 0;
    5865      //
    59       // SymbolicExpressionTreeView
     66      // formattersComboBox
     67      //
     68      this.formattersComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     69                  | System.Windows.Forms.AnchorStyles.Right)));
     70      this.formattersComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     71      this.formattersComboBox.FormattingEnabled = true;
     72      this.formattersComboBox.Location = new System.Drawing.Point(72, 3);
     73      this.formattersComboBox.Name = "formattersComboBox";
     74      this.formattersComboBox.Size = new System.Drawing.Size(406, 21);
     75      this.formattersComboBox.TabIndex = 1;
     76      this.formattersComboBox.SelectedIndexChanged += new System.EventHandler(this.formattersComboBox_SelectedIndexChanged);
     77      //
     78      // formatterLabel
     79      //
     80      this.formatterLabel.AutoSize = true;
     81      this.formatterLabel.Location = new System.Drawing.Point(3, 6);
     82      this.formatterLabel.Name = "formatterLabel";
     83      this.formatterLabel.Size = new System.Drawing.Size(54, 13);
     84      this.formatterLabel.TabIndex = 2;
     85      this.formatterLabel.Text = "Formatter:";
     86      //
     87      // SymbolicExpressionView
    6088      //
    6189      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    6290      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     91      this.Controls.Add(this.formatterLabel);
     92      this.Controls.Add(this.formattersComboBox);
    6393      this.Controls.Add(this.textBox);
    64       this.Name = "SymbolicExpressionTreeView";
     94      this.Name = "SymbolicExpressionView";
     95      this.Size = new System.Drawing.Size(481, 315);
    6596      this.ResumeLayout(false);
    6697      this.PerformLayout();
     
    71102
    72103    private System.Windows.Forms.TextBox textBox;
     104    private System.Windows.Forms.ComboBox formattersComboBox;
     105    private System.Windows.Forms.Label formatterLabel;
    73106  }
    74107}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.3/SymbolicExpressionView.cs

    r4068 r5416  
    2323using HeuristicLab.MainForm;
    2424using HeuristicLab.MainForm.WindowsForms;
     25using HeuristicLab.PluginInfrastructure;
     26using System.Collections.Generic;
     27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Formatters;
    2528
    2629namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
     
    2831  [Content(typeof(SymbolicExpressionTree), false)]
    2932  public partial class SymbolicExpressionView : AsynchronousContentView {
    30     private SymbolicExpressionTreeStringFormatter treeFormatter;
     33
     34    List<ISymbolicExpressionTreeStringFormatter> treeFormattersList = new List<ISymbolicExpressionTreeStringFormatter>();
    3135
    3236    public new SymbolicExpressionTree Content {
     
    3741    public SymbolicExpressionView() {
    3842      InitializeComponent();
    39       treeFormatter = new SymbolicExpressionTreeStringFormatter();
     43      IEnumerable<ISymbolicExpressionTreeStringFormatter> formatters = ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeStringFormatter>();
     44      treeFormattersList = new List<ISymbolicExpressionTreeStringFormatter>();
     45      int selectedIndex = -1;
     46      foreach (ISymbolicExpressionTreeStringFormatter formatter in formatters) {
     47        if (formatter is SymbolicExpressionTreeStringFormatter)
     48          selectedIndex = treeFormattersList.Count;
     49        treeFormattersList.Add(formatter);
     50        formattersComboBox.Items.Add(formatter.Name);
     51      }
     52      formattersComboBox.SelectedIndex = selectedIndex;
    4053    }
    4154
    4255    protected override void OnContentChanged() {
    4356      base.OnContentChanged();
    44       if (Content == null)
     57      UpdateTextbox();
     58    }
     59
     60    private void UpdateTextbox() {
     61      if (Content == null || formattersComboBox.SelectedIndex < 0)
    4562        textBox.Text = string.Empty;
    4663      else
    47         textBox.Text = treeFormatter.Format(Content);
     64        textBox.Text = treeFormattersList[formattersComboBox.SelectedIndex].Format(Content);
    4865    }
    4966
     
    5370      textBox.ReadOnly = ReadOnly;
    5471    }
     72
     73    private void formattersComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
     74      UpdateTextbox();
     75    }
    5576  }
    5677}
  • trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.3/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.3.csproj

    r5386 r5416  
    126126    <Compile Include="Crossovers\CrossoverPoint.cs" />
    127127    <Compile Include="Crossovers\SymbolicExpressionTreeCrossover.cs" />
     128    <Compile Include="Formatters\SymbolicExpressionTreeStringFormatter.cs" />
    128129    <Compile Include="Interfaces\ISymbolicExpressionTreeAnalyzer.cs" />
    129130    <Compile Include="Interfaces\ISymbolicExpressionTreeArchitectureManipulator.cs" />
     
    131132    <Compile Include="Interfaces\ISymbolicExpressionTreeCrossover.cs" />
    132133    <Compile Include="Interfaces\ISymbolicExpressionTreeNode.cs" />
     134    <Compile Include="Interfaces\ISymbolicExpressionTreeStringFormatter.cs" />
    133135    <Compile Include="Manipulators\ChangeNodeTypeManipulation.cs" />
    134136    <Compile Include="Interfaces\ISymbolicExpressionTreeManipulator.cs" />
     
    139141    <Compile Include="Manipulators\SymbolicExpressionTreeManipulator.cs" />
    140142    <Compile Include="SymbolicExpressionTreeGrammar.cs" />
    141     <Compile Include="SymbolicExpressionTreeStringFormatter.cs" />
    142143    <Compile Include="SymbolicExpressionTreeTopLevelNode.cs" />
    143144    <Compile Include="Crossovers\SubtreeCrossover.cs">
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation.GP/3.3/SymbolicExpressionTreeStringConverter.cs

    r4916 r5416  
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Formatters;
    2728
    2829namespace HeuristicLab.Problems.ExternalEvaluation.GP {
Note: See TracChangeset for help on using the changeset viewer.