[4703] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[12012] | 3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[4703] | 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 |
|
---|
[4739] | 22 | using System;
|
---|
[4703] | 23 | using HeuristicLab.Common;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Data;
|
---|
| 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Analysis {
|
---|
| 29 | [Item("HeatMap", "Represents a heat map of double values.")]
|
---|
| 30 | [StorableClass]
|
---|
| 31 | public class HeatMap : DoubleMatrix {
|
---|
| 32 |
|
---|
[13656] | 33 |
|
---|
[4739] | 34 | private string title;
|
---|
[13656] | 35 | public string Title
|
---|
| 36 | {
|
---|
[4739] | 37 | get { return title; }
|
---|
[13656] | 38 | set
|
---|
| 39 | {
|
---|
[4848] | 40 | if (value == null) value = string.Empty;
|
---|
| 41 | if (title != value) {
|
---|
| 42 | title = value;
|
---|
[4739] | 43 | OnTitleChanged();
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 | private double minimum;
|
---|
[13656] | 48 | public double Minimum
|
---|
| 49 | {
|
---|
[4739] | 50 | get { return minimum; }
|
---|
[13656] | 51 | set
|
---|
| 52 | {
|
---|
[4739] | 53 | if (minimum != value) {
|
---|
| 54 | minimum = value;
|
---|
| 55 | if (minimum >= maximum) Maximum = minimum + 1.0;
|
---|
| 56 | OnMinimumChanged();
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 | private double maximum;
|
---|
[13656] | 61 | public double Maximum
|
---|
| 62 | {
|
---|
[4739] | 63 | get { return maximum; }
|
---|
[13656] | 64 | set
|
---|
| 65 | {
|
---|
[4739] | 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")]
|
---|
[13656] | 76 | private string StorableTitle
|
---|
| 77 | {
|
---|
[4739] | 78 | get { return title; }
|
---|
| 79 | set { title = value; }
|
---|
| 80 | }
|
---|
| 81 | [Storable(Name = "Minimum")]
|
---|
[13656] | 82 | private double StorableMinimum
|
---|
| 83 | {
|
---|
[4739] | 84 | get { return minimum; }
|
---|
| 85 | set { minimum = value; }
|
---|
| 86 | }
|
---|
| 87 | [Storable(Name = "Maximum")]
|
---|
[13656] | 88 | private double StorableMaximum
|
---|
| 89 | {
|
---|
[4739] | 90 | get { return maximum; }
|
---|
| 91 | set { maximum = value; }
|
---|
| 92 | }
|
---|
| 93 | #endregion
|
---|
| 94 |
|
---|
[4722] | 95 | [StorableConstructor]
|
---|
| 96 | protected HeatMap(bool deserializing) : base(deserializing) { }
|
---|
[4739] | 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 | }
|
---|
[4703] | 140 |
|
---|
| 141 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
[4722] | 142 | return new HeatMap(this, cloner);
|
---|
[4703] | 143 | }
|
---|
[4715] | 144 |
|
---|
| 145 | public override string ToString() {
|
---|
[4739] | 146 | return Title;
|
---|
[4715] | 147 | }
|
---|
[4739] | 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 | }
|
---|
[4703] | 164 | }
|
---|
| 165 | }
|
---|