[14588] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.ComponentModel;
|
---|
| 25 | using System.Drawing;
|
---|
| 26 | using System.Runtime.CompilerServices;
|
---|
| 27 | using HeuristicLab.Collections;
|
---|
| 28 | using HeuristicLab.Common;
|
---|
| 29 | using HeuristicLab.Core;
|
---|
[14710] | 30 | using HeuristicLab.Data;
|
---|
[14588] | 31 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 32 |
|
---|
| 33 | namespace 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;
|
---|
[14710] | 41 | public static Color DefaultBarColor = Color.FromArgb(65, 140, 240);
|
---|
[14588] | 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 |
|
---|
[14710] | 54 | private double thresholdLowerBound;
|
---|
[14588] | 55 |
|
---|
[14710] | 56 | public double ThresholdLowerBound {
|
---|
| 57 | get { return thresholdLowerBound; }
|
---|
[14588] | 58 | set {
|
---|
| 59 | if (this.value != value) {
|
---|
| 60 | this.value = value;
|
---|
| 61 | OnThresholdPropertyChanged("Threshold");
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[14710] | 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 |
|
---|
[14588] | 80 | #region Persistence Properties
|
---|
| 81 | [Storable(Name = "Value")]
|
---|
| 82 | private double StorableValue {
|
---|
| 83 | get { return value; }
|
---|
| 84 | set { this.value = value; }
|
---|
| 85 | }
|
---|
[14710] | 86 | [Storable(Name = "ThresholdLowerBound")]
|
---|
| 87 | private double StorableThresholdLowerBound {
|
---|
| 88 | get { return thresholdLowerBound; }
|
---|
| 89 | set { this.thresholdLowerBound = value; }
|
---|
[14588] | 90 | }
|
---|
[14710] | 91 | [Storable(Name = "ThresholdUpperBound")]
|
---|
| 92 | private double StorableThresholdUpperBound
|
---|
| 93 | {
|
---|
| 94 | get { return thresholdUpperBound; }
|
---|
| 95 | set { this.thresholdUpperBound = value; }
|
---|
| 96 | }
|
---|
[14588] | 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;
|
---|
[14710] | 133 | this.thresholdLowerBound = original.thresholdLowerBound;
|
---|
[14588] | 134 | this.barColor = original.barColor;
|
---|
| 135 | this.thresholdColor = original.thresholdColor;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | public DataBar() : this("DataBar") {
|
---|
[14710] | 139 | barColor = DefaultBarColor;
|
---|
| 140 | thresholdColor = Color.Black;
|
---|
[14588] | 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);
|
---|
[14710] | 145 | barColor = DefaultBarColor;
|
---|
| 146 | thresholdColor = Color.Black;
|
---|
[14588] | 147 | }
|
---|
| 148 |
|
---|
[14710] | 149 | public DataBar(string name, double thresholdLowerBound, double thresholdUpperBound) : base(name) {
|
---|
[14588] | 150 | if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
|
---|
[14710] | 151 | this.thresholdLowerBound = thresholdLowerBound;
|
---|
| 152 | this.thresholdUpperBound = thresholdUpperBound;
|
---|
| 153 | barColor = DefaultBarColor;
|
---|
| 154 | thresholdColor = Color.Black;
|
---|
[14588] | 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);
|
---|
[14710] | 159 | barColor = DefaultBarColor;
|
---|
| 160 | thresholdColor = Color.Black;
|
---|
[14588] | 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 | }
|
---|