Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 13346 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 8.9 KB
RevLine 
[4644]1#region License Information
2/* HeuristicLab
[12012]3 * Copyright (C) 2002-2015 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]22using System;
[4644]23using System.ComponentModel;
[4722]24using System.Drawing;
[4644]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,
[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    }
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    }
[6978]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    }
[7124]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    }
[6628]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    }
[4644]180
[4648]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    }
[6342]192    [Storable(Name = "SecondXAxis")]
193    private bool StorableSecondXAxis {
194      get { return secondXAxis; }
195      set { secondXAxis = value; }
196    }
[4648]197    [Storable(Name = "Color")]
198    private Color StorableColor {
199      get { return color; }
200      set { color = value; }
201    }
[6342]202    [Storable(Name = "LineStyle")]
203    private DataRowLineStyle StorableLineStyle {
204      get { return lineStyle; }
205      set { lineStyle = value; }
206    }
[4648]207    [Storable(Name = "StartIndexZero")]
208    private bool StorableStartIndexZero {
209      get { return startIndexZero; }
210      set { startIndexZero = value; }
211    }
[6342]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    }
[6978]227    [Storable(Name = "ScaleFactor")]
228    private double StorableScaleFactor {
229      get { return scaleFactor; }
230      set { scaleFactor = value; }
231    }
[7126]232    [Storable(Name = "IsVisibleInLegend", DefaultValue = true)]
[7124]233    private bool StorableIsVisibleInLegend {
234      get { return isVisibleInLegend; }
235      set { isVisibleInLegend = value; }
236    }
[6628]237    [Storable(Name = "DisplayName")]
238    private string StorableDisplayName {
239      get { return displayName; }
240      set { displayName = value; }
241    }
[4648]242    #endregion
243
[4722]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;
[6342]250      this.secondXAxis = original.secondXAxis;
[4722]251      this.color = original.color;
[6342]252      this.lineStyle = original.lineStyle;
[4722]253      this.startIndexZero = original.startIndexZero;
[6342]254      this.lineWidth = original.lineWidth;
255      this.bins = original.bins;
256      this.exactBins = original.exactBins;
[6978]257      this.scaleFactor = original.scaleFactor;
[6628]258      this.displayName = original.displayName;
[7124]259      this.isVisibleInLegend = original.isVisibleInLegend;
[4722]260    }
[4644]261    public DataRowVisualProperties() {
262      chartType = DataRowChartType.Line;
263      secondYAxis = false;
[6342]264      secondXAxis = false;
[4648]265      color = Color.Empty;
[6342]266      lineStyle = DataRowLineStyle.Solid;
[4648]267      startIndexZero = false;
[6342]268      lineWidth = 1;
269      bins = 10;
270      exactBins = false;
[6978]271      scaleFactor = 1.0;
[6628]272      displayName = String.Empty;
[7124]273      isVisibleInLegend = true;
[4644]274    }
[6628]275    public DataRowVisualProperties(string displayName)
276      : this() {
277      this.displayName = displayName;
278    }
[4644]279
[4777]280    public override IDeepCloneable Clone(Cloner cloner) {
281      return new DataRowVisualProperties(this, cloner);
282    }
283
[4644]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    }
[6676]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    }
[4644]307  }
308}
Note: See TracBrowser for help on using the repository browser.