Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/24/12 18:48:16 (12 years ago)
Author:
sforsten
Message:

#1292:

  • NaN values are used, if the calculation is invalid (e.g. missing values, infinity etc.)
  • Variables can now be filtered. Initially allowed input variables and target variable are shown, but with a right click a dialog can be opened to select variables, which shall be shown
Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.Designer.cs

    r8578 r8689  
    4646    /// </summary>
    4747    private void InitializeComponent() {
     48      this.components = new System.ComponentModel.Container();
    4849      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AbstractFeatureCorrelationView));
    4950      this.DataGridView = new System.Windows.Forms.DataGridView();
     
    5960      this.CalculatingPanel = new System.Windows.Forms.Panel();
    6061      this.CalculatingLabel = new System.Windows.Forms.Label();
     62      this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
     63      this.ShowHideColumns = new System.Windows.Forms.ToolStripMenuItem();
    6164      ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
    6265      ((System.ComponentModel.ISupportInitialize)(this.PictureBox)).BeginInit();
     
    6669      this.SplitContainer.SuspendLayout();
    6770      this.CalculatingPanel.SuspendLayout();
     71      this.contextMenu.SuspendLayout();
    6872      this.SuspendLayout();
    6973      //
     
    8488      this.DataGridView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.DataGridView_ColumnHeaderMouseClick);
    8589      this.DataGridView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.DataGridView_KeyDown);
     90      this.DataGridView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.DataGridView_MouseClick);
    8691      //
    8792      // HeatMapProgressBar
     
    211216      this.CalculatingLabel.TabIndex = 10;
    212217      this.CalculatingLabel.Text = "Calculating correlation...";
     218      //
     219      // contextMenu
     220      //
     221      this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     222            this.ShowHideColumns});
     223      this.contextMenu.Name = "contextMenu";
     224      this.contextMenu.Size = new System.Drawing.Size(191, 26);
     225      //
     226      // ShowHideColumns
     227      //
     228      this.ShowHideColumns.Name = "ShowHideColumns";
     229      this.ShowHideColumns.Size = new System.Drawing.Size(190, 22);
     230      this.ShowHideColumns.Text = "Show / Hide Columns";
     231      this.ShowHideColumns.Click += new System.EventHandler(this.ShowHideColumns_Click);
    213232      //
    214233      // AbstractFeatureCorrelationView
     
    231250      this.CalculatingPanel.ResumeLayout(false);
    232251      this.CalculatingPanel.PerformLayout();
     252      this.contextMenu.ResumeLayout(false);
    233253      this.ResumeLayout(false);
    234254
     
    249269    protected System.Windows.Forms.Panel CalculatingPanel;
    250270    protected System.Windows.Forms.Label CalculatingLabel;
     271    protected System.Windows.Forms.ContextMenuStrip contextMenu;
     272    protected System.Windows.Forms.ToolStripMenuItem ShowHideColumns;
    251273
    252274  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.cs

    r8578 r8689  
    3030using HeuristicLab.Common;
    3131using HeuristicLab.Data.Views;
     32using HeuristicLab.DataAnalysis.Views;
    3233using HeuristicLab.MainForm;
    3334using HeuristicLab.MainForm.WindowsForms;
     
    4041
    4142    private int[] virtualRowIndices;
     43    private VariableVisibilityDialog variableVisibility;
    4244    private List<KeyValuePair<int, SortOrder>> sortedColumnIndices;
    4345    private StringConvertibleMatrixView.RowComparer rowComparer;
     
    8284      if (Content != null) {
    8385        fcc.ProblemData = Content;
     86        bool[] initialVisibility = SetInitialVisibilityOfColumns();
     87
     88        variableVisibility = new VariableVisibilityDialog(Content.Dataset.DoubleVariables, initialVisibility);
     89        variableVisibility.VariableVisibilityChanged += new ItemCheckEventHandler(variableVisibility_VariableVisibilityChanged);
    8490        CalculateCorrelation();
    8591      } else {
     
    8894      }
    8995    }
     96
     97    protected virtual bool[] SetInitialVisibilityOfColumns() {
     98      bool[] initialVisibility = new bool[Content.Dataset.DoubleVariables.Count()];
     99      int i = 0;
     100      foreach (var variable in Content.Dataset.DoubleVariables) {
     101        initialVisibility[i] = Content.AllowedInputVariables.Contains(variable);
     102        i++;
     103      }
     104      return initialVisibility;
     105    }
     106
     107    protected abstract void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e);
    90108
    91109    protected void CorrelationMeasureComboBox_SelectedChangeCommitted(object sender, System.EventArgs e) {
     
    127145      for (int i = 0; i < DataGridView.ColumnCount; i++) {
    128146        DataGridView.Columns[i].HeaderText = currentCorrelation.ColumnNames.ElementAt(i);
     147        DataGridView.Columns[i].Visible = variableVisibility.Visibility[i];
    129148      }
    130149    }
     
    132151      for (int i = 0; i < DataGridView.RowCount; i++) {
    133152        DataGridView.Rows[i].HeaderCell.Value = currentCorrelation.RowNames.ElementAt(virtualRowIndices[i]);
     153        DataGridView.Rows[i].Visible = variableVisibility.Visibility[virtualRowIndices[i]];
    134154      }
    135155    }
     
    169189
    170190    protected virtual Color GetDataPointColor(double value, double min, double max) {
     191      if (double.IsNaN(value)) {
     192        return Color.DarkGray;
     193      }
    171194      IList<Color> colors = ColorGradient.Colors;
    172195      int index = (int)((colors.Count - 1) * (value - min) / (max - min));
     
    301324    }
    302325    #endregion
     326
     327    protected void ShowHideColumns_Click(object sender, EventArgs e) {
     328      variableVisibility.ShowDialog();
     329    }
     330
     331    protected void DataGridView_MouseClick(object sender, MouseEventArgs e) {
     332      if (Content == null) return;
     333      if (e.Button == MouseButtons.Right && DataGridView.Columns.Count != 0)
     334        contextMenu.Show(MousePosition);
     335    }
     336
     337    protected int GetRowIndexOfVirtualindex(int virtualIndex) {
     338      if (virtualIndex < 0 || virtualIndex >= virtualRowIndices.Length) {
     339        throw new ArgumentException("Virtual index is out of bounds");
     340      }
     341
     342      for (int i = 0; i < virtualRowIndices.Length; i++) {
     343        if (virtualRowIndices[i] == virtualIndex) {
     344          return i;
     345        }
     346      }
     347      throw new ArgumentException("Virtual index was not found!");
     348    }
    303349  }
    304350}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.resx

    r8578 r8689  
    10201020</value>
    10211021  </data>
     1022  <metadata name="contextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     1023    <value>17, 17</value>
     1024  </metadata>
    10221025</root>
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationView.cs

    r8578 r8689  
    7878      }
    7979    }
     80
     81    protected override void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e) {
     82      DataGridView.Columns[e.Index].Visible = e.NewValue == CheckState.Checked;
     83      DataGridView.Rows[GetRowIndexOfVirtualindex(e.Index)].Visible = e.NewValue == CheckState.Checked;
     84    }
    8085  }
    8186}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/TimeframeFeatureCorrelationView.cs

    r8578 r8689  
    107107      }
    108108    }
     109
     110    protected override void variableVisibility_VariableVisibilityChanged(object sender, ItemCheckEventArgs e) {
     111      DataGridView.Rows[GetRowIndexOfVirtualindex(e.Index)].Visible = e.NewValue == CheckState.Checked;
     112    }
    109113  }
    110114}
Note: See TracChangeset for help on using the changeset viewer.