[671] | 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;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.Logging {
|
---|
[1167] | 30 | /// <summary>
|
---|
| 31 | /// Class for point xy charts.
|
---|
| 32 | /// </summary>
|
---|
[671] | 33 | public class PointXYChart : ItemBase, IVisualizationItem {
|
---|
[677] | 34 | private ItemList myValues;
|
---|
[1167] | 35 | /// <summary>
|
---|
| 36 | /// Gets or sets the values of the current instance.
|
---|
| 37 | /// </summary>
|
---|
| 38 | /// <remarks>Calls <see cref="OnValuesChanged"/> in the setter.</remarks>
|
---|
[677] | 39 | public ItemList Values {
|
---|
[671] | 40 | get { return myValues; }
|
---|
| 41 | set {
|
---|
| 42 | if (value != myValues) {
|
---|
| 43 | myValues = value;
|
---|
| 44 | OnValuesChanged();
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | private BoolData myConnectDots;
|
---|
[1167] | 50 | /// <summary>
|
---|
| 51 | /// Gets or sets the flag whether the dots should be connected or not.
|
---|
| 52 | /// </summary>
|
---|
| 53 | /// <remarks>Calls <see cref="OnConnectDotsChanged"/> in the setter.</remarks>
|
---|
[671] | 54 | public BoolData ConnectDots {
|
---|
| 55 | get { return myConnectDots; }
|
---|
| 56 | set {
|
---|
| 57 | if (value != myConnectDots) {
|
---|
| 58 | myConnectDots = value;
|
---|
| 59 | OnConnectDotsChanged();
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 |
|
---|
[1167] | 65 | /// <summary>
|
---|
| 66 | /// Initializes a new instance of <see cref="PointXYChart"/> with the <c>ConnectDots</c> flag set to
|
---|
| 67 | /// <c>true</c>.
|
---|
| 68 | /// </summary>
|
---|
[671] | 69 | public PointXYChart() {
|
---|
| 70 | myConnectDots = new BoolData(true);
|
---|
| 71 | }
|
---|
[1167] | 72 | /// <summary>
|
---|
| 73 | /// Initializes a new instance of <see cref="PointXYChart"/> with the given <paramref name="connectDots"/>
|
---|
| 74 | /// flag and the specified <paramref name="values"/>.
|
---|
| 75 | /// </summary>
|
---|
| 76 | /// <param name="connectDots">The flag whether the dots should be connected or not.</param>
|
---|
| 77 | /// <param name="values">The values with which the current instance should be initialized.</param>
|
---|
[677] | 78 | public PointXYChart(bool connectDots,ItemList values) {
|
---|
[671] | 79 | myConnectDots = new BoolData(connectDots);
|
---|
| 80 | myValues = values;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[1167] | 83 | /// <summary>
|
---|
| 84 | /// Clones the current instance (deep clone).
|
---|
| 85 | /// </summary>
|
---|
| 86 | /// <remarks>Deep clone through <see cref="Auxiliary.Clone"/> method of helper class
|
---|
| 87 | /// <see cref="Auxiliary"/>.</remarks>
|
---|
| 88 | /// <param name="clonedObjects">Dictionary of all already clone objects. (Needed to avoid cycles.)</param>
|
---|
| 89 | /// <returns>The cloned object as <see cref="PointXYChart"/>.</returns>
|
---|
[671] | 90 | public override object Clone(IDictionary<Guid, object> clonedObjects) {
|
---|
| 91 | PointXYChart clone = (PointXYChart)base.Clone(clonedObjects);
|
---|
[677] | 92 | clone.myValues = (ItemList)Auxiliary.Clone(Values, clonedObjects);
|
---|
[671] | 93 | return clone;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
[1167] | 96 | /// <summary>
|
---|
| 97 | /// Creates a new instance of <see cref="PointXYChartView"/> to represent the current instance visually.
|
---|
| 98 | /// </summary>
|
---|
| 99 | /// <returns>The created view as <see cref="PointXYChartView"/>.</returns>
|
---|
[671] | 100 | public override IView CreateView() {
|
---|
| 101 | return new PointXYChartView(this);
|
---|
| 102 | }
|
---|
| 103 |
|
---|
[1167] | 104 | /// <summary>
|
---|
| 105 | /// Occurs when the values of the current instance have been changed.
|
---|
| 106 | /// </summary>
|
---|
[671] | 107 | public event EventHandler ValuesChanged;
|
---|
[1167] | 108 | /// <summary>
|
---|
| 109 | /// Fires a <c>ValuesChanged</c> event.
|
---|
| 110 | /// </summary>
|
---|
[671] | 111 | protected virtual void OnValuesChanged() {
|
---|
| 112 | if (ValuesChanged != null)
|
---|
| 113 | ValuesChanged(this, new EventArgs());
|
---|
| 114 | }
|
---|
[1167] | 115 | /// <summary>
|
---|
| 116 | /// Occurs when the boolean flag has been changed.
|
---|
| 117 | /// </summary>
|
---|
[671] | 118 | public event EventHandler ConnectDotsChanged;
|
---|
[1167] | 119 | /// <summary>
|
---|
| 120 | /// Fires a <c>ConnectDotsChanged</c> event.
|
---|
| 121 | /// </summary>
|
---|
[671] | 122 | protected virtual void OnConnectDotsChanged() {
|
---|
| 123 | if (ConnectDotsChanged != null)
|
---|
| 124 | ConnectDotsChanged(this, new EventArgs());
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | #region Persistence Methods
|
---|
[1167] | 128 | /// <summary>
|
---|
| 129 | /// Saves the current instance as <see cref="XmlNode"/> in the specified <paramref name="document"/>.
|
---|
| 130 | /// </summary>
|
---|
| 131 | /// <remarks>The ConnectDots flag and the values of the current instance are saved as child nodes
|
---|
| 132 | /// with tag names <c>ConnectDots</c> and <c>Values</c> respectively.</remarks>
|
---|
| 133 | /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
|
---|
| 134 | /// <param name="document">The <see cref="XmlDocument"/> where to save the data.</param>
|
---|
| 135 | /// <param name="persistedObjects">The dictionary of all already persisted objects.
|
---|
| 136 | /// (Needed to avoid cycles.)</param>
|
---|
| 137 | /// <returns>The saved <see cref="XmlNode"/>.</returns>
|
---|
[671] | 138 | public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
|
---|
| 139 | XmlNode node = base.GetXmlNode(name, document, persistedObjects);
|
---|
| 140 | node.AppendChild(PersistenceManager.Persist("ConnectDots",ConnectDots,document,persistedObjects));
|
---|
| 141 | node.AppendChild(PersistenceManager.Persist("Values", Values, document, persistedObjects));
|
---|
| 142 | return node;
|
---|
| 143 | }
|
---|
[1167] | 144 | /// <summary>
|
---|
| 145 | /// Loads the persisted item from the specified <paramref name="node"/>.
|
---|
| 146 | /// </summary>
|
---|
| 147 | /// <remarks>Has to be saved in a special way, see <see cref="GetXmlNode"/> for further information.</remarks>
|
---|
| 148 | /// <param name="node">The <see cref="XmlNode"/> where the PointXYChart is saved.</param>
|
---|
| 149 | /// <param name="restoredObjects">The dictionary of all already restored objects.
|
---|
| 150 | /// (Needed to avoid cycles.)</param>
|
---|
[671] | 151 | public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
|
---|
| 152 | base.Populate(node, restoredObjects);
|
---|
| 153 | myConnectDots = (BoolData)PersistenceManager.Restore(node.SelectSingleNode("ConnectDots"), restoredObjects);
|
---|
[677] | 154 | myValues = (ItemList)PersistenceManager.Restore(node.SelectSingleNode("Values"), restoredObjects);
|
---|
[671] | 155 | }
|
---|
| 156 | #endregion
|
---|
| 157 | }
|
---|
| 158 | }
|
---|