Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs @ 16350

Last change on this file since 16350 was 15584, checked in by swagner, 7 years ago

#2640: Updated year of copyrights in license headers on stable

File size: 8.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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.ComponentModel;
24using System.Drawing;
25using HeuristicLab.Common;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace 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,
39      Bars,
40      Histogram,
41      StepLine
42    }
43    #endregion
44    #region LineStyle
45    public enum DataRowLineStyle {
46      Dash,
47      DashDot,
48      DashDotDot,
49      Dot,
50      NotSet,
51      Solid
52    }
53    #endregion
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    }
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    }
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    }
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    }
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    }
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    }
125
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    }
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    }
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    }
161
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    }
173    [Storable(Name = "SecondXAxis")]
174    private bool StorableSecondXAxis {
175      get { return secondXAxis; }
176      set { secondXAxis = value; }
177    }
178    [Storable(Name = "Color")]
179    private Color StorableColor {
180      get { return color; }
181      set { color = value; }
182    }
183    [Storable(Name = "LineStyle")]
184    private DataRowLineStyle StorableLineStyle {
185      get { return lineStyle; }
186      set { lineStyle = value; }
187    }
188    [Storable(Name = "StartIndexZero")]
189    private bool StorableStartIndexZero {
190      get { return startIndexZero; }
191      set { startIndexZero = value; }
192    }
193    [Storable(Name = "LineWidth")]
194    private int StorableLineWidth {
195      get { return lineWidth; }
196      set { lineWidth = value; }
197    }
198    [Storable(Name = "ScaleFactor")]
199    private double StorableScaleFactor {
200      get { return scaleFactor; }
201      set { scaleFactor = value; }
202    }
203    [Storable(Name = "IsVisibleInLegend", DefaultValue = true)]
204    private bool StorableIsVisibleInLegend {
205      get { return isVisibleInLegend; }
206      set { isVisibleInLegend = value; }
207    }
208    [Storable(Name = "DisplayName")]
209    private string StorableDisplayName {
210      get { return displayName; }
211      set { displayName = value; }
212    }
213    #endregion
214
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
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;
240      this.secondXAxis = original.secondXAxis;
241      this.color = original.color;
242      this.lineStyle = original.lineStyle;
243      this.startIndexZero = original.startIndexZero;
244      this.lineWidth = original.lineWidth;
245      this.scaleFactor = original.scaleFactor;
246      this.displayName = original.displayName;
247      this.isVisibleInLegend = original.isVisibleInLegend;
248    }
249    public DataRowVisualProperties() {
250      chartType = DataRowChartType.Line;
251      secondYAxis = false;
252      secondXAxis = false;
253      color = Color.Empty;
254      lineStyle = DataRowLineStyle.Solid;
255      startIndexZero = false;
256      lineWidth = 1;
257      scaleFactor = 1.0;
258      displayName = String.Empty;
259      isVisibleInLegend = true;
260    }
261    public DataRowVisualProperties(string displayName)
262      : this() {
263      this.displayName = displayName;
264    }
265
266    public override IDeepCloneable Clone(Cloner cloner) {
267      return new DataRowVisualProperties(this, cloner);
268    }
269
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    }
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    }
290  }
291}
Note: See TracBrowser for help on using the repository browser.