[4644] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[16057] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[4644] | 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 |
|
---|
[6628] | 22 | using System;
|
---|
[4644] | 23 | using System.ComponentModel;
|
---|
[4722] | 24 | using System.Drawing;
|
---|
[4644] | 25 | using HeuristicLab.Common;
|
---|
| 26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Analysis {
|
---|
| 29 | /// <summary>
|
---|
| 30 | /// Visual properties of a DataRow.
|
---|
| 31 | /// </summary>
|
---|
| 32 | [StorableClass]
|
---|
| 33 | public class DataRowVisualProperties : DeepCloneable, INotifyPropertyChanged {
|
---|
| 34 | #region ChartType
|
---|
| 35 | public enum DataRowChartType {
|
---|
| 36 | Line,
|
---|
| 37 | Columns,
|
---|
| 38 | Points,
|
---|
[6342] | 39 | Bars,
|
---|
[7297] | 40 | Histogram,
|
---|
| 41 | StepLine
|
---|
[4644] | 42 | }
|
---|
| 43 | #endregion
|
---|
[6342] | 44 | #region LineStyle
|
---|
| 45 | public enum DataRowLineStyle {
|
---|
| 46 | Dash,
|
---|
| 47 | DashDot,
|
---|
| 48 | DashDotDot,
|
---|
| 49 | Dot,
|
---|
| 50 | NotSet,
|
---|
| 51 | Solid
|
---|
| 52 | }
|
---|
| 53 | #endregion
|
---|
[4644] | 54 |
|
---|
| 55 | private DataRowChartType chartType;
|
---|
| 56 | public DataRowChartType ChartType {
|
---|
| 57 | get { return chartType; }
|
---|
| 58 | set {
|
---|
| 59 | if (chartType != value) {
|
---|
| 60 | chartType = value;
|
---|
| 61 | OnPropertyChanged("ChartType");
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | }
|
---|
| 65 | private bool secondYAxis;
|
---|
| 66 | public bool SecondYAxis {
|
---|
| 67 | get { return secondYAxis; }
|
---|
| 68 | set {
|
---|
| 69 | if (secondYAxis != value) {
|
---|
| 70 | secondYAxis = value;
|
---|
| 71 | OnPropertyChanged("SecondYAxis");
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 | }
|
---|
[6342] | 75 | private bool secondXAxis;
|
---|
| 76 | public bool SecondXAxis {
|
---|
| 77 | get { return secondXAxis; }
|
---|
| 78 | set {
|
---|
| 79 | if (secondXAxis != value) {
|
---|
| 80 | secondXAxis = value;
|
---|
| 81 | OnPropertyChanged("SecondXAxis");
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
[4648] | 85 | private Color color;
|
---|
| 86 | public Color Color {
|
---|
| 87 | get { return color; }
|
---|
| 88 | set {
|
---|
| 89 | if (color != value) {
|
---|
| 90 | color = value;
|
---|
| 91 | OnPropertyChanged("Color");
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
[6342] | 95 | private DataRowLineStyle lineStyle;
|
---|
| 96 | public DataRowLineStyle LineStyle {
|
---|
| 97 | get { return lineStyle; }
|
---|
| 98 | set {
|
---|
| 99 | if (lineStyle != value) {
|
---|
| 100 | lineStyle = value;
|
---|
| 101 | OnPropertyChanged("LineStyle");
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
[4648] | 105 | private bool startIndexZero;
|
---|
| 106 | public bool StartIndexZero {
|
---|
| 107 | get { return startIndexZero; }
|
---|
| 108 | set {
|
---|
| 109 | if (startIndexZero != value) {
|
---|
| 110 | startIndexZero = value;
|
---|
| 111 | OnPropertyChanged("StartIndexZero");
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
[6342] | 115 | private int lineWidth;
|
---|
| 116 | public int LineWidth {
|
---|
| 117 | get { return lineWidth; }
|
---|
| 118 | set {
|
---|
| 119 | if (lineWidth != value) {
|
---|
| 120 | lineWidth = value;
|
---|
| 121 | OnPropertyChanged("LineWidth");
|
---|
| 122 | }
|
---|
| 123 | }
|
---|
| 124 | }
|
---|
[15068] | 125 |
|
---|
[6978] | 126 | private double scaleFactor;
|
---|
| 127 | public double ScaleFactor {
|
---|
| 128 | get { return scaleFactor; }
|
---|
| 129 | set {
|
---|
| 130 | if (scaleFactor != value) {
|
---|
| 131 | scaleFactor = value;
|
---|
| 132 | OnPropertyChanged("ScaleFactor");
|
---|
| 133 | }
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
[7124] | 136 | private bool isVisibleInLegend;
|
---|
| 137 | public bool IsVisibleInLegend {
|
---|
| 138 | get { return isVisibleInLegend; }
|
---|
| 139 | set {
|
---|
| 140 | if (isVisibleInLegend != value) {
|
---|
| 141 | isVisibleInLegend = value;
|
---|
| 142 | OnPropertyChanged("IsVisibleInLegend");
|
---|
| 143 | }
|
---|
| 144 | }
|
---|
| 145 | }
|
---|
[6628] | 146 | private string displayName;
|
---|
| 147 | public string DisplayName {
|
---|
| 148 | get { return displayName == null ? String.Empty : displayName; }
|
---|
| 149 | set {
|
---|
| 150 | if (displayName != value) {
|
---|
| 151 | if (value == null && displayName != String.Empty) {
|
---|
| 152 | displayName = String.Empty;
|
---|
| 153 | OnPropertyChanged("DisplayName");
|
---|
| 154 | } else if (value != null) {
|
---|
| 155 | displayName = value;
|
---|
| 156 | OnPropertyChanged("DisplayName");
|
---|
| 157 | }
|
---|
| 158 | }
|
---|
| 159 | }
|
---|
| 160 | }
|
---|
[4644] | 161 |
|
---|
[4648] | 162 | #region Persistence Properties
|
---|
| 163 | [Storable(Name = "ChartType")]
|
---|
| 164 | private DataRowChartType StorableChartType {
|
---|
| 165 | get { return chartType; }
|
---|
| 166 | set { chartType = value; }
|
---|
| 167 | }
|
---|
| 168 | [Storable(Name = "SecondYAxis")]
|
---|
| 169 | private bool StorableSecondYAxis {
|
---|
| 170 | get { return secondYAxis; }
|
---|
| 171 | set { secondYAxis = value; }
|
---|
| 172 | }
|
---|
[6342] | 173 | [Storable(Name = "SecondXAxis")]
|
---|
| 174 | private bool StorableSecondXAxis {
|
---|
| 175 | get { return secondXAxis; }
|
---|
| 176 | set { secondXAxis = value; }
|
---|
| 177 | }
|
---|
[4648] | 178 | [Storable(Name = "Color")]
|
---|
| 179 | private Color StorableColor {
|
---|
| 180 | get { return color; }
|
---|
| 181 | set { color = value; }
|
---|
| 182 | }
|
---|
[6342] | 183 | [Storable(Name = "LineStyle")]
|
---|
| 184 | private DataRowLineStyle StorableLineStyle {
|
---|
| 185 | get { return lineStyle; }
|
---|
| 186 | set { lineStyle = value; }
|
---|
| 187 | }
|
---|
[4648] | 188 | [Storable(Name = "StartIndexZero")]
|
---|
| 189 | private bool StorableStartIndexZero {
|
---|
| 190 | get { return startIndexZero; }
|
---|
| 191 | set { startIndexZero = value; }
|
---|
| 192 | }
|
---|
[6342] | 193 | [Storable(Name = "LineWidth")]
|
---|
| 194 | private int StorableLineWidth {
|
---|
| 195 | get { return lineWidth; }
|
---|
| 196 | set { lineWidth = value; }
|
---|
| 197 | }
|
---|
[6978] | 198 | [Storable(Name = "ScaleFactor")]
|
---|
| 199 | private double StorableScaleFactor {
|
---|
| 200 | get { return scaleFactor; }
|
---|
| 201 | set { scaleFactor = value; }
|
---|
| 202 | }
|
---|
[7126] | 203 | [Storable(Name = "IsVisibleInLegend", DefaultValue = true)]
|
---|
[7124] | 204 | private bool StorableIsVisibleInLegend {
|
---|
| 205 | get { return isVisibleInLegend; }
|
---|
| 206 | set { isVisibleInLegend = value; }
|
---|
| 207 | }
|
---|
[6628] | 208 | [Storable(Name = "DisplayName")]
|
---|
| 209 | private string StorableDisplayName {
|
---|
| 210 | get { return displayName; }
|
---|
| 211 | set { displayName = value; }
|
---|
| 212 | }
|
---|
[4648] | 213 | #endregion
|
---|
| 214 |
|
---|
[15068] | 215 | #region Histogram Properties - Backwards Compatability
|
---|
| 216 | internal enum DataRowHistogramAggregation {
|
---|
| 217 | Overlapping,
|
---|
| 218 | SideBySide,
|
---|
| 219 | Stacked
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | internal int? Bins { get; private set; }
|
---|
| 223 | internal bool? ExactBins { get; private set; }
|
---|
| 224 | internal DataRowHistogramAggregation? Aggregation { get; private set; }
|
---|
| 225 |
|
---|
| 226 | [Storable(Name = "Bins", AllowOneWay = true)]
|
---|
| 227 | private int StorableBins { set { Bins = value; } }
|
---|
| 228 | [Storable(Name = "ExactBins", AllowOneWay = true)]
|
---|
| 229 | private bool StorableExactBins { set { ExactBins = value; } }
|
---|
| 230 | [Storable(Name = "Aggregation", AllowOneWay = true)]
|
---|
| 231 | private DataRowHistogramAggregation StorableAggregation { set { Aggregation = value; } }
|
---|
| 232 | #endregion
|
---|
| 233 |
|
---|
[4722] | 234 | [StorableConstructor]
|
---|
| 235 | protected DataRowVisualProperties(bool deserializing) : base() { }
|
---|
| 236 | protected DataRowVisualProperties(DataRowVisualProperties original, Cloner cloner)
|
---|
| 237 | : base(original, cloner) {
|
---|
| 238 | this.chartType = original.chartType;
|
---|
| 239 | this.secondYAxis = original.secondYAxis;
|
---|
[6342] | 240 | this.secondXAxis = original.secondXAxis;
|
---|
[4722] | 241 | this.color = original.color;
|
---|
[6342] | 242 | this.lineStyle = original.lineStyle;
|
---|
[4722] | 243 | this.startIndexZero = original.startIndexZero;
|
---|
[6342] | 244 | this.lineWidth = original.lineWidth;
|
---|
[6978] | 245 | this.scaleFactor = original.scaleFactor;
|
---|
[6628] | 246 | this.displayName = original.displayName;
|
---|
[7124] | 247 | this.isVisibleInLegend = original.isVisibleInLegend;
|
---|
[4722] | 248 | }
|
---|
[4644] | 249 | public DataRowVisualProperties() {
|
---|
| 250 | chartType = DataRowChartType.Line;
|
---|
| 251 | secondYAxis = false;
|
---|
[6342] | 252 | secondXAxis = false;
|
---|
[4648] | 253 | color = Color.Empty;
|
---|
[6342] | 254 | lineStyle = DataRowLineStyle.Solid;
|
---|
[4648] | 255 | startIndexZero = false;
|
---|
[6342] | 256 | lineWidth = 1;
|
---|
[6978] | 257 | scaleFactor = 1.0;
|
---|
[6628] | 258 | displayName = String.Empty;
|
---|
[7124] | 259 | isVisibleInLegend = true;
|
---|
[4644] | 260 | }
|
---|
[6628] | 261 | public DataRowVisualProperties(string displayName)
|
---|
| 262 | : this() {
|
---|
| 263 | this.displayName = displayName;
|
---|
| 264 | }
|
---|
[4644] | 265 |
|
---|
[4777] | 266 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 267 | return new DataRowVisualProperties(this, cloner);
|
---|
| 268 | }
|
---|
| 269 |
|
---|
[4644] | 270 | public event PropertyChangedEventHandler PropertyChanged;
|
---|
| 271 | protected virtual void OnPropertyChanged(string propertyName) {
|
---|
| 272 | PropertyChangedEventHandler handler = PropertyChanged;
|
---|
| 273 | if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
---|
| 274 | }
|
---|
[6676] | 275 |
|
---|
| 276 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 277 | private void AfterDeserialization() {
|
---|
| 278 | // BackwardsCompatibility3.3
|
---|
| 279 | #region Backwards compatible code, remove with 3.4
|
---|
| 280 | if (secondXAxis == default(bool)
|
---|
| 281 | && lineStyle == default(DataRowLineStyle)
|
---|
| 282 | && displayName == default(string)) {
|
---|
| 283 | secondXAxis = false;
|
---|
| 284 | lineStyle = DataRowLineStyle.Solid;
|
---|
| 285 | lineWidth = 1;
|
---|
| 286 | displayName = String.Empty;
|
---|
| 287 | }
|
---|
| 288 | #endregion
|
---|
| 289 | }
|
---|
[4644] | 290 | }
|
---|
| 291 | }
|
---|