Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Logging/3.3/Linechart.cs @ 3021

Last change on this file since 3021 was 2526, checked in by swagner, 15 years ago

Refactored cloning (#806)

File size: 4.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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 System.Collections.Generic;
24using System.Text;
25using System.Xml;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Logging {
31  /// <summary>
32  /// Class to represent a Linechart.
33  /// </summary>
34  public class Linechart : ItemBase, IVisualizationItem {
35    [Storable]
36    private IntData myNumberOfLines;
37    /// <summary>
38    /// Gets or sets the number of lines of the current instance.
39    /// </summary>
40    /// <remarks>Calls <see cref="OnNumberOfLinesChanged"/> in the setter.</remarks>
41    public int NumberOfLines {
42      get { return myNumberOfLines.Data; }
43      set {
44        if (value != myNumberOfLines.Data) {
45          myNumberOfLines.Data = value;
46          OnNumberOfLinesChanged();
47        }
48      }
49    }
50    [Storable]
51    private ItemList myValues;
52    /// <summary>
53    /// Gets or sets the values of the current instance.
54    /// </summary>
55    /// <remarks>Calls <see cref="OnValuesChanged"/> in the setter.</remarks>
56    public ItemList Values {
57      get { return myValues; }
58      set {
59        if (value != myValues) {
60          myValues = value;
61          OnValuesChanged();
62        }
63      }
64    }
65
66
67    /// <summary>
68    /// Initializes a new instance of <see cref="Linechart"/>.
69    /// </summary>
70    public Linechart() {
71      myNumberOfLines = new IntData(0);
72    }
73    /// <summary>
74    /// Initializes a new instance of <see cref="Linechart"/> with the given <paramref name="numberOfLines"/>
75    /// and the given <paramref name="values"/>.
76    /// </summary>
77    /// <param name="numberOfLines">The number of lines with which to initialize the current instance.</param>
78    /// <param name="values">The values with which to initialize the current instance.</param>
79    public Linechart(int numberOfLines, ItemList values) {
80      myNumberOfLines = new IntData(numberOfLines);
81      myValues = values;
82    }
83
84    /// <summary>
85    /// Clones the current instance (deep clone).
86    /// </summary>
87    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
88    /// <see cref="Auxiliary"/>.</remarks>
89    /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
90    /// <returns>The cloned object as <see cref="Linechart"/>.</returns>
91    public override IItem Clone(ICloner cloner) {
92      Linechart clone = (Linechart)base.Clone(cloner);
93      clone.myNumberOfLines = (IntData)cloner.Clone(myNumberOfLines);
94      clone.myValues = (ItemList)cloner.Clone(Values);
95      return clone;
96    }
97
98    /// <summary>
99    /// Occurs when the number of lines has been changed.
100    /// </summary>
101    public event EventHandler NumberOfLinesChanged;
102    /// <summary>
103    /// Fires a new <c>NumberOfLinesChanged</c> event.
104    /// </summary>
105    protected virtual void OnNumberOfLinesChanged() {
106      if (NumberOfLinesChanged != null)
107        NumberOfLinesChanged(this, new EventArgs());
108    }
109    /// <summary>
110    /// Occurs when the values have been changed.
111    /// </summary>
112    public event EventHandler ValuesChanged;
113    /// <summary>
114    /// Fires a new <c>ValuesChanged</c> event.
115    /// </summary>
116    protected virtual void OnValuesChanged() {
117      if (ValuesChanged != null)
118        ValuesChanged(this, new EventArgs());
119    }
120  }
121}
Note: See TracBrowser for help on using the repository browser.