Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/RangeDataRow.cs @ 18242

Last change on this file since 18242 was 17980, checked in by jzenisek, 3 years ago

#2719 merged head of HeuristicLab.Problems.DataAnalysis into branch; added several minor items

File size: 4.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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.ComponentModel;
25using HeuristicLab.Collections;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Analysis;
29using HEAL.Attic;
30
31namespace HeuristicLab.DatastreamAnalysis {
32  /// <summary>
33  /// A row of data ranges.
34  /// </summary>
35  [Item("RangeDataRow", "A DataRow with double tuples")]
36  [StorableType("38367CFE-AEE7-44C2-BF10-CB42F25BB533")]
37  public class RangeDataRow : NamedItem {
38    private DataRowVisualProperties visualProperties;
39    public DataRowVisualProperties VisualProperties {
40      get { return visualProperties; }
41      set {
42        if (visualProperties != value) {
43          if (value == null) throw new ArgumentNullException("VisualProperties");
44          if (visualProperties != null) visualProperties.PropertyChanged -= new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
45          visualProperties = value;
46          visualProperties.PropertyChanged += new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
47          OnVisualPropertiesChanged();
48        }
49      }
50    }
51    private ObservableList<Tuple<double,double>> values;
52    public ObservableList<Tuple<double, double>> Values {
53      get { return values; }
54    }
55
56    #region Persistence Properties
57    [Storable(Name = "VisualProperties")]
58    private DataRowVisualProperties StorableVisualProperties {
59      get { return visualProperties; }
60      set {
61        visualProperties = value;
62        visualProperties.PropertyChanged += new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
63      }
64    }
65    [Storable(Name ="values")]
66    private IEnumerable<Tuple<double, double>> StorableValues {
67      get { return values; }
68      set { values = new ObservableList<Tuple<double, double>>(value); }
69    }
70    #endregion
71
72    [StorableConstructor]
73    protected RangeDataRow(StorableConstructorFlag _) : base(_) { }
74    protected RangeDataRow(RangeDataRow original, Cloner cloner)
75      : base(original, cloner) {
76      this.VisualProperties = (DataRowVisualProperties)cloner.Clone(original.visualProperties);
77      this.values = new ObservableList<Tuple<double, double>>(original.values);
78    }
79    public RangeDataRow() : this("RangeDataRow") { }
80    public RangeDataRow(string name)
81      : base(name) {
82      if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a RangeDataRow cannot be empty", name);
83      VisualProperties = new DataRowVisualProperties(name);
84      values = new ObservableList<Tuple<double,double>>();
85    }
86    public RangeDataRow(string name, string description)
87      : base(name, description) {
88      if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a RangeDataRow cannot be empty", name);
89      VisualProperties = new DataRowVisualProperties(name);
90      values = new ObservableList<Tuple<double, double>>();
91    }
92    public RangeDataRow(string name, string description, IEnumerable<Tuple<double, double>> values)
93      : base(name, description) {
94      if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a RangeDataRow cannot be empty", name);
95      VisualProperties = new DataRowVisualProperties(name);
96      this.values = new ObservableList<Tuple<double, double>>(values);
97    }
98
99    public override IDeepCloneable Clone(Cloner cloner) {
100      return new RangeDataRow(this, cloner);
101    }
102
103    public event EventHandler VisualPropertiesChanged;
104    protected virtual void OnVisualPropertiesChanged() {
105      EventHandler handler = VisualPropertiesChanged;
106      if (handler != null) handler(this, EventArgs.Empty);
107    }
108
109    private void VisualProperties_PropertyChanged(object sender, PropertyChangedEventArgs e) {
110      OnVisualPropertiesChanged();
111    }
112    protected override void OnNameChanged() {
113      base.OnNameChanged();
114      VisualProperties.DisplayName = Name;
115    }
116  }
117}
Note: See TracBrowser for help on using the repository browser.