Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis.Views/3.4/ExtendedHeatMapView.cs @ 8276

Last change on this file since 8276 was 8276, checked in by sforsten, 12 years ago

#1292:

  • merged r8034:8179 from trunk
  • added BackgroundWorker
  • added ProgressBar
  • added SpearmansRankCorrelationCoefficientCalculator
  • corrected bug in HoeffdingsDependenceCalculator
  • made some changes in the GUI
File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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.Collections.Generic;
24using System.Linq;
25using System.Windows.Forms;
26using HeuristicLab.Analysis.Views;
27using HeuristicLab.MainForm;
28
29namespace HeuristicLab.Problems.DataAnalysis.Views {
30  [View("ExtendedHeatMap View")]
31  [Content(typeof(ExtendedHeatMap), false)]
32  public partial class ExtendedHeatMapView : HeatMapView {
33    public new ExtendedHeatMap Content {
34      get { return (ExtendedHeatMap)base.Content; }
35      set { base.Content = value; }
36    }
37
38    public ExtendedHeatMapView() {
39      InitializeComponent();
40      chart.ChartAreas[0].AxisX.Title = "";
41      chart.ChartAreas[0].AxisY.Title = "";
42    }
43
44    protected override void OnResize(EventArgs e) {
45      base.OnResize(e);
46      SetMarkerSize();
47    }
48
49    private void SetMarkerSize() {
50      if (chart != null && chart.ChartAreas.Count > 0 && chart.Series.Count > 0) {
51        int height = (chart.Size.Height / 4) * 3;
52        double max = chart.ChartAreas[0].AxisY.Maximum;
53        chart.Series[0].MarkerSize = (int)Math.Floor(height / max);
54      }
55    }
56
57    protected override void UpdatePoints() {
58      base.UpdatePoints();
59      UpdateLabels();
60      SetMarkerSize();
61    }
62
63    protected virtual void UpdateLabels() {
64      chart.ChartAreas[0].AxisX.CustomLabels.Clear();
65      IList<string> names = Content.ColumnNames.ToList();
66      for (int i = 0; i < names.Count; i++) {
67        chart.ChartAreas[0].AxisX.CustomLabels.Add(i + 0.5, i + 1.5, names[i]);
68        chart.ChartAreas[0].AxisY.CustomLabels.Add(i + 0.5, i + 1.5, names[i]);
69      }
70    }
71
72    protected override void DeregisterContentEvents() {
73      Content.ColumnNamesChanged -= new EventHandler(Content_ColumnNamesChanged);
74      Content.Reset -= new EventHandler(Content_Reset);
75      base.DeregisterContentEvents();
76    }
77    protected override void RegisterContentEvents() {
78      base.RegisterContentEvents();
79      // only column names event is required. Row names are the same.
80      Content.ColumnNamesChanged += new EventHandler(Content_ColumnNamesChanged);
81      Content.Reset += new EventHandler(Content_Reset);
82    }
83
84    protected virtual void Content_ColumnNamesChanged(object sender, EventArgs e) {
85      if (InvokeRequired)
86        Invoke(new EventHandler(Content_ColumnNamesChanged), sender, e);
87      else {
88        UpdateLabels();
89      }
90    }
91
92    protected void Content_Reset(object sender, EventArgs e) {
93      UpdatePoints();
94    }
95  }
96}
Note: See TracBrowser for help on using the repository browser.