Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 11677 was 11171, checked in by ascheibe, 10 years ago

#2115 merged r11170 (copyright update) into trunk

File size: 8.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2014 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    private int bins;
126    public int Bins {
127      get { return bins; }
128      set {
129        if (bins != value) {
130          bins = value;
131          OnPropertyChanged("Bins");
132        }
133      }
134    }
135    private bool exactBins;
136    public bool ExactBins {
137      get { return exactBins; }
138      set {
139        if (exactBins != value) {
140          exactBins = value;
141          OnPropertyChanged("ExactBins");
142        }
143      }
144    }
145    private double scaleFactor;
146    public double ScaleFactor {
147      get { return scaleFactor; }
148      set {
149        if (scaleFactor != value) {
150          scaleFactor = value;
151          OnPropertyChanged("ScaleFactor");
152        }
153      }
154    }
155    private bool isVisibleInLegend;
156    public bool IsVisibleInLegend {
157      get { return isVisibleInLegend; }
158      set {
159        if (isVisibleInLegend != value) {
160          isVisibleInLegend = value;
161          OnPropertyChanged("IsVisibleInLegend");
162        }
163      }
164    }
165    private string displayName;
166    public string DisplayName {
167      get { return displayName == null ? String.Empty : displayName; }
168      set {
169        if (displayName != value) {
170          if (value == null && displayName != String.Empty) {
171            displayName = String.Empty;
172            OnPropertyChanged("DisplayName");
173          } else if (value != null) {
174            displayName = value;
175            OnPropertyChanged("DisplayName");
176          }
177        }
178      }
179    }
180
181    #region Persistence Properties
182    [Storable(Name = "ChartType")]
183    private DataRowChartType StorableChartType {
184      get { return chartType; }
185      set { chartType = value; }
186    }
187    [Storable(Name = "SecondYAxis")]
188    private bool StorableSecondYAxis {
189      get { return secondYAxis; }
190      set { secondYAxis = value; }
191    }
192    [Storable(Name = "SecondXAxis")]
193    private bool StorableSecondXAxis {
194      get { return secondXAxis; }
195      set { secondXAxis = value; }
196    }
197    [Storable(Name = "Color")]
198    private Color StorableColor {
199      get { return color; }
200      set { color = value; }
201    }
202    [Storable(Name = "LineStyle")]
203    private DataRowLineStyle StorableLineStyle {
204      get { return lineStyle; }
205      set { lineStyle = value; }
206    }
207    [Storable(Name = "StartIndexZero")]
208    private bool StorableStartIndexZero {
209      get { return startIndexZero; }
210      set { startIndexZero = value; }
211    }
212    [Storable(Name = "LineWidth")]
213    private int StorableLineWidth {
214      get { return lineWidth; }
215      set { lineWidth = value; }
216    }
217    [Storable(Name = "Bins")]
218    private int StorableBins {
219      get { return bins; }
220      set { bins = value; }
221    }
222    [Storable(Name = "ExactBins")]
223    private bool StorableExactBins {
224      get { return exactBins; }
225      set { exactBins = value; }
226    }
227    [Storable(Name = "ScaleFactor")]
228    private double StorableScaleFactor {
229      get { return scaleFactor; }
230      set { scaleFactor = value; }
231    }
232    [Storable(Name = "IsVisibleInLegend", DefaultValue = true)]
233    private bool StorableIsVisibleInLegend {
234      get { return isVisibleInLegend; }
235      set { isVisibleInLegend = value; }
236    }
237    [Storable(Name = "DisplayName")]
238    private string StorableDisplayName {
239      get { return displayName; }
240      set { displayName = value; }
241    }
242    #endregion
243
244    [StorableConstructor]
245    protected DataRowVisualProperties(bool deserializing) : base() { }
246    protected DataRowVisualProperties(DataRowVisualProperties original, Cloner cloner)
247      : base(original, cloner) {
248      this.chartType = original.chartType;
249      this.secondYAxis = original.secondYAxis;
250      this.secondXAxis = original.secondXAxis;
251      this.color = original.color;
252      this.lineStyle = original.lineStyle;
253      this.startIndexZero = original.startIndexZero;
254      this.lineWidth = original.lineWidth;
255      this.bins = original.bins;
256      this.exactBins = original.exactBins;
257      this.scaleFactor = original.scaleFactor;
258      this.displayName = original.displayName;
259      this.isVisibleInLegend = original.isVisibleInLegend;
260    }
261    public DataRowVisualProperties() {
262      chartType = DataRowChartType.Line;
263      secondYAxis = false;
264      secondXAxis = false;
265      color = Color.Empty;
266      lineStyle = DataRowLineStyle.Solid;
267      startIndexZero = false;
268      lineWidth = 1;
269      bins = 10;
270      exactBins = false;
271      scaleFactor = 1.0;
272      displayName = String.Empty;
273      isVisibleInLegend = true;
274    }
275    public DataRowVisualProperties(string displayName)
276      : this() {
277      this.displayName = displayName;
278    }
279
280    public override IDeepCloneable Clone(Cloner cloner) {
281      return new DataRowVisualProperties(this, cloner);
282    }
283
284    public event PropertyChangedEventHandler PropertyChanged;
285    protected virtual void OnPropertyChanged(string propertyName) {
286      PropertyChangedEventHandler handler = PropertyChanged;
287      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
288    }
289
290    [StorableHook(HookType.AfterDeserialization)]
291    private void AfterDeserialization() {
292      // BackwardsCompatibility3.3
293      #region Backwards compatible code, remove with 3.4
294      if (secondXAxis == default(bool)
295        && lineStyle == default(DataRowLineStyle)
296        && lineWidth == default(int) && bins == default(int) && exactBins == default(bool)
297        && displayName == default(string)) {
298        secondXAxis = false;
299        lineStyle = DataRowLineStyle.Solid;
300        lineWidth = 1;
301        bins = 10;
302        exactBins = false;
303        displayName = String.Empty;
304      }
305      #endregion
306    }
307  }
308}
Note: See TracBrowser for help on using the repository browser.