Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Logging/3.3/PointXYChart.cs @ 3155

Last change on this file since 3155 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 for point xy charts.
33  /// </summary>
34  public class PointXYChart : ItemBase, IVisualizationItem {
35    [Storable]
36    private ItemList myValues;
37    /// <summary>
38    /// Gets or sets the values of the current instance.
39    /// </summary>
40    /// <remarks>Calls <see cref="OnValuesChanged"/> in the setter.</remarks>
41    public ItemList Values {
42      get { return myValues; }
43      set {
44        if (value != myValues) {
45          myValues = value;
46          OnValuesChanged();
47        }
48      }
49    }
50
51    [Storable]
52    private BoolData myConnectDots;
53    /// <summary>
54    /// Gets or sets the flag whether the dots should be connected or not.
55    /// </summary>
56    /// <remarks>Calls <see cref="OnConnectDotsChanged"/> in the setter.</remarks>
57    public BoolData ConnectDots {
58      get { return myConnectDots; }
59      set {
60        if (value != myConnectDots) {
61          myConnectDots = value;
62          OnConnectDotsChanged();
63        }
64      }
65    }
66 
67         
68    /// <summary>
69    /// Initializes a new instance of <see cref="PointXYChart"/> with the <c>ConnectDots</c> flag set to
70    /// <c>true</c>.
71    /// </summary>
72    public PointXYChart() {
73      myConnectDots = new BoolData(true);
74    }
75    /// <summary>
76    /// Initializes a new instance of <see cref="PointXYChart"/> with the given <paramref name="connectDots"/>
77    /// flag and the specified <paramref name="values"/>.
78    /// </summary>
79    /// <param name="connectDots">The flag whether the dots should be connected or not.</param>
80    /// <param name="values">The values with which the current instance should be initialized.</param>
81    public PointXYChart(bool connectDots,ItemList values) {
82      myConnectDots = new BoolData(connectDots);
83      myValues = values;
84    }
85
86    /// <summary>
87    /// Clones the current instance (deep clone).
88    /// </summary>
89    /// <remarks>Deep clone through <see cref="cloner.Clone"/> method of helper class
90    /// <see cref="Auxiliary"/>.</remarks>
91    /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
92    /// <returns>The cloned object as <see cref="PointXYChart"/>.</returns>
93    public override IItem Clone(ICloner cloner) {
94      PointXYChart clone = (PointXYChart)base.Clone(cloner);
95      clone.myValues = (ItemList)cloner.Clone(Values);
96      return clone;
97    }
98
99    /// <summary>
100    /// Occurs when the values of the current instance have been changed.
101    /// </summary>
102    public event EventHandler ValuesChanged;
103    /// <summary>
104    /// Fires a <c>ValuesChanged</c> event.
105    /// </summary>
106    protected virtual void OnValuesChanged() {
107      if (ValuesChanged != null)
108        ValuesChanged(this, new EventArgs());
109    }
110    /// <summary>
111    /// Occurs when the boolean flag has been changed.
112    /// </summary>
113    public event EventHandler ConnectDotsChanged;
114    /// <summary>
115    /// Fires a <c>ConnectDotsChanged</c> event.
116    /// </summary>
117    protected virtual void OnConnectDotsChanged() {
118      if (ConnectDotsChanged != null)
119        ConnectDotsChanged(this, new EventArgs());
120    }
121  }
122}
Note: See TracBrowser for help on using the repository browser.