Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs @ 7201

Last change on this file since 7201 was 7126, checked in by bburlacu, 13 years ago

#1661: Modified the DataTableView to take the IsVisibleInLegend property into account for all chart types. Added default value for the IsVisibleInLegend property in the storable constructor (the property is true by default, identical to the old behavior).

File size: 8.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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    }
42    #endregion
43    #region LineStyle
44    public enum DataRowLineStyle {
45      Dash,
46      DashDot,
47      DashDotDot,
48      Dot,
49      NotSet,
50      Solid
51    }
52    #endregion
53
54    private DataRowChartType chartType;
55    public DataRowChartType ChartType {
56      get { return chartType; }
57      set {
58        if (chartType != value) {
59          chartType = value;
60          OnPropertyChanged("ChartType");
61        }
62      }
63    }
64    private bool secondYAxis;
65    public bool SecondYAxis {
66      get { return secondYAxis; }
67      set {
68        if (secondYAxis != value) {
69          secondYAxis = value;
70          OnPropertyChanged("SecondYAxis");
71        }
72      }
73    }
74    private bool secondXAxis;
75    public bool SecondXAxis {
76      get { return secondXAxis; }
77      set {
78        if (secondXAxis != value) {
79          secondXAxis = value;
80          OnPropertyChanged("SecondXAxis");
81        }
82      }
83    }
84    private Color color;
85    public Color Color {
86      get { return color; }
87      set {
88        if (color != value) {
89          color = value;
90          OnPropertyChanged("Color");
91        }
92      }
93    }
94    private DataRowLineStyle lineStyle;
95    public DataRowLineStyle LineStyle {
96      get { return lineStyle; }
97      set {
98        if (lineStyle != value) {
99          lineStyle = value;
100          OnPropertyChanged("LineStyle");
101        }
102      }
103    }
104    private bool startIndexZero;
105    public bool StartIndexZero {
106      get { return startIndexZero; }
107      set {
108        if (startIndexZero != value) {
109          startIndexZero = value;
110          OnPropertyChanged("StartIndexZero");
111        }
112      }
113    }
114    private int lineWidth;
115    public int LineWidth {
116      get { return lineWidth; }
117      set {
118        if (lineWidth != value) {
119          lineWidth = value;
120          OnPropertyChanged("LineWidth");
121        }
122      }
123    }
124    private int bins;
125    public int Bins {
126      get { return bins; }
127      set {
128        if (bins != value) {
129          bins = value;
130          OnPropertyChanged("Bins");
131        }
132      }
133    }
134    private bool exactBins;
135    public bool ExactBins {
136      get { return exactBins; }
137      set {
138        if (exactBins != value) {
139          exactBins = value;
140          OnPropertyChanged("ExactBins");
141        }
142      }
143    }
144    private double scaleFactor;
145    public double ScaleFactor {
146      get { return scaleFactor; }
147      set {
148        if (scaleFactor != value) {
149          scaleFactor = value;
150          OnPropertyChanged("ScaleFactor");
151        }
152      }
153    }
154    private bool isVisibleInLegend;
155    public bool IsVisibleInLegend {
156      get { return isVisibleInLegend; }
157      set {
158        if (isVisibleInLegend != value) {
159          isVisibleInLegend = value;
160          OnPropertyChanged("IsVisibleInLegend");
161        }
162      }
163    }
164    private string displayName;
165    public string DisplayName {
166      get { return displayName == null ? String.Empty : displayName; }
167      set {
168        if (displayName != value) {
169          if (value == null && displayName != String.Empty) {
170            displayName = String.Empty;
171            OnPropertyChanged("DisplayName");
172          } else if (value != null) {
173            displayName = value;
174            OnPropertyChanged("DisplayName");
175          }
176        }
177      }
178    }
179
180    #region Persistence Properties
181    [Storable(Name = "ChartType")]
182    private DataRowChartType StorableChartType {
183      get { return chartType; }
184      set { chartType = value; }
185    }
186    [Storable(Name = "SecondYAxis")]
187    private bool StorableSecondYAxis {
188      get { return secondYAxis; }
189      set { secondYAxis = value; }
190    }
191    [Storable(Name = "SecondXAxis")]
192    private bool StorableSecondXAxis {
193      get { return secondXAxis; }
194      set { secondXAxis = value; }
195    }
196    [Storable(Name = "Color")]
197    private Color StorableColor {
198      get { return color; }
199      set { color = value; }
200    }
201    [Storable(Name = "LineStyle")]
202    private DataRowLineStyle StorableLineStyle {
203      get { return lineStyle; }
204      set { lineStyle = value; }
205    }
206    [Storable(Name = "StartIndexZero")]
207    private bool StorableStartIndexZero {
208      get { return startIndexZero; }
209      set { startIndexZero = value; }
210    }
211    [Storable(Name = "LineWidth")]
212    private int StorableLineWidth {
213      get { return lineWidth; }
214      set { lineWidth = value; }
215    }
216    [Storable(Name = "Bins")]
217    private int StorableBins {
218      get { return bins; }
219      set { bins = value; }
220    }
221    [Storable(Name = "ExactBins")]
222    private bool StorableExactBins {
223      get { return exactBins; }
224      set { exactBins = value; }
225    }
226    [Storable(Name = "ScaleFactor")]
227    private double StorableScaleFactor {
228      get { return scaleFactor; }
229      set { scaleFactor = value; }
230    }
231    [Storable(Name = "IsVisibleInLegend", DefaultValue = true)]
232    private bool StorableIsVisibleInLegend {
233      get { return isVisibleInLegend; }
234      set { isVisibleInLegend = value; }
235    }
236    [Storable(Name = "DisplayName")]
237    private string StorableDisplayName {
238      get { return displayName; }
239      set { displayName = value; }
240    }
241    #endregion
242
243    [StorableConstructor]
244    protected DataRowVisualProperties(bool deserializing) : base() { }
245    protected DataRowVisualProperties(DataRowVisualProperties original, Cloner cloner)
246      : base(original, cloner) {
247      this.chartType = original.chartType;
248      this.secondYAxis = original.secondYAxis;
249      this.secondXAxis = original.secondXAxis;
250      this.color = original.color;
251      this.lineStyle = original.lineStyle;
252      this.startIndexZero = original.startIndexZero;
253      this.lineWidth = original.lineWidth;
254      this.bins = original.bins;
255      this.exactBins = original.exactBins;
256      this.scaleFactor = original.scaleFactor;
257      this.displayName = original.displayName;
258      this.isVisibleInLegend = original.isVisibleInLegend;
259    }
260    public DataRowVisualProperties() {
261      chartType = DataRowChartType.Line;
262      secondYAxis = false;
263      secondXAxis = false;
264      color = Color.Empty;
265      lineStyle = DataRowLineStyle.Solid;
266      startIndexZero = false;
267      lineWidth = 1;
268      bins = 10;
269      exactBins = false;
270      scaleFactor = 1.0;
271      displayName = String.Empty;
272      isVisibleInLegend = true;
273    }
274    public DataRowVisualProperties(string displayName)
275      : this() {
276      this.displayName = displayName;
277    }
278
279    public override IDeepCloneable Clone(Cloner cloner) {
280      return new DataRowVisualProperties(this, cloner);
281    }
282
283    public event PropertyChangedEventHandler PropertyChanged;
284    protected virtual void OnPropertyChanged(string propertyName) {
285      PropertyChangedEventHandler handler = PropertyChanged;
286      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
287    }
288
289    [StorableHook(HookType.AfterDeserialization)]
290    private void AfterDeserialization() {
291      // BackwardsCompatibility3.3
292      #region Backwards compatible code, remove with 3.4
293      if (secondXAxis == default(bool)
294        && lineStyle == default(DataRowLineStyle)
295        && lineWidth == default(int) && bins == default(int) && exactBins == default(bool)
296        && displayName == default(string)) {
297        secondXAxis = false;
298        lineStyle = DataRowLineStyle.Solid;
299        lineWidth = 1;
300        bins = 10;
301        exactBins = false;
302        displayName = String.Empty;
303      }
304      #endregion
305    }
306  }
307}
Note: See TracBrowser for help on using the repository browser.