Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.TimeSeries/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs @ 7098

Last change on this file since 7098 was 6978, checked in by bburlacu, 13 years ago

#1661: Added SymbolicExpressionTreeLengthAnalyzer. Added new scalingFactory visual property for table data rows (for dynamically adjusting the histogram scale depending on the number of bins) + scaling logic inside the tree length analyzer, adjusted DataTableView.

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