Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14545 for branches


Ignore:
Timestamp:
01/05/17 15:12:27 (7 years ago)
Author:
pfleck
Message:

#2709

  • Uses StringMatrix for statistics instead of winforms datagrid.
  • Precheck input/target variables only for statistics.
Location:
branches/DataPreprocessing Enhancements
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs

    r14467 r14545  
    5757        var viewShortcuts = new ItemList<IViewShortcut> {
    5858          new DataGridContent(data, manipulationLogic, filterLogic),
    59           new StatisticsContent(statisticsLogic),
     59          new StatisticsContent(data, statisticsLogic),
    6060
    6161          new LineChartContent(data),
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/StatisticsView.Designer.cs

    r14185 r14545  
    5555      this.lblNominalColumns = new System.Windows.Forms.Label();
    5656      this.txtMissingValuesTotal = new System.Windows.Forms.Label();
    57       this.dataGridView = new System.Windows.Forms.DataGridView();
    58       ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
     57      this.stringMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView();
    5958      this.SuspendLayout();
    6059      //
     
    149148      this.txtMissingValuesTotal.Text = "102";
    150149      //
    151       // dataGridView
    152       //
    153       this.dataGridView.AllowUserToAddRows = false;
    154       this.dataGridView.AllowUserToDeleteRows = false;
    155       this.dataGridView.AllowUserToOrderColumns = true;
    156       this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    157             | System.Windows.Forms.AnchorStyles.Left)
     150      // stringMatrixView
     151      //
     152      this.stringMatrixView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     153            | System.Windows.Forms.AnchorStyles.Left)
    158154            | System.Windows.Forms.AnchorStyles.Right)));
    159       this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
    160       this.dataGridView.Location = new System.Drawing.Point(5, 117);
    161       this.dataGridView.Name = "dataGridView";
    162       this.dataGridView.ReadOnly = true;
    163       this.dataGridView.RowHeadersWidth = 80;
    164       this.dataGridView.Size = new System.Drawing.Size(530, 278);
    165       this.dataGridView.TabIndex = 4;
    166       this.dataGridView.VirtualMode = true;
    167       this.dataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.dataGridView_CellValueNeeded);
     155      this.stringMatrixView.Caption = "StringConvertibleMatrix View";
     156      this.stringMatrixView.Content = null;
     157      this.stringMatrixView.Location = new System.Drawing.Point(5, 117);
     158      this.stringMatrixView.Name = "stringMatrixView";
     159      this.stringMatrixView.ReadOnly = true;
     160      this.stringMatrixView.ShowRowsAndColumnsTextBox = false;
     161      this.stringMatrixView.ShowStatisticalInformation = true;
     162      this.stringMatrixView.Size = new System.Drawing.Size(530, 278);
     163      this.stringMatrixView.TabIndex = 4;
    168164      //
    169165      // StatisticsView
     
    171167      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    172168      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    173       this.Controls.Add(this.dataGridView);
     169      this.Controls.Add(this.stringMatrixView);
    174170      this.Controls.Add(this.lblNominalColumns);
    175171      this.Controls.Add(this.lblNumericColumns);
     
    184180      this.Name = "StatisticsView";
    185181      this.Size = new System.Drawing.Size(549, 408);
    186       ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
    187182      this.ResumeLayout(false);
    188183      this.PerformLayout();
     
    202197    private System.Windows.Forms.Label lblNominalColumns;
    203198    private System.Windows.Forms.Label txtMissingValuesTotal;
    204     private System.Windows.Forms.DataGridView dataGridView;
     199    private HeuristicLab.Data.Views.StringConvertibleMatrixView stringMatrixView;
    205200  }
    206201}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/StatisticsView.cs

    r14185 r14545  
    2424using System.Windows.Forms;
    2525using HeuristicLab.Core.Views;
     26using HeuristicLab.Data;
    2627using HeuristicLab.MainForm;
    2728
     
    3233  public partial class StatisticsView : ItemView {
    3334
    34     private List<List<string>> columnsRowsMatrix;
    35     private readonly int COLUMNS = 12;
     35    private StringMatrix statisticsMatrix;
     36
     37    private static readonly string[] RowNames = new[] {
     38      "Type",
     39      "Missing Values",
     40      "Min",
     41      "Max",
     42      "Median",
     43      "Average",
     44      "std. Deviation",
     45      "Variance",
     46      "25th Percentile",
     47      "75th Percentile",
     48      "Most Common Value",
     49      "Num. diff. Values"
     50    };
    3651
    3752    public new StatisticsContent Content {
     
    5267        txtNominalColumns.Text = "";
    5368        txtMissingValuesTotal.Text = "";
    54         dataGridView.Columns.Clear();
     69        stringMatrixView.Content = null;
     70        statisticsMatrix = null;
    5571      } else {
    5672        UpdateData();
     
    5874    }
    5975
    60     /// <summary>
    61     /// Adds eventhandlers to the current instance.
    62     /// </summary>
    6376    protected override void RegisterContentEvents() {
     77      base.RegisterContentEvents();
    6478      Content.Changed += Content_Changed;
    6579    }
    6680
    67 
    68     /// <summary>
    69     /// Removes the eventhandlers from the current instance.
    70     /// </summary>
    7181    protected override void DeregisterContentEvents() {
    7282      Content.Changed -= Content_Changed;
     83      base.DeregisterContentEvents();
    7384    }
    7485
     
    7687      var logic = Content.StatisticsLogic;
    7788      var rowCount = logic.GetRowCount();
    78       txtRows.Text = rowCount.ToString();
    79       txtColumns.Text = logic.GetColumnCount().ToString();
     89      txtRows.Text = logic.GetColumnCount().ToString();
     90      txtColumns.Text = rowCount.ToString();
    8091      txtNumericColumns.Text = logic.GetNumericColumnCount().ToString();
    8192      txtNominalColumns.Text = logic.GetNominalColumnCount().ToString();
    8293      txtMissingValuesTotal.Text = logic.GetMissingValueCount().ToString();
    8394
    84       columnsRowsMatrix = new List<List<string>>();
    85       DataGridViewColumn[] columns = new DataGridViewColumn[COLUMNS];
    86       for (int i = 0; i < COLUMNS; ++i) {
    87         var column = new DataGridViewTextBoxColumn();
    88         column.SortMode = DataGridViewColumnSortMode.Automatic;
    89         column.FillWeight = 1;
    90         columns[i] = column;
    91       }
    92 
    93       columns[0].HeaderCell.Value = "Type";
    94       columns[1].HeaderCell.Value = "Missing Values";
    95       columns[2].HeaderCell.Value = "Min";
    96       columns[3].HeaderCell.Value = "Max";
    97       columns[4].HeaderCell.Value = "Median";
    98       columns[5].HeaderCell.Value = "Average";
    99       columns[6].HeaderCell.Value = "std. Deviation";
    100       columns[7].HeaderCell.Value = "Variance";
    101       columns[8].HeaderCell.Value = "25th Percentile";
    102       columns[9].HeaderCell.Value = "75th Percentile";
    103       columns[10].HeaderCell.Value = "Most Common Value";
    104       columns[11].HeaderCell.Value = "Num. diff. Values";
     95      statisticsMatrix = new StringMatrix(RowNames.Length, Content.PreprocessingData.Columns) {
     96        RowNames = StatisticsView.RowNames,
     97        ColumnNames = Content.PreprocessingData.VariableNames
     98      };
    10599
    106100      if (rowCount > 0) {
    107101        for (int i = 0; i < logic.GetColumnCount(); ++i) {
    108           columnsRowsMatrix.Add(GetList(i));
     102          var data = GetList(i);
     103          for (int j = 0; j < data.Count; j++) {
     104            statisticsMatrix[j, i] = data[j];
     105          }
    109106        }
    110107      }
    111 
    112       dataGridView.Columns.Clear();
    113       dataGridView.Columns.AddRange(columns);
    114       dataGridView.RowCount = columnsRowsMatrix.Count;
    115 
    116       for (int i = 0; i < columnsRowsMatrix.Count; ++i) {
    117         dataGridView.Rows[i].HeaderCell.Value = logic.GetVariableName(i);
    118       }
    119 
    120       dataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
    121       dataGridView.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders);
    122       dataGridView.AllowUserToResizeColumns = true;
     108      stringMatrixView.Content = statisticsMatrix;
     109
     110      foreach (DataGridViewColumn column in stringMatrixView.DataGridView.Columns) {
     111        var variable = column.HeaderText;
     112        bool isInputTarget = Content.PreprocessingData.InputVariables.Contains(variable)
     113                             || Content.PreprocessingData.TargetVariable == variable;
     114        column.Visible = isInputTarget;
     115      }
     116      stringMatrixView.DataGridView.AutoResizeColumns();
     117
     118      //foreach (DataGridViewRow row in stringMatrixView.DataGridView.Rows) {
     119      //  var variable = (string)row.HeaderCell.Value;
     120      //  bool isInputTarget = Content.PreprocessingData.InputVariables.Contains(variable)
     121      //                       || Content.PreprocessingData.TargetVariable == variable;
     122      //  row.Visible = isInputTarget;
     123      //}
    123124    }
    124125
     
    134135      } else {
    135136        list = new List<string>();
    136         for (int j = 0; j < COLUMNS; ++j) {
     137        for (int j = 0; j < RowNames.Length; ++j) {
    137138          list.Add("unknown column type");
    138139        }
     
    195196    }
    196197
    197     private void dataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {
    198       if (Content != null && e.RowIndex < columnsRowsMatrix.Count && e.ColumnIndex < columnsRowsMatrix[0].Count) {
    199         e.Value = columnsRowsMatrix[e.RowIndex][e.ColumnIndex];
    200       }
    201     }
    202 
    203198    private void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
    204       switch (e.Type) {
    205         case DataPreprocessingChangedEventType.DeleteColumn:
    206           columnsRowsMatrix.RemoveAt(e.Column);
    207           break;
    208         case DataPreprocessingChangedEventType.AddColumn:
    209           columnsRowsMatrix.Insert(e.Row, GetList(e.Column));
    210           dataGridView.RowCount++;
    211           break;
    212         case DataPreprocessingChangedEventType.ChangeItem:
    213           columnsRowsMatrix[e.Column] = GetList(e.Column);
    214           break;
    215         case DataPreprocessingChangedEventType.DeleteRow:
    216         case DataPreprocessingChangedEventType.AddRow:
    217         default:
    218           for (int i = 0; i < columnsRowsMatrix.Count; ++i) {
    219             columnsRowsMatrix[i] = GetList(e.Column);
    220           }
    221           break;
    222       }
    223       dataGridView.Refresh();
     199      UpdateData();
     200      //switch (e.Type) {
     201      //  case DataPreprocessingChangedEventType.DeleteColumn:
     202      //    statisticsMatrix.RemoveAt(e.Column);
     203      //    break;
     204      //  case DataPreprocessingChangedEventType.AddColumn:
     205      //    statisticsMatrix.Insert(e.Row, GetList(e.Column));
     206      //    stringMatrixView.Content.Rows++;
     207      //    break;
     208      //  case DataPreprocessingChangedEventType.ChangeItem:
     209      //    statisticsMatrix[e.Column] = GetList(e.Column);
     210      //    break;
     211      //  case DataPreprocessingChangedEventType.DeleteRow:
     212      //  case DataPreprocessingChangedEventType.AddRow:
     213      //  default:
     214      //    for (int i = 0; i < statisticsMatrix.Count; ++i) {
     215      //      statisticsMatrix[i] = GetList(e.Column);
     216      //    }
     217      //    break;
     218      //}
    224219    }
    225220  }
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/StatisticsContent.cs

    r14185 r14545  
    2727  [Item("Statistics", "Represents the statistics grid.")]
    2828  public class StatisticsContent : Item, IViewShortcut {
     29    public ITransactionalPreprocessingData PreprocessingData { get; private set; }
    2930
    3031    private readonly StatisticsLogic statisticsLogic;
    31     public StatisticsContent(StatisticsLogic theStatisticsLogic) {
     32    public StatisticsContent(ITransactionalPreprocessingData preProcessingData, StatisticsLogic theStatisticsLogic) {
     33      PreprocessingData = preProcessingData;
    3234      statisticsLogic = theStatisticsLogic;
    3335    }
Note: See TracChangeset for help on using the changeset viewer.