Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/08/10 03:00:46 (13 years ago)
Author:
swagner
Message:

Worked on population diversity analysis (#1188)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Analysis/3.3/HeatMap.cs

    r4722 r4739  
    2020#endregion
    2121
    22 using System.Collections.Generic;
     22using System;
    2323using System.Drawing;
    2424using HeuristicLab.Common;
     
    3535    }
    3636
     37    private string title;
     38    public string Title {
     39      get { return title; }
     40      set {
     41        if (!(title.Equals(value) || (value == null) && (title == string.Empty))) {
     42          title = value == null ? string.Empty : value;
     43          OnTitleChanged();
     44        }
     45      }
     46    }
     47    private double minimum;
     48    public double Minimum {
     49      get { return minimum; }
     50      set {
     51        if (minimum != value) {
     52          minimum = value;
     53          if (minimum >= maximum) Maximum = minimum + 1.0;
     54          OnMinimumChanged();
     55        }
     56      }
     57    }
     58    private double maximum;
     59    public double Maximum {
     60      get { return maximum; }
     61      set {
     62        if (maximum != value) {
     63          maximum = value;
     64          if (maximum <= minimum) Minimum = maximum - 1.0;
     65          OnMaximumChanged();
     66        }
     67      }
     68    }
     69
     70    #region Storable Properties
     71    [Storable(Name = "Title")]
     72    private string StorableTitle {
     73      get { return title; }
     74      set { title = value; }
     75    }
     76    [Storable(Name = "Minimum")]
     77    private double StorableMinimum {
     78      get { return minimum; }
     79      set { minimum = value; }
     80    }
     81    [Storable(Name = "Maximum")]
     82    private double StorableMaximum {
     83      get { return maximum; }
     84      set { maximum = value; }
     85    }
     86    #endregion
     87
    3788    [StorableConstructor]
    3889    protected HeatMap(bool deserializing) : base(deserializing) { }
    39     protected HeatMap(HeatMap original, Cloner cloner) : base(original, cloner) { }
    40     public HeatMap() : base() { }
    41     public HeatMap(int rows, int columns) : base(rows, columns) { }
    42     public HeatMap(int rows, int columns, IEnumerable<string> columnNames) : base(rows, columns, columnNames) { }
    43     public HeatMap(int rows, int columns, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(rows, columns, columnNames, rowNames) { }
    44     public HeatMap(double[,] elements) : base(elements) { }
    45     public HeatMap(double[,] elements, IEnumerable<string> columnNames) : base(elements, columnNames) { }
    46     public HeatMap(double[,] elements, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(elements, columnNames, rowNames) { }
     90    protected HeatMap(HeatMap original, Cloner cloner)
     91      : base(original, cloner) {
     92      this.title = original.title;
     93      this.minimum = original.minimum;
     94      this.maximum = original.maximum;
     95    }
     96    public HeatMap()
     97      : base() {
     98      this.title = "Heat Map";
     99      this.minimum = 0.0;
     100      this.maximum = 1.0;
     101    }
     102    public HeatMap(int rows, int columns)
     103      : base(rows, columns) {
     104      this.title = "Heat Map";
     105      this.minimum = 0.0;
     106      this.maximum = 1.0;
     107    }
     108    public HeatMap(int rows, int columns, string title)
     109      : base(rows, columns) {
     110      this.title = title == null ? string.Empty : title;
     111      this.minimum = 0.0;
     112      this.maximum = 1.0;
     113    }
     114    public HeatMap(double[,] elements)
     115      : base(elements) {
     116      this.title = "Heat Map";
     117      this.minimum = 0.0;
     118      this.maximum = 1.0;
     119    }
     120    public HeatMap(double[,] elements, string title)
     121      : base(elements) {
     122      this.title = title == null ? string.Empty : title;
     123      this.minimum = 0.0;
     124      this.maximum = 1.0;
     125    }
     126    public HeatMap(double[,] elements, string title, double minimum, double maximum)
     127      : base(elements) {
     128      this.title = title == null ? string.Empty : title;
     129      if (minimum >= maximum) throw new ArgumentException("Minimum is larger than or equal to maximum");
     130      this.minimum = minimum;
     131      this.maximum = maximum;
     132    }
    47133
    48134    public override IDeepCloneable Clone(Cloner cloner) {
     
    51137
    52138    public override string ToString() {
    53       return ItemName;
     139      return Title;
     140    }
     141
     142    public event EventHandler TitleChanged;
     143    protected virtual void OnTitleChanged() {
     144      var handler = TitleChanged;
     145      if (handler != null) handler(this, EventArgs.Empty);
     146    }
     147    public event EventHandler MinimumChanged;
     148    protected virtual void OnMinimumChanged() {
     149      var handler = MinimumChanged;
     150      if (handler != null) handler(this, EventArgs.Empty);
     151    }
     152    public event EventHandler MaximumChanged;
     153    protected virtual void OnMaximumChanged() {
     154      var handler = MaximumChanged;
     155      if (handler != null) handler(this, EventArgs.Empty);
    54156    }
    55157  }
Note: See TracChangeset for help on using the changeset viewer.