Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 2173 was 1872, checked in by epitzer, 16 years ago

Upgrade Charting.Data, Logging, Operators.Programmable, OptimizationFrontend, OffspringSelection, SGA, TestFunctions and ThreadParallelEngine to 3.3 (#603)

File size: 4.6 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="Auxiliary.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 object Clone(IDictionary<Guid, object> clonedObjects) {
92      Linechart clone = (Linechart)base.Clone(clonedObjects);
93      clone.myNumberOfLines = (IntData)Auxiliary.Clone(myNumberOfLines, clonedObjects);
94      clone.myValues = (ItemList)Auxiliary.Clone(Values, clonedObjects);
95      return clone;
96    }
97
98    /// <summary>
99    /// Creates an instance of <see cref="LinechartView"/> to represent the current instance visually.
100    /// </summary>
101    /// <returns>The created view as <see cref="LinechartView"/>.</returns>
102    public override IView CreateView() {
103      return new LinechartView(this);
104    }
105
106    /// <summary>
107    /// Occurs when the number of lines has been changed.
108    /// </summary>
109    public event EventHandler NumberOfLinesChanged;
110    /// <summary>
111    /// Fires a new <c>NumberOfLinesChanged</c> event.
112    /// </summary>
113    protected virtual void OnNumberOfLinesChanged() {
114      if (NumberOfLinesChanged != null)
115        NumberOfLinesChanged(this, new EventArgs());
116    }
117    /// <summary>
118    /// Occurs when the values have been changed.
119    /// </summary>
120    public event EventHandler ValuesChanged;
121    /// <summary>
122    /// Fires a new <c>ValuesChanged</c> event.
123    /// </summary>
124    protected virtual void OnValuesChanged() {
125      if (ValuesChanged != null)
126        ValuesChanged(this, new EventArgs());
127    }
128  }
129}
Note: See TracBrowser for help on using the repository browser.