Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingFeatureCorrelationView.cs

Last change on this file was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

File size: 3.2 KB
RevLine 
[8578]1#region License Information
2/* HeuristicLab
[17180]3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[8578]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
[15110]22using System;
23using System.Linq;
24using HeuristicLab.Data.Views;
[8578]25using HeuristicLab.MainForm;
26using HeuristicLab.MainForm.WindowsForms;
27
[15110]28namespace HeuristicLab.DataPreprocessing.Views {
[10908]29  [View("Preprocessing Feature Correlation View")]
[15110]30  [Content(typeof(CorrelationMatrixContent), true)]
[10908]31  public partial class PreprocessingFeatureCorrelationView : AsynchronousContentView {
[13502]32    public new CorrelationMatrixContent Content {
33      get { return (CorrelationMatrixContent)base.Content; }
[8578]34      set { base.Content = value; }
35    }
36
[10908]37    public PreprocessingFeatureCorrelationView() {
[8578]38      InitializeComponent();
39    }
40
41    protected override void RegisterContentEvents() {
42      base.RegisterContentEvents();
[13502]43      Content.Changed += Data_Changed;
[8578]44    }
45
46    protected override void DeregisterContentEvents() {
[13502]47      Content.Changed -= Data_Changed;
[8578]48      base.DeregisterContentEvents();
49    }
50
[10934]51    private void Data_Changed(object sender, DataPreprocessingChangedEventArgs e) {
52      OnContentChanged();
53    }
54
[8578]55    protected override void OnContentChanged() {
56      base.OnContentChanged();
[15110]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)
[10908]76        return;
77
[15110]78      dataView.ColumnVisibility = visibilities;
79      dataView.RowVisibility = visibilities;
80      dataView.UpdateColumnHeaders();
81      dataView.UpdateRowHeaders();
[8578]82    }
[15110]83    #endregion
[8578]84  }
85}
Note: See TracBrowser for help on using the repository browser.