Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingFeatureCorrelationView.cs @ 17842

Last change on this file since 17842 was 17181, checked in by swagner, 5 years ago

#2875: Merged r17180 from trunk to stable

File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Linq;
24using HeuristicLab.Data.Views;
25using HeuristicLab.MainForm;
26using HeuristicLab.MainForm.WindowsForms;
27
28namespace HeuristicLab.DataPreprocessing.Views {
29  [View("Preprocessing Feature Correlation View")]
30  [Content(typeof(CorrelationMatrixContent), true)]
31  public partial class PreprocessingFeatureCorrelationView : AsynchronousContentView {
32    public new CorrelationMatrixContent Content {
33      get { return (CorrelationMatrixContent)base.Content; }
34      set { base.Content = value; }
35    }
36
37    public PreprocessingFeatureCorrelationView() {
38      InitializeComponent();
39    }
40
41    protected override void RegisterContentEvents() {
42      base.RegisterContentEvents();
43      Content.Changed += Data_Changed;
44    }
45
46    protected override void DeregisterContentEvents() {
47      Content.Changed -= Data_Changed;
48      base.DeregisterContentEvents();
49    }
50
51    private void Data_Changed(object sender, DataPreprocessingChangedEventArgs e) {
52      OnContentChanged();
53    }
54
55    protected override void OnContentChanged() {
56      base.OnContentChanged();
57      correlationView.Content = Content != null ? Content.ProblemData : null;
58    }
59
60    #region Check Variables
61    private void checkAllButton_Click(object sender, System.EventArgs e) {
62      SetVisibility(x => true);
63    }
64    private void checkInputsTargetButton_Click(object sender, System.EventArgs e) {
65      var ppd = Content.PreprocessingData;
66      SetVisibility(x => ppd.InputVariables.Contains(x) || ppd.TargetVariable == x);
67    }
68    private void uncheckAllButton_Click(object sender, System.EventArgs e) {
69      SetVisibility(x => false);
70    }
71    private void SetVisibility(Func<string, bool> check) {
72      var dataView = (EnhancedStringConvertibleMatrixView)correlationView.Controls.Find("DataView", searchAllChildren: true).Single();
73      var ppd = Content.PreprocessingData;
74      var visibilities = ppd.VariableNames.Where((v, i) => ppd.VariableHasType<double>(i)).Select(check).ToList();
75      if (dataView.Content.Rows != dataView.Content.Columns || dataView.Content.Rows != visibilities.Count)
76        return;
77
78      dataView.ColumnVisibility = visibilities;
79      dataView.RowVisibility = visibilities;
80      dataView.UpdateColumnHeaders();
81      dataView.UpdateRowHeaders();
82    }
83    #endregion
84  }
85}
Note: See TracBrowser for help on using the repository browser.