#region License Information
/* HeuristicLab
* Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using HeuristicLab.Collections;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.DatastreamAnalysis {
///
/// Bar representation for a single value.
///
[Item("DataBar", "Bar representation for a single value")]
[StorableClass]
public class DataBar : NamedItem, INotifyPropertyChanged {
private double value;
public static Color DefaultBarColor = Color.FromArgb(65, 140, 240);
public double Value {
get { return value; }
set {
if (this.value != value) {
this.value = value;
OnValuePropertyChanged("Value");
}
}
}
private double thresholdLowerBound;
public double ThresholdLowerBound {
get { return thresholdLowerBound; }
set {
if (this.value != value) {
this.value = value;
OnThresholdPropertyChanged("Threshold");
}
}
}
private double thresholdUpperBound;
public double ThresholdUpperBound
{
get { return thresholdUpperBound; }
set
{
if (this.value != value) {
this.value = value;
OnThresholdPropertyChanged("Threshold");
}
}
}
#region Persistence Properties
[Storable(Name = "Value")]
private double StorableValue {
get { return value; }
set { this.value = value; }
}
[Storable(Name = "ThresholdLowerBound")]
private double StorableThresholdLowerBound {
get { return thresholdLowerBound; }
set { this.thresholdLowerBound = value; }
}
[Storable(Name = "ThresholdUpperBound")]
private double StorableThresholdUpperBound
{
get { return thresholdUpperBound; }
set { this.thresholdUpperBound = value; }
}
#endregion
#region Visual Properties
private Color barColor;
public Color BarColor
{
get { return barColor; }
set
{
if (barColor != value) {
barColor = value;
OnValuePropertyChanged("BarColor");
}
}
}
private Color thresholdColor;
public Color ThresholdColor
{
get { return thresholdColor; }
set
{
if (thresholdColor != value) {
thresholdColor = value;
OnThresholdPropertyChanged("ThresholdColor");
}
}
}
#endregion
#region constructors, cloner ...
[StorableConstructor]
protected DataBar(bool deserializing) : base(deserializing) { }
protected DataBar(DataBar original, Cloner cloner) : base(original, cloner) {
this.value = original.value;
this.thresholdLowerBound = original.thresholdLowerBound;
this.barColor = original.barColor;
this.thresholdColor = original.thresholdColor;
}
public DataBar() : this("DataBar") {
barColor = DefaultBarColor;
thresholdColor = Color.Black;
}
public DataBar(string name) : base(name) {
if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
barColor = DefaultBarColor;
thresholdColor = Color.Black;
}
public DataBar(string name, double thresholdLowerBound, double thresholdUpperBound) : base(name) {
if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
this.thresholdLowerBound = thresholdLowerBound;
this.thresholdUpperBound = thresholdUpperBound;
barColor = DefaultBarColor;
thresholdColor = Color.Black;
}
public DataBar(string name, string description) : base(name, description) {
if (string.IsNullOrEmpty(name)) throw new ArgumentException("Name of a DataBar cannot be empty", name);
barColor = DefaultBarColor;
thresholdColor = Color.Black;
}
public override IDeepCloneable Clone(Cloner cloner) {
return new DataBar(this, cloner);
}
#endregion
protected override void OnNameChanged() {
base.OnNameChanged();
}
public event PropertyChangedEventHandler PropertyChanged;
public event PropertyChangedEventHandler ValuePropertyChanged;
public event PropertyChangedEventHandler ThresholdPropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) {
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
protected virtual void OnValuePropertyChanged([CallerMemberName] string propertyName = null) {
PropertyChangedEventHandler handler = ValuePropertyChanged;
if(handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
protected virtual void OnThresholdPropertyChanged([CallerMemberName] string propertyName = null) {
PropertyChangedEventHandler handler = ThresholdPropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}