Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5513


Ignore:
Timestamp:
02/18/11 10:55:20 (13 years ago)
Author:
mkommend
Message:

#1418: Adapted views to new symbolic expression tree encoding.

Location:
branches/DataAnalysis Refactoring
Files:
7 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.cs

    r5473 r5513  
    2727namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    2828  [View("Graphical SymbolicExpressionTree View")]
    29   [Content(typeof(SymbolicExpressionTree), true)]
     29  [Content(typeof(ISymbolicExpressionTree), true)]
    3030  public partial class GraphicalSymbolicExpressionTreeView : ItemView {
    31     public new SymbolicExpressionTree Content {
    32       get { return (SymbolicExpressionTree)base.Content; }
     31    public new ISymbolicExpressionTree Content {
     32      get { return (ISymbolicExpressionTree)base.Content; }
    3333      set { base.Content = value; }
    3434    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.csproj

    r5477 r5513  
    109109  </ItemGroup>
    110110  <ItemGroup>
    111     <Compile Include="DefaultSymbolicExpressionGrammarView.cs">
    112       <SubType>UserControl</SubType>
    113     </Compile>
    114     <Compile Include="DefaultSymbolicExpressionGrammarView.Designer.cs">
    115       <DependentUpon>DefaultSymbolicExpressionGrammarView.cs</DependentUpon>
     111    <Compile Include="SymbolicExpressionTreeGrammarView.cs">
     112      <SubType>UserControl</SubType>
     113    </Compile>
     114    <Compile Include="SymbolicExpressionTreeGrammarView.Designer.cs">
     115      <DependentUpon>SymbolicExpressionTreeGrammarView.cs</DependentUpon>
    116116    </Compile>
    117117    <Compile Include="SymbolView.cs">
     
    161161    </ProjectReference>
    162162    <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
    163       <Project>{125D3006-67F5-48CB-913E-73C0548F17FA}</Project>
     163      <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project>
    164164      <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name>
    165165    </ProjectReference>
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolView.cs

    r5473 r5513  
    2323using System.Windows.Forms;
    2424using HeuristicLab.Core.Views;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2625using HeuristicLab.MainForm;
    2726using HeuristicLab.MainForm.WindowsForms;
     
    2928namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    3029  [View("Symbol View")]
    31   [Content(typeof(Symbol), false)]
     30  [Content(typeof(ISymbol), false)]
    3231  public partial class SymbolView : NamedItemView {
    33     public new Symbol Content {
    34       get { return (Symbol)base.Content; }
     32    public new ISymbol Content {
     33      get { return (ISymbol)base.Content; }
    3534      set { base.Content = value; }
    3635    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r5473 r5513  
    2424using System.Drawing;
    2525using System.Drawing.Imaging;
     26using System.Linq;
    2627using System.Windows.Forms;
    2728
     
    3031    private Image image;
    3132    private StringFormat stringFormat;
    32     private Dictionary<SymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes;
     33    private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes;
    3334
    3435    public SymbolicExpressionTreeChart() {
     
    4445    }
    4546
    46     public SymbolicExpressionTreeChart(SymbolicExpressionTree tree)
     47    public SymbolicExpressionTreeChart(ISymbolicExpressionTree tree)
    4748      : this() {
    4849      this.Tree = tree;
     
    8586    }
    8687
    87     private SymbolicExpressionTree tree;
    88     public SymbolicExpressionTree Tree {
     88    private ISymbolicExpressionTree tree;
     89    public ISymbolicExpressionTree Tree {
    8990      get { return this.tree; }
    9091      set {
    9192        tree = value;
    92         visualTreeNodes = new Dictionary<SymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode>();
     93        visualTreeNodes = new Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode>();
    9394        if (tree != null) {
    9495          foreach (SymbolicExpressionTreeNode node in tree.IterateNodesPrefix())
     
    129130    }
    130131
    131     public VisualSymbolicExpressionTreeNode GetVisualSymbolicExpressionTreeNode(SymbolicExpressionTreeNode symbolicExpressionTreeNode) {
     132    public VisualSymbolicExpressionTreeNode GetVisualSymbolicExpressionTreeNode(ISymbolicExpressionTreeNode symbolicExpressionTreeNode) {
    132133      if (visualTreeNodes.ContainsKey(symbolicExpressionTreeNode))
    133134        return visualTreeNodes[symbolicExpressionTreeNode];
     
    207208
    208209    #region methods for painting the symbolic expression tree
    209     private void DrawFunctionTree(SymbolicExpressionTree tree, Graphics graphics, int x, int y, int width, int height) {
     210    private void DrawFunctionTree(ISymbolicExpressionTree tree, Graphics graphics, int x, int y, int width, int height) {
    210211      DrawFunctionTree(tree.Root, graphics, x, y, width, height, Point.Empty);
    211212    }
     
    220221    /// <param name="width">width of drawing area</param>
    221222    /// <param name="height">height of drawing area</param>
    222     private void DrawFunctionTree(SymbolicExpressionTreeNode node, Graphics graphics, int x, int y, int width, int height, Point connectionPoint) {
     223    private void DrawFunctionTree(ISymbolicExpressionTreeNode node, Graphics graphics, int x, int y, int width, int height, Point connectionPoint) {
    223224      VisualSymbolicExpressionTreeNode visualTreeNode = visualTreeNodes[node];
    224225      float center_x = x + width / 2;
     
    262263
    263264      //draw terminal node
    264       if (node.SubTrees.Count == 0) {
     265      if (node.SubTrees.Count() == 0) {
    265266        graphics.FillRectangle(nodeFillBrush, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
    266267        graphics.DrawRectangle(nodeLinePen, visualTreeNode.X, visualTreeNode.Y, visualTreeNode.Width, visualTreeNode.Height);
     
    280281      //calculate areas for the subtrees according to their tree size and call drawFunctionTree
    281282      Point connectFrom = new Point(visualTreeNode.X + visualTreeNode.Width / 2, visualTreeNode.Y + visualTreeNode.Height);
    282       int[] xBoundaries = new int[node.SubTrees.Count + 1];
     283      int[] xBoundaries = new int[node.SubTrees.Count() + 1];
    283284      xBoundaries[0] = x;
    284       for (int i = 0; i < node.SubTrees.Count; i++) {
    285         xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.SubTrees[i].GetSize()) / (node.GetSize() - 1));
    286         DrawFunctionTree(node.SubTrees[i], graphics, xBoundaries[i], y + height,
     285      for (int i = 0; i < node.SubTrees.Count(); i++) {
     286        xBoundaries[i + 1] = (int)(xBoundaries[i] + (width * (double)node.SubTrees.ElementAt(i).GetSize()) / (node.GetSize() - 1));
     287        DrawFunctionTree(node.SubTrees.ElementAt(i), graphics, xBoundaries[i], y + height,
    287288          xBoundaries[i + 1] - xBoundaries[i], height, connectFrom);
    288289      }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeGrammarView.Designer.cs

    r5512 r5513  
    2121
    2222namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    23   partial class DefaultSymbolicExpressionGrammarView {
     23  partial class SymbolicExpressionTreeGrammarView {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.checkedItemListView = new HeuristicLab.Core.Views.CheckedItemListView<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols.Symbol>();
     47      this.checkedItemListView = new HeuristicLab.Core.Views.CheckedItemListView<ISymbol>();
    4848      this.SuspendLayout();
    4949      this.checkedItemListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     
    6868    #endregion
    6969
    70     protected HeuristicLab.Core.Views.CheckedItemListView<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols.Symbol> checkedItemListView;
     70    protected HeuristicLab.Core.Views.CheckedItemListView<ISymbol> checkedItemListView;
    7171  }
    7272}
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeGrammarView.cs

    r5512 r5513  
    2222using System;
    2323using System.Windows.Forms;
     24using HeuristicLab.Collections;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Core.Views;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.MainForm.WindowsForms;
     
    3030namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    3131  [View("Symbolic Expression Grammar View")]
    32   [Content(typeof(DefaultSymbolicExpressionGrammar), true)]
    33   public partial class DefaultSymbolicExpressionGrammarView : ItemView {
    34     private CheckedItemList<Symbol> symbols;
     32  [Content(typeof(ISymbolicExpressionTreeGrammar), true)]
     33  public partial class SymbolicExpressionTreeGrammarView : ItemView {
     34    private CheckedItemList<ISymbol> symbols;
    3535
    36     public new DefaultSymbolicExpressionGrammar Content {
    37       get { return (DefaultSymbolicExpressionGrammar)base.Content; }
     36    public new ISymbolicExpressionTreeGrammar Content {
     37      get { return (ISymbolicExpressionTreeGrammar)base.Content; }
    3838      set { base.Content = value; }
    3939    }
    4040
    41     public DefaultSymbolicExpressionGrammarView() {
     41    public SymbolicExpressionTreeGrammarView() {
    4242      InitializeComponent();
    43       symbols = new CheckedItemList<Symbol>();
    44       symbols.CheckedItemsChanged += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<Symbol>>(symbols_CheckedItemsChanged);
     43      symbols = new CheckedItemList<ISymbol>();
     44      symbols.CheckedItemsChanged += new CollectionItemsChangedEventHandler<IndexedItem<ISymbol>>(symbols_CheckedItemsChanged);
    4545    }
    4646
     
    8282
    8383    private void symbol_Changed(object sender, EventArgs e) {
    84       Symbol symbol = (Symbol)sender;
     84      ISymbol symbol = (ISymbol)sender;
    8585      symbols.SetItemCheckedState(symbol, symbol.InitialFrequency > 0.0);
    8686    }
    8787
    88     private void symbols_CheckedItemsChanged(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<HeuristicLab.Collections.IndexedItem<Symbol>> e) {
    89       ICheckedItemList<Symbol> checkedItemList = (ICheckedItemList<Symbol>)sender;
     88    private void symbols_CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<ISymbol>> e) {
     89      ICheckedItemList<ISymbol> checkedItemList = (ICheckedItemList<ISymbol>)sender;
    9090      foreach (var indexedItem in e.Items) {
    9191        if (checkedItemList.ItemChecked(indexedItem.Value)) {
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionView.cs

    r5473 r5513  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Windows.Forms;
    2324using HeuristicLab.MainForm;
    2425using HeuristicLab.MainForm.WindowsForms;
    2526using HeuristicLab.PluginInfrastructure;
    26 using System.Collections.Generic;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Formatters;
    2827
    2928namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
    3029  [View("SymbolicExpression View")]
    31   [Content(typeof(SymbolicExpressionTree), false)]
     30  [Content(typeof(ISymbolicExpressionTree), false)]
    3231  public partial class SymbolicExpressionView : AsynchronousContentView {
    3332
     
    4544      int selectedIndex = -1;
    4645      foreach (ISymbolicExpressionTreeStringFormatter formatter in formatters) {
    47         if (formatter is SymbolicExpressionTreeStringFormatter)
     46        if (formatter is ISymbolicExpressionTreeStringFormatter)
    4847          selectedIndex = treeFormattersList.Count;
    4948        treeFormattersList.Add(formatter);
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/VisualSymbolicExpressionTreeNode.cs

    r5473 r5513  
    3030    private const int defaultPreferredHeight = 46;
    3131
    32     public VisualSymbolicExpressionTreeNode(SymbolicExpressionTreeNode symbolicExpressionTreeNode) :
     32    public VisualSymbolicExpressionTreeNode(ISymbolicExpressionTreeNode symbolicExpressionTreeNode) :
    3333      this(symbolicExpressionTreeNode, defaultLineColor) {
    3434    }
    3535
    36     public VisualSymbolicExpressionTreeNode(SymbolicExpressionTreeNode symbolicExpressionTreeNode, Color lineColor) :
     36    public VisualSymbolicExpressionTreeNode(ISymbolicExpressionTreeNode symbolicExpressionTreeNode, Color lineColor) :
    3737      this(symbolicExpressionTreeNode, lineColor, defaultTextColor) {
    3838    }
    3939
    40     public VisualSymbolicExpressionTreeNode(SymbolicExpressionTreeNode symbolicExpressionTreeNode, Color lineColor, Color textColor) :
     40    public VisualSymbolicExpressionTreeNode(ISymbolicExpressionTreeNode symbolicExpressionTreeNode, Color lineColor, Color textColor) :
    4141      this(symbolicExpressionTreeNode, lineColor, textColor, defaultFillColor) {
    4242    }
    4343
    44     public VisualSymbolicExpressionTreeNode(SymbolicExpressionTreeNode symbolicExpressionTreeNode, Color lineColor, Color textColor, Color fillColor) :
     44    public VisualSymbolicExpressionTreeNode(ISymbolicExpressionTreeNode symbolicExpressionTreeNode, Color lineColor, Color textColor, Color fillColor) :
    4545      this(symbolicExpressionTreeNode, lineColor, textColor, fillColor, defaultPreferredWidth, defaultPreferredHeight) {
    4646    }
    4747
    48     public VisualSymbolicExpressionTreeNode(SymbolicExpressionTreeNode symbolicExpressionTreeNode, Color lineColor, Color textColor, Color fillColor, int width, int height) {
     48    public VisualSymbolicExpressionTreeNode(ISymbolicExpressionTreeNode symbolicExpressionTreeNode, Color lineColor, Color textColor, Color fillColor, int width, int height) {
    4949      this.symbolicExpressionTreeNode = symbolicExpressionTreeNode;
    5050      this.lineColor = lineColor;
     
    8282    #endregion
    8383
    84     private SymbolicExpressionTreeNode symbolicExpressionTreeNode;
    85     public SymbolicExpressionTreeNode SymbolicExpressionTreeNode {
     84    private ISymbolicExpressionTreeNode symbolicExpressionTreeNode;
     85    public ISymbolicExpressionTreeNode SymbolicExpressionTreeNode {
    8686      get { return this.symbolicExpressionTreeNode; }
    8787    }
  • branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ISymbol.cs

    r5510 r5513  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Core;
    2324
     
    2526  public interface ISymbol : INamedItem {
    2627    ISymbolicExpressionTreeNode CreateTreeNode();
    27     double InitialFrequency { get; }
     28    double InitialFrequency { get; set; }
     29
     30    event EventHandler Changed;
    2831  }
    2932}
Note: See TracChangeset for help on using the changeset viewer.