Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/DataBar.cs @ 14588

Last change on this file since 14588 was 14588, checked in by jzenisek, 7 years ago

#2719 updated databar set and view

File size: 5.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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 System.Drawing;
26using System.Runtime.CompilerServices;
27using HeuristicLab.Collections;
28using HeuristicLab.Common;
29using HeuristicLab.Core;
30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
31
32namespace HeuristicLab.DatastreamAnalysis {
33  /// <summary>
34  /// Bar representation for a single value.
35  /// </summary>
36  [Item("DataBar", "Bar representation for a single value")]
37  [StorableClass]
38  public class DataBar : NamedItem, INotifyPropertyChanged {
39    private double value;
40
41    public double Value {
42      get { return value; }
43      set {
44
45        if (this.value != value) {
46          this.value = value;
47          OnValuePropertyChanged("Value");
48        }
49      }
50    }
51
52    private double threshold;
53
54    public double Threshold {
55      get { return threshold; }
56      set {
57        if (this.value != value) {
58          this.value = value;
59          OnThresholdPropertyChanged("Threshold");
60        }
61      }
62    }
63
64    #region Persistence Properties
65    [Storable(Name = "Value")]
66    private double StorableValue {
67      get { return value; }
68      set { this.value = value; }
69    }
70    [Storable(Name = "Threshold")]
71    private double StorableThreshold {
72      get { return threshold; }
73      set { this.threshold = value; }
74    }
75    #endregion
76
77    #region Visual Properties
78    private Color barColor;
79    public Color BarColor
80    {
81      get { return barColor; }
82      set
83      {
84        if (barColor != value) {
85          barColor = value;
86          OnValuePropertyChanged("BarColor");
87        }
88      }
89    }
90
91    private Color thresholdColor;
92    public Color ThresholdColor
93    {
94      get { return thresholdColor; }
95      set
96      {
97        if (thresholdColor != value) {
98          thresholdColor = value;
99          OnThresholdPropertyChanged("ThresholdColor");
100        }
101      }
102    }
103    #endregion
104
105    #region constructors, cloner ...
106    [StorableConstructor]
107    protected DataBar(bool deserializing) : base(deserializing) { }
108
109    protected DataBar(DataBar original, Cloner cloner) : base(original, cloner) {
110      this.value = original.value;
111      this.threshold = original.threshold;
112      this.barColor = original.barColor;
113      this.thresholdColor = original.thresholdColor;
114    }
115
116    public DataBar() : this("DataBar") {
117      barColor = Color.Empty;
118      thresholdColor = Color.Red;
119    }
120
121    public DataBar(string name) : base(name) {
122      if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
123      barColor = Color.Empty;
124      thresholdColor = Color.Red;
125    }
126
127    public DataBar(string name, double threshold) : base(name) {
128      if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
129      this.threshold = threshold;
130      barColor = Color.Empty;
131      thresholdColor = Color.Red;
132    }
133
134    public DataBar(string name, string description) : base(name, description) {
135      if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
136      barColor = Color.Empty;
137      thresholdColor = Color.Red;
138    }
139
140    public override IDeepCloneable Clone(Cloner cloner) {
141      return new DataBar(this, cloner);
142    }
143    #endregion
144
145    protected override void OnNameChanged() {
146      base.OnNameChanged();
147    }
148
149    public event PropertyChangedEventHandler PropertyChanged;
150    public event PropertyChangedEventHandler ValuePropertyChanged;
151    public event PropertyChangedEventHandler ThresholdPropertyChanged;
152
153    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) {
154      PropertyChangedEventHandler handler = PropertyChanged;
155      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
156    }
157
158    protected virtual void OnValuePropertyChanged([CallerMemberName] string propertyName = null) {
159      PropertyChangedEventHandler handler = ValuePropertyChanged;
160      if(handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
161    }
162
163    protected virtual void OnThresholdPropertyChanged([CallerMemberName] string propertyName = null) {
164      PropertyChangedEventHandler handler = ThresholdPropertyChanged;
165      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
166    }
167  }
168}
Note: See TracBrowser for help on using the repository browser.