Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/21/13 16:20:52 (12 years ago)
Author:
bburlacu
Message:

#1772: Merged trunk changes for HeuristicLab.Optimization.Views. Modified RunCollectionDataTableView to calculate rows mean and put the results into the clipboard.

Location:
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Optimization.Views
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Optimization.Views

  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionBubbleChartView.cs

    r9068 r9240  
    2020#endregion
    2121
     22using HeuristicLab.Common;
     23using HeuristicLab.Core;
     24using HeuristicLab.Data;
     25using HeuristicLab.MainForm;
     26using HeuristicLab.MainForm.WindowsForms;
    2227using System;
    2328using System.Collections.Generic;
     
    2631using System.Windows.Forms;
    2732using System.Windows.Forms.DataVisualization.Charting;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Core;
    30 using HeuristicLab.Data;
    31 using HeuristicLab.MainForm;
    32 using HeuristicLab.MainForm.WindowsForms;
    3333
    3434namespace HeuristicLab.Optimization.Views {
     
    5858      chart.ContextMenuStrip.Items.Insert(0, hideRunToolStripMenuItem);
    5959      chart.ContextMenuStrip.Items.Insert(1, openBoxPlotViewToolStripMenuItem);
     60      chart.ContextMenuStrip.Items.Add(getDataAsMatrixToolStripMenuItem);
    6061      chart.ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening);
    6162
     
    688689      boxplotView.Show();
    689690    }
     691
     692    private void getDataAsMatrixToolStripMenuItem_Click(object sender, EventArgs e) {
     693      int xCol = Matrix.ColumnNames.ToList().IndexOf(xAxisValue);
     694      var grouped = new Dictionary<string, List<string>>();
     695      Dictionary<double, string> reverseMapping = null;
     696      if (categoricalMapping.ContainsKey(xCol))
     697        reverseMapping = categoricalMapping[xCol].ToDictionary(x => x.Value, y => y.Key.ToString());
     698      foreach (var run in Content.Where(r => r.Visible)) {
     699        var x = GetValue(run, xAxisValue);
     700        var y = GetValue(run, yAxisValue);
     701        if (!(x.HasValue && y.HasValue)) continue;
     702
     703        var category = reverseMapping == null ? x.Value.ToString() : reverseMapping[x.Value];
     704        if (!grouped.ContainsKey(category)) grouped[category] = new List<string>();
     705        grouped[category].Add(y.Value.ToString());
     706      }
     707
     708      if (!grouped.Any()) return;
     709      var matrix = new StringMatrix(grouped.Values.Max(x => x.Count), grouped.Count) {
     710        ColumnNames = grouped.Keys.ToArray()
     711      };
     712      int i = 0;
     713      foreach (var col in matrix.ColumnNames) {
     714        int j = 0;
     715        foreach (var y in grouped[col])
     716          matrix[j++, i] = y;
     717        i++;
     718      }
     719
     720      MainFormManager.MainForm.ShowContent(matrix);
     721    }
    690722    #endregion
    691723
Note: See TracChangeset for help on using the changeset viewer.