Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2719_HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis/3.4/DataBar.cs @ 16755

Last change on this file since 16755 was 14710, checked in by jzenisek, 8 years ago

#2719 implemented ensemble model rating by introducing the new type RatedEnsembleModel; introduced performance indicator calculation in results;

File size: 6.1 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.Data;
31using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
32
33namespace HeuristicLab.DatastreamAnalysis {
34  /// <summary>
35  /// Bar representation for a single value.
36  /// </summary>
37  [Item("DataBar", "Bar representation for a single value")]
38  [StorableClass]
39  public class DataBar : NamedItem, INotifyPropertyChanged {
40    private double value;
41    public static Color DefaultBarColor = Color.FromArgb(65, 140, 240);
42
43    public double Value {
44      get { return value; }
45      set {
46
47        if (this.value != value) {
48          this.value = value;
49          OnValuePropertyChanged("Value");
50        }
51      }
52    }
53
54    private double thresholdLowerBound;
55
56    public double ThresholdLowerBound {
57      get { return thresholdLowerBound; }
58      set {
59        if (this.value != value) {
60          this.value = value;
61          OnThresholdPropertyChanged("Threshold");
62        }
63      }
64    }
65
66    private double thresholdUpperBound;
67
68    public double ThresholdUpperBound
69    {
70      get { return thresholdUpperBound; }
71      set
72      {
73        if (this.value != value) {
74          this.value = value;
75          OnThresholdPropertyChanged("Threshold");
76        }
77      }
78    }
79
80    #region Persistence Properties
81    [Storable(Name = "Value")]
82    private double StorableValue {
83      get { return value; }
84      set { this.value = value; }
85    }
86    [Storable(Name = "ThresholdLowerBound")]
87    private double StorableThresholdLowerBound {
88      get { return thresholdLowerBound; }
89      set { this.thresholdLowerBound = value; }
90    }
91    [Storable(Name = "ThresholdUpperBound")]
92    private double StorableThresholdUpperBound
93    {
94      get { return thresholdUpperBound; }
95      set { this.thresholdUpperBound = value; }
96    }
97    #endregion
98
99    #region Visual Properties
100    private Color barColor;
101    public Color BarColor
102    {
103      get { return barColor; }
104      set
105      {
106        if (barColor != value) {
107          barColor = value;
108          OnValuePropertyChanged("BarColor");
109        }
110      }
111    }
112
113    private Color thresholdColor;
114    public Color ThresholdColor
115    {
116      get { return thresholdColor; }
117      set
118      {
119        if (thresholdColor != value) {
120          thresholdColor = value;
121          OnThresholdPropertyChanged("ThresholdColor");
122        }
123      }
124    }
125    #endregion
126
127    #region constructors, cloner ...
128    [StorableConstructor]
129    protected DataBar(bool deserializing) : base(deserializing) { }
130
131    protected DataBar(DataBar original, Cloner cloner) : base(original, cloner) {
132      this.value = original.value;
133      this.thresholdLowerBound = original.thresholdLowerBound;
134      this.barColor = original.barColor;
135      this.thresholdColor = original.thresholdColor;
136    }
137
138    public DataBar() : this("DataBar") {
139      barColor = DefaultBarColor;
140      thresholdColor = Color.Black;
141    }
142
143    public DataBar(string name) : base(name) {
144      if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
145      barColor = DefaultBarColor;
146      thresholdColor = Color.Black;
147    }
148
149    public DataBar(string name, double thresholdLowerBound, double thresholdUpperBound) : base(name) {
150      if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
151      this.thresholdLowerBound = thresholdLowerBound;
152      this.thresholdUpperBound = thresholdUpperBound;
153      barColor = DefaultBarColor;
154      thresholdColor = Color.Black;
155    }
156
157    public DataBar(string name, string description) : base(name, description) {
158      if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
159      barColor = DefaultBarColor;
160      thresholdColor = Color.Black;
161    }
162
163    public override IDeepCloneable Clone(Cloner cloner) {
164      return new DataBar(this, cloner);
165    }
166    #endregion
167
168    protected override void OnNameChanged() {
169      base.OnNameChanged();
170    }
171
172    public event PropertyChangedEventHandler PropertyChanged;
173    public event PropertyChangedEventHandler ValuePropertyChanged;
174    public event PropertyChangedEventHandler ThresholdPropertyChanged;
175
176    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) {
177      PropertyChangedEventHandler handler = PropertyChanged;
178      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
179    }
180
181    protected virtual void OnValuePropertyChanged([CallerMemberName] string propertyName = null) {
182      PropertyChangedEventHandler handler = ValuePropertyChanged;
183      if(handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
184    }
185
186    protected virtual void OnThresholdPropertyChanged([CallerMemberName] string propertyName = null) {
187      PropertyChangedEventHandler handler = ThresholdPropertyChanged;
188      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
189    }
190  }
191}
Note: See TracBrowser for help on using the repository browser.