Free cookie consent management tool by TermsFeed Policy Generator

source: branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/FDC/HeatMap.cs @ 7128

Last change on this file since 7128 was 7128, checked in by epitzer, 12 years ago

#1696 Integrate fitness landscape analysis plugins from Heureka! repository.

File size: 2.7 KB
RevLine 
[7128]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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.Collections.Generic;
23using System.Drawing;
24using System.Linq;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Analysis.FitnessLandscape {
30
31  [Item("HeatMap", "A heat map of 2D data")]
32  [StorableClass]
33  public class HeatMap : NamedItem {
34
35    public override Image ItemImage {
36      get { return HeuristicLab.Common.Resources.VSImageLibrary.Image; }
37    }
38
39    #region Persistence
40
41    private IEnumerable<float> GetPointCoordinates() {
42      foreach (var p in points) {
43        yield return p.X;
44        yield return p.Y;
45      }
46    }
47
48    [Storable(Name = "Points")]
49    private List<float> PointsPersistence {
50      get {
51        return new List<float>(GetPointCoordinates());
52      }
53      set {
54        points = new List<PointF>();
55        var iter = value.GetEnumerator();
56        while (iter.MoveNext()) {
57          float x = iter.Current;
58          iter.MoveNext();
59          float y = iter.Current;
60          points.Add(new PointF(x, y));
61        }
62      }
63    }
64    #endregion
65
66    private List<PointF> points;
67    public IEnumerable<PointF> Points {
68      get { return points; }
69    }
70
71    public void Add(IEnumerable<PointF> points) {
72      this.points.AddRange(points);
73    }
74
75    [StorableConstructor]
76    protected HeatMap(bool deserializing) : base(deserializing) { }
77    protected HeatMap(HeatMap original, Cloner cloner)
78      : base(original, cloner) {
79      points = new List<PointF>(original.points.Select(p => new PointF(p.X, p.Y)));
80    }
81
82
83    public HeatMap() {
84      points = new List<PointF>();
85      Name = "Heat Map";
86    }
87
88    public override IDeepCloneable Clone(Cloner cloner) {
89      return new HeatMap(this, cloner);
90    }
91
92
93    internal void Clear() {
94      var oldPoints = points;
95      points = new List<PointF>();
96    }
97  }
98}
Note: See TracBrowser for help on using the repository browser.