Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2898_GeneralizedAdditiveModels/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs @ 16003

Last change on this file since 16003 was 15583, checked in by swagner, 7 years ago

#2640: Updated year of copyrights in license headers

File size: 3.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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.Drawing;
24using HeuristicLab.Analysis;
25using HeuristicLab.MainForm;
26
27namespace HeuristicLab.DataPreprocessing.Views {
28  [View("Histogram View")]
29  [Content(typeof(HistogramContent), true)]
30  public partial class HistogramView : PreprocessingChartView {
31    public new HistogramContent Content {
32      get { return (HistogramContent)base.Content; }
33      set { base.Content = value; }
34    }
35
36    public HistogramView() {
37      InitializeComponent();
38      aggregationComboBox.DataSource = Enum.GetValues(typeof(DataTableVisualProperties.DataTableHistogramAggregation));
39      aggregationComboBox.SelectedItem = DataTableVisualProperties.DataTableHistogramAggregation.Overlapping;
40      orderComboBox.DataSource = Enum.GetValues(typeof(PreprocessingChartContent.LegendOrder));
41      orderComboBox.SelectedItem = PreprocessingChartContent.LegendOrder.Alphabetically;
42    }
43
44    protected override void OnContentChanged() {
45      base.OnContentChanged();
46      groupingComboBox.Items.Clear();
47      groupingComboBox.Items.Add(string.Empty);
48
49      if (Content != null) {
50        foreach (string var in PreprocessingChartContent.GetVariableNamesForGrouping(Content.PreprocessingData)) {
51          groupingComboBox.Items.Add(var);
52        }
53
54        groupingComboBox.SelectedItem = Content.GroupingVariableName ?? string.Empty;
55      }
56    }
57
58    protected override DataTable CreateDataTable(string variableName) {
59      var aggregation = (DataTableVisualProperties.DataTableHistogramAggregation)aggregationComboBox.SelectedItem;
60      var hist = HistogramContent.CreateHistogram(Content.PreprocessingData, variableName, Content.GroupingVariableName, aggregation, Content.Order);
61      hist.VisualProperties.TitleFont = new Font(DefaultFont.FontFamily, 10, FontStyle.Bold);
62      return hist;
63    }
64
65    private void classifierComboBox_SelectedIndexChanged(object sender, EventArgs e) {
66      Content.GroupingVariableName = groupingComboBox.SelectedItem.ToString();
67
68      // rebuild datatables
69      InitData();
70      GenerateLayout();
71    }
72
73    private void aggregationComboBox_SelectedIndexChanged(object sender, EventArgs e) {
74      foreach (var dt in dataTables.Values) {
75        dt.VisualProperties.HistogramAggregation = (DataTableVisualProperties.DataTableHistogramAggregation)aggregationComboBox.SelectedItem;
76      }
77    }
78
79    private void orderComboBox_SelectedIndexChanged(object sender, EventArgs e) {
80      if (Content == null) return;
81
82      Content.Order = (PreprocessingChartContent.LegendOrder)orderComboBox.SelectedItem;
83
84      // rebuild datatables
85      InitData();
86      GenerateLayout();
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.