Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/27/13 13:31:32 (12 years ago)
Author:
bburlacu
Message:

#1772: Updated LineageExplorerView and added functionality for highlighting common fragments in a given tree. Fixed view layout and element anchoring.

Location:
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.cs

    r9239 r9250  
    105105      symbolicExpressionTreeChart.Tree = genealogyGraphNode.SymbolicExpressionTree;
    106106      if (genealogyGraphNode.InEdges == null) return;
    107       var arc = genealogyGraphNode.InEdges.First(x => x.Source != x.Target && x.Data != null);
    108       if (arc == null) return;
     107      var arc = genealogyGraphNode.InEdges.First(x => x.Source != x.Target);
     108      if (arc == null || arc.Data == null) return;
    109109      var fragment = (IFragment)arc.Data;
    110110      if (fragment.Root == null) return;
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/HeuristicLab.EvolutionaryTracking.Views-3.4.csproj

    r9239 r9250  
    9494      <DependentUpon>GenealogyGraphChart.cs</DependentUpon>
    9595    </Compile>
    96     <Compile Include="GenealogyGraphDialog.cs" />
     96    <Compile Include="GenealogyGraphDialog.cs">
     97      <SubType>Form</SubType>
     98    </Compile>
    9799    <Compile Include="GenealogyGraphDialog.designer.cs">
    98100      <DependentUpon>GenealogyGraphDialog.cs</DependentUpon>
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.Designer.cs

    r9239 r9250  
    5151      // qualityImprovementTreeView
    5252      //
    53       this.qualityImprovementTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     53      this.qualityImprovementTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     54            | System.Windows.Forms.AnchorStyles.Right)));
    5455      this.qualityImprovementTreeView.HideSelection = false;
    5556      this.qualityImprovementTreeView.Location = new System.Drawing.Point(388, 0);
     
    6162      // symbolicExpressionTreeChart
    6263      //
     64      this.symbolicExpressionTreeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     65            | System.Windows.Forms.AnchorStyles.Left)
     66            | System.Windows.Forms.AnchorStyles.Right)));
    6367      this.symbolicExpressionTreeChart.BackgroundColor = System.Drawing.Color.White;
    64       this.symbolicExpressionTreeChart.Dock = System.Windows.Forms.DockStyle.Fill;
    6568      this.symbolicExpressionTreeChart.LineColor = System.Drawing.Color.Black;
    6669      this.symbolicExpressionTreeChart.Location = new System.Drawing.Point(155, 0);
    6770      this.symbolicExpressionTreeChart.Name = "symbolicExpressionTreeChart";
    68       this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(348, 624);
     71      this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(227, 624);
    6972      this.symbolicExpressionTreeChart.Spacing = 5;
    7073      this.symbolicExpressionTreeChart.SuspendRepaint = false;
     
    9699      // showGenealogyButton
    97100      //
    98       this.showGenealogyButton.Location = new System.Drawing.Point(128, 4);
     101      this.showGenealogyButton.AutoSize = true;
     102      this.showGenealogyButton.Location = new System.Drawing.Point(129, 4);
    99103      this.showGenealogyButton.Name = "showGenealogyButton";
    100104      this.showGenealogyButton.Size = new System.Drawing.Size(104, 23);
     
    106110      // calculateFragmentFrequencyButton
    107111      //
     112      this.calculateFragmentFrequencyButton.AutoSize = true;
    108113      this.calculateFragmentFrequencyButton.Location = new System.Drawing.Point(4, 4);
    109114      this.calculateFragmentFrequencyButton.Name = "calculateFragmentFrequencyButton";
    110       this.calculateFragmentFrequencyButton.Size = new System.Drawing.Size(118, 23);
     115      this.calculateFragmentFrequencyButton.Size = new System.Drawing.Size(119, 23);
    111116      this.calculateFragmentFrequencyButton.TabIndex = 0;
    112117      this.calculateFragmentFrequencyButton.Text = "Fragment frequencies";
     
    124129      this.panel1.ResumeLayout(false);
    125130      this.panel2.ResumeLayout(false);
     131      this.panel2.PerformLayout();
    126132      this.ResumeLayout(false);
    127133
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.cs

    r9239 r9250  
    2424    public LineageExplorerView() {
    2525      InitializeComponent();
    26 
    2726      treeMap = new Dictionary<TreeNode, ISymbolicExpressionTree>();
    2827    }
     
    4544      base.OnContentChanged();
    4645      if (Content == null) {
    47         // TODO: Add code when content has been changed and is null
    4846      } else {
    4947        var tuples = Content.Trees.OrderByDescending(x => x.Item2).ToList();
     
    5755          scopeListTreeView.Nodes[i].ForeColor = color;
    5856        }
    59 
    60         // TODO: Add code when content has been changed and is not null
    6157      }
    6258    }
     
    7369
    7470      var graphNode = Content.GenealogyGraph.GetGraphNodes(symbExprTree).First();
    75       if (lineage == null)
    76         lineage = new List<SymbolicExpressionGenealogyGraphNode> { graphNode };
    77       else
    78         lineage.Clear();
     71      lineage = lineage ?? new List<SymbolicExpressionGenealogyGraphNode>();
     72      lineage.Clear();
     73      lineage.Add(graphNode);
    7974
    8075      var gn = graphNode;
     
    8378        lineage.Add(gn);
    8479      }
    85       lineage.Reverse();
     80      lineage.Reverse(); // incresing order by generation
    8681
    8782      // update the righthand side tree view
     
    10196    /// that is saved as a data member in the incoming arc from the parent in the previous generation
    10297    /// </summary>
    103     /// <param name="tree"></param>
     98    /// <param name="symbExprTree"></param>
    10499    private void HighlightFragment(ISymbolicExpressionTree symbExprTree) {
    105100      // update the symbolic expression tree chart with the new selected tree:
     101      symbolicExpressionTreeChart.SuspendRepaint = true;
    106102      symbolicExpressionTreeChart.Tree = symbExprTree;
    107103      var matchingNodes = Content.GenealogyGraph.GetGraphNodes(symbExprTree);
    108104      SymbolicExpressionGenealogyGraphNode graphNode = matchingNodes.First();
    109 
    110       if (graphNode.InEdges == null) return;
    111 
     105      if (graphNode.InEdges == null) {
     106        symbolicExpressionTreeChart.SuspendRepaint = false;
     107        symbolicExpressionTreeChart.Repaint();
     108        return;
     109      }
    112110      var fragment = (IFragment)graphNode.InEdges[0].Data;
    113       if (fragment.Root == null) return;
     111      if (fragment.Root == null) {
     112        symbolicExpressionTreeChart.SuspendRepaint = false;
     113        symbolicExpressionTreeChart.Repaint();
     114        return;
     115      }
    114116      foreach (var node in fragment.Root.IterateNodesBreadth()) {
    115117        var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
    116118        visualNode.LineColor = Color.DodgerBlue;
    117119      }
     120      symbolicExpressionTreeChart.SuspendRepaint = false;
    118121      symbolicExpressionTreeChart.Repaint();
    119122    }
     
    125128
    126129    private void calculateFragmentFrequencyButton_Click(object sender, EventArgs e) {
    127       var matchingNodes = Content.GenealogyGraph.GetGraphNodes(symbolicExpressionTreeChart.Tree);
    128       SymbolicExpressionGenealogyGraphNode graphNode = matchingNodes.First();
    129 
    130       //      var tree = symbolicExpressionTreeChart.Tree;
    131       //      var fragments = tree.IterateNodesPrefix().Select(node => new Fragment(node)).ToList();
    132       //
    133       //      var similarityComparer = new SymbolicExpressionTreeNodeSimilarityComparer {
    134       //        MatchConstantValues = false,
    135       //        MatchVariableNames = true,
    136       //        MatchVariableWeights = false
    137       //      };
    138       //
    139       //      var dict = new Dictionary<ISymbolicExpressionTree, bool>();
    140       //
    141       //      var trees = Content.Trees.Select(t => t.Item1).ToList();
    142 
    143 
    144       #region oldcode
    145       if (graphNode.InEdges == null) return;
    146 
    147       var fragment = (IFragment)graphNode.InEdges[0].Data;
    148       if (fragment.Root == null) return;
    149 
    150       var fragments = new List<IFragment>(); // fragments that contain the current fragment
    151       var subtree = fragment.Root;
    152 
    153       while (subtree.Parent != null) {
    154         subtree = subtree.Parent;
    155         fragments.Add(new Fragment(subtree));
    156       }
    157 
    158       fragments.Add(fragment);
    159       fragments.Sort((b, a) => a.Length.CompareTo(b.Length));
     130      // the individual can occur multiple times in the graph if it is(was) elite. we take the first occurence.
     131      var graphNode = Content.GenealogyGraph.GetGraphNodes(symbolicExpressionTreeChart.Tree).First();
     132      var fragments = graphNode.SymbolicExpressionTree.IterateNodesBreadth().Select(n => new Fragment(n));
     133      var trees = Content.Trees.Select(t => t.Item1).ToList();
     134      var hashset = new HashSet<ISymbolicExpressionTree>();
    160135
    161136      var similarityComparer = new SymbolicExpressionTreeNodeSimilarityComparer {
     
    165140      };
    166141
    167       //      var trees = Content.GenealogyGraph.Nodes.Select(n => n.SymbolicExpressionTree).ToList();
    168 
    169       var trees = Content.Trees.Select(t => t.Item1).ToList();
    170       //      var dictionary = new Dictionary<ISymbolicExpressionTree, bool>(trees.Count);
    171       var hashset = new HashSet<ISymbolicExpressionTree>();
    172       //      foreach (var tree in trees)
    173       //        if (!dictionary.ContainsKey(tree))
    174       //          dictionary.Add(tree, false);
    175 
     142      symbolicExpressionTreeChart.SuspendRepaint = true;
    176143      foreach (var f in fragments) {
    177         double frequency = 0;
    178         foreach (var tree in trees) {
    179           if (hashset.Contains(tree)) frequency += 1;
    180           else if (tree.Root.ContainsFragment(f, similarityComparer)) {
    181             frequency += 1;
    182             hashset.Add(tree);
     144        double freq = 0;
     145        foreach (var t in trees) {
     146          if (t.Root.ContainsFragment(f, similarityComparer)) ++freq;
     147          int index = (int)Math.Floor(freq * ColorGradient.Colors.Count / trees.Count);
     148          if (index == ColorGradient.Colors.Count) index--;
     149          var color = ColorGradient.Colors[index];
     150          foreach (var node in f.Root.IterateNodesBreadth()) {
     151            var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
     152            visualNode.FillColor = Color.FromArgb(200, color);
    183153          }
    184154        }
    185 
    186         int index = (int)Math.Floor(frequency * ColorGradient.Colors.Count / trees.Count);
    187         if (index == ColorGradient.Colors.Count) index--;
    188         var color = ColorGradient.Colors[index];
    189 
    190         foreach (var node in f.Root.IterateNodesBreadth()) {
    191           var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
    192           visualNode.FillColor = Color.FromArgb(200, color);
    193         }
    194155      }
    195       #endregion
     156      symbolicExpressionTreeChart.SuspendRepaint = false;
    196157      symbolicExpressionTreeChart.Repaint();
    197158    }
    198159
    199160    private void symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
    200 
    201161    }
    202162
     
    212172      }
    213173      using (var dialog = new GenealogyGraphDialog { Graph = graph }) {
    214         //        dialog.ShowDialog();
    215         dialog.Show(this);
     174        dialog.ShowDialog(this);
    216175      }
    217176    }
Note: See TracChangeset for help on using the changeset viewer.