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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using System.Windows.Forms;
|
---|
26 | using HeuristicLab.Analysis.Views;
|
---|
27 | using HeuristicLab.MainForm;
|
---|
28 |
|
---|
29 | namespace 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 | }
|
---|