[2] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Text;
|
---|
| 25 | using System.Xml;
|
---|
| 26 | using HeuristicLab.Core;
|
---|
| 27 | using HeuristicLab.Data;
|
---|
[1872] | 28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
[2] | 29 |
|
---|
| 30 | namespace HeuristicLab.Logging {
|
---|
[1167] | 31 | /// <summary>
|
---|
| 32 | /// Class to represent a Linechart.
|
---|
| 33 | /// </summary>
|
---|
[2] | 34 | public class Linechart : ItemBase, IVisualizationItem {
|
---|
[1872] | 35 | [Storable]
|
---|
[2] | 36 | private IntData myNumberOfLines;
|
---|
[1167] | 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>
|
---|
[2] | 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 | }
|
---|
[1872] | 50 | [Storable]
|
---|
[2] | 51 | private ItemList myValues;
|
---|
[1167] | 52 | /// <summary>
|
---|
| 53 | /// Gets or sets the values of the current instance.
|
---|
| 54 | /// </summary>
|
---|
| 55 | /// <remarks>Calls <see cref="OnValuesChanged"/> in the setter.</remarks>
|
---|
[2] | 56 | public ItemList Values {
|
---|
| 57 | get { return myValues; }
|
---|
| 58 | set {
|
---|
| 59 | if (value != myValues) {
|
---|
| 60 | myValues = value;
|
---|
| 61 | OnValuesChanged();
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 |
|
---|
[1167] | 67 | /// <summary>
|
---|
| 68 | /// Initializes a new instance of <see cref="Linechart"/>.
|
---|
| 69 | /// </summary>
|
---|
[2] | 70 | public Linechart() {
|
---|
| 71 | myNumberOfLines = new IntData(0);
|
---|
| 72 | }
|
---|
[1167] | 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>
|
---|
[2] | 79 | public Linechart(int numberOfLines, ItemList values) {
|
---|
| 80 | myNumberOfLines = new IntData(numberOfLines);
|
---|
| 81 | myValues = values;
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[1167] | 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>
|
---|
[2] | 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 |
|
---|
[1167] | 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>
|
---|
[2] | 102 | public override IView CreateView() {
|
---|
| 103 | return new LinechartView(this);
|
---|
| 104 | }
|
---|
| 105 |
|
---|
[1167] | 106 | /// <summary>
|
---|
| 107 | /// Occurs when the number of lines has been changed.
|
---|
| 108 | /// </summary>
|
---|
[2] | 109 | public event EventHandler NumberOfLinesChanged;
|
---|
[1167] | 110 | /// <summary>
|
---|
| 111 | /// Fires a new <c>NumberOfLinesChanged</c> event.
|
---|
| 112 | /// </summary>
|
---|
[2] | 113 | protected virtual void OnNumberOfLinesChanged() {
|
---|
| 114 | if (NumberOfLinesChanged != null)
|
---|
| 115 | NumberOfLinesChanged(this, new EventArgs());
|
---|
| 116 | }
|
---|
[1167] | 117 | /// <summary>
|
---|
| 118 | /// Occurs when the values have been changed.
|
---|
| 119 | /// </summary>
|
---|
[2] | 120 | public event EventHandler ValuesChanged;
|
---|
[1167] | 121 | /// <summary>
|
---|
| 122 | /// Fires a new <c>ValuesChanged</c> event.
|
---|
| 123 | /// </summary>
|
---|
[2] | 124 | protected virtual void OnValuesChanged() {
|
---|
| 125 | if (ValuesChanged != null)
|
---|
| 126 | ValuesChanged(this, new EventArgs());
|
---|
| 127 | }
|
---|
| 128 | }
|
---|
| 129 | }
|
---|