#region License Information /* HeuristicLab * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System.Collections.Generic; using System.Drawing; using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Common.Resources; namespace HeuristicLab.Analysis.FitnessLandscape { [Item("HeatMap", "A heat map of 2D data")] [StorableClass] public class HeatMap : NamedItem { public static new Image StaticItemImage { get { return VSImageLibrary.Image; } } #region Persistence private IEnumerable GetPointCoordinates() { foreach (var p in points) { yield return p.X; yield return p.Y; } } [Storable(Name = "Points")] private List PointsPersistence { get { return new List(GetPointCoordinates()); } set { points = new List(); var iter = value.GetEnumerator(); while (iter.MoveNext()) { float x = iter.Current; iter.MoveNext(); float y = iter.Current; points.Add(new PointF(x, y)); } } } #endregion private List points; public IEnumerable Points { get { return points; } } public void Add(IEnumerable points) { this.points.AddRange(points); } [StorableConstructor] protected HeatMap(bool deserializing) : base(deserializing) { } protected HeatMap(HeatMap original, Cloner cloner) : base(original, cloner) { points = new List(original.points.Select(p => new PointF(p.X, p.Y))); } public HeatMap() { points = new List(); Name = "Heat Map"; } public override IDeepCloneable Clone(Cloner cloner) { return new HeatMap(this, cloner); } internal void Clear() { var oldPoints = points; points = new List(); } } }