Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Analysis/3.3/DataVisualization/HeatMap.cs @ 13656

Last change on this file since 13656 was 13656, checked in by ascheibe, 8 years ago

#2582 created branch for Hive Web Job Manager

File size: 4.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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 HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Analysis {
29  [Item("HeatMap", "Represents a heat map of double values.")]
30  [StorableClass]
31  public class HeatMap : DoubleMatrix {
32
33
34    private string title;
35    public string Title
36    {
37      get { return title; }
38      set
39      {
40        if (value == null) value = string.Empty;
41        if (title != value) {
42          title = value;
43          OnTitleChanged();
44        }
45      }
46    }
47    private double minimum;
48    public double Minimum
49    {
50      get { return minimum; }
51      set
52      {
53        if (minimum != value) {
54          minimum = value;
55          if (minimum >= maximum) Maximum = minimum + 1.0;
56          OnMinimumChanged();
57        }
58      }
59    }
60    private double maximum;
61    public double Maximum
62    {
63      get { return maximum; }
64      set
65      {
66        if (maximum != value) {
67          maximum = value;
68          if (maximum <= minimum) Minimum = maximum - 1.0;
69          OnMaximumChanged();
70        }
71      }
72    }
73
74    #region Storable Properties
75    [Storable(Name = "Title")]
76    private string StorableTitle
77    {
78      get { return title; }
79      set { title = value; }
80    }
81    [Storable(Name = "Minimum")]
82    private double StorableMinimum
83    {
84      get { return minimum; }
85      set { minimum = value; }
86    }
87    [Storable(Name = "Maximum")]
88    private double StorableMaximum
89    {
90      get { return maximum; }
91      set { maximum = value; }
92    }
93    #endregion
94
95    [StorableConstructor]
96    protected HeatMap(bool deserializing) : base(deserializing) { }
97    protected HeatMap(HeatMap original, Cloner cloner)
98      : base(original, cloner) {
99      this.title = original.title;
100      this.minimum = original.minimum;
101      this.maximum = original.maximum;
102    }
103    public HeatMap()
104      : base() {
105      this.title = "Heat Map";
106      this.minimum = 0.0;
107      this.maximum = 1.0;
108    }
109    public HeatMap(int rows, int columns)
110      : base(rows, columns) {
111      this.title = "Heat Map";
112      this.minimum = 0.0;
113      this.maximum = 1.0;
114    }
115    public HeatMap(int rows, int columns, string title)
116      : base(rows, columns) {
117      this.title = title == null ? string.Empty : title;
118      this.minimum = 0.0;
119      this.maximum = 1.0;
120    }
121    public HeatMap(double[,] elements)
122      : base(elements) {
123      this.title = "Heat Map";
124      this.minimum = 0.0;
125      this.maximum = 1.0;
126    }
127    public HeatMap(double[,] elements, string title)
128      : base(elements) {
129      this.title = title == null ? string.Empty : title;
130      this.minimum = 0.0;
131      this.maximum = 1.0;
132    }
133    public HeatMap(double[,] elements, string title, double minimum, double maximum)
134      : base(elements) {
135      this.title = title == null ? string.Empty : title;
136      if (minimum >= maximum) throw new ArgumentException("Minimum is larger than or equal to maximum");
137      this.minimum = minimum;
138      this.maximum = maximum;
139    }
140
141    public override IDeepCloneable Clone(Cloner cloner) {
142      return new HeatMap(this, cloner);
143    }
144
145    public override string ToString() {
146      return Title;
147    }
148
149    public event EventHandler TitleChanged;
150    protected virtual void OnTitleChanged() {
151      var handler = TitleChanged;
152      if (handler != null) handler(this, EventArgs.Empty);
153    }
154    public event EventHandler MinimumChanged;
155    protected virtual void OnMinimumChanged() {
156      var handler = MinimumChanged;
157      if (handler != null) handler(this, EventArgs.Empty);
158    }
159    public event EventHandler MaximumChanged;
160    protected virtual void OnMaximumChanged() {
161      var handler = MaximumChanged;
162      if (handler != null) handler(this, EventArgs.Empty);
163    }
164  }
165}
Note: See TracBrowser for help on using the repository browser.