Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceReintegration/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs @ 15071

Last change on this file since 15071 was 15018, checked in by gkronber, 8 years ago

#2520 introduced StorableConstructorFlag type for StorableConstructors

File size: 9.9 KB
RevLine 
[4644]1#region License Information
2/* HeuristicLab
[14185]3 * Copyright (C) 2002-2016 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;
[14927]26using HeuristicLab.Persistence;
[4644]27
28namespace HeuristicLab.Analysis {
29  /// <summary>
30  /// Visual properties of a DataRow.
31  /// </summary>
[14927]32  [StorableType("6d4307f2-9400-4836-bfeb-9d90fe88830e")]
[4644]33  public class DataRowVisualProperties : DeepCloneable, INotifyPropertyChanged {
34    #region ChartType
[14929]35    [StorableType("c43ebac6-acf0-40f7-9515-c032f73f6b3c")]
[4644]36    public enum DataRowChartType {
37      Line,
38      Columns,
39      Points,
[6342]40      Bars,
[7297]41      Histogram,
42      StepLine
[4644]43    }
44    #endregion
[6342]45    #region LineStyle
[14929]46    [StorableType("d006c5b0-a8f2-44ce-9cb7-6fb1f6ef7109")]
[6342]47    public enum DataRowLineStyle {
48      Dash,
49      DashDot,
50      DashDotDot,
51      Dot,
52      NotSet,
53      Solid
54    }
55    #endregion
[14582]56    #region Histogram Aggregation
[14929]57    [StorableType("7fd525d7-4126-4084-b811-ee36b9eddf45")]
[14582]58    public enum DataRowHistogramAggregation {
59      Overlapping,
60      SideBySide,
61      Stacked
62    }
63    #endregion
[4644]64
65    private DataRowChartType chartType;
66    public DataRowChartType ChartType {
67      get { return chartType; }
68      set {
69        if (chartType != value) {
70          chartType = value;
71          OnPropertyChanged("ChartType");
72        }
73      }
74    }
75    private bool secondYAxis;
76    public bool SecondYAxis {
77      get { return secondYAxis; }
78      set {
79        if (secondYAxis != value) {
80          secondYAxis = value;
81          OnPropertyChanged("SecondYAxis");
82        }
83      }
84    }
[6342]85    private bool secondXAxis;
86    public bool SecondXAxis {
87      get { return secondXAxis; }
88      set {
89        if (secondXAxis != value) {
90          secondXAxis = value;
91          OnPropertyChanged("SecondXAxis");
92        }
93      }
94    }
[4648]95    private Color color;
96    public Color Color {
97      get { return color; }
98      set {
99        if (color != value) {
100          color = value;
101          OnPropertyChanged("Color");
102        }
103      }
104    }
[6342]105    private DataRowLineStyle lineStyle;
106    public DataRowLineStyle LineStyle {
107      get { return lineStyle; }
108      set {
109        if (lineStyle != value) {
110          lineStyle = value;
111          OnPropertyChanged("LineStyle");
112        }
113      }
114    }
[4648]115    private bool startIndexZero;
116    public bool StartIndexZero {
117      get { return startIndexZero; }
118      set {
119        if (startIndexZero != value) {
120          startIndexZero = value;
121          OnPropertyChanged("StartIndexZero");
122        }
123      }
124    }
[6342]125    private int lineWidth;
126    public int LineWidth {
127      get { return lineWidth; }
128      set {
129        if (lineWidth != value) {
130          lineWidth = value;
131          OnPropertyChanged("LineWidth");
132        }
133      }
134    }
135    private int bins;
136    public int Bins {
137      get { return bins; }
138      set {
139        if (bins != value) {
140          bins = value;
141          OnPropertyChanged("Bins");
142        }
143      }
144    }
145    private bool exactBins;
146    public bool ExactBins {
147      get { return exactBins; }
148      set {
149        if (exactBins != value) {
150          exactBins = value;
151          OnPropertyChanged("ExactBins");
152        }
153      }
154    }
[14582]155    private DataRowHistogramAggregation aggregation;
156    public DataRowHistogramAggregation Aggregation {
157      get { return aggregation; }
158      set {
159        if (aggregation != value) {
160          aggregation = value;
161          OnPropertyChanged("Aggregation");
162        }
163      }
164    }
[6978]165    private double scaleFactor;
166    public double ScaleFactor {
167      get { return scaleFactor; }
168      set {
169        if (scaleFactor != value) {
170          scaleFactor = value;
171          OnPropertyChanged("ScaleFactor");
172        }
173      }
174    }
[7124]175    private bool isVisibleInLegend;
176    public bool IsVisibleInLegend {
177      get { return isVisibleInLegend; }
178      set {
179        if (isVisibleInLegend != value) {
180          isVisibleInLegend = value;
181          OnPropertyChanged("IsVisibleInLegend");
182        }
183      }
184    }
[6628]185    private string displayName;
186    public string DisplayName {
187      get { return displayName == null ? String.Empty : displayName; }
188      set {
189        if (displayName != value) {
190          if (value == null && displayName != String.Empty) {
191            displayName = String.Empty;
192            OnPropertyChanged("DisplayName");
193          } else if (value != null) {
194            displayName = value;
195            OnPropertyChanged("DisplayName");
196          }
197        }
198      }
199    }
[4644]200
[4648]201    #region Persistence Properties
202    [Storable(Name = "ChartType")]
203    private DataRowChartType StorableChartType {
204      get { return chartType; }
205      set { chartType = value; }
206    }
207    [Storable(Name = "SecondYAxis")]
208    private bool StorableSecondYAxis {
209      get { return secondYAxis; }
210      set { secondYAxis = value; }
211    }
[6342]212    [Storable(Name = "SecondXAxis")]
213    private bool StorableSecondXAxis {
214      get { return secondXAxis; }
215      set { secondXAxis = value; }
216    }
[4648]217    [Storable(Name = "Color")]
218    private Color StorableColor {
219      get { return color; }
220      set { color = value; }
221    }
[6342]222    [Storable(Name = "LineStyle")]
223    private DataRowLineStyle StorableLineStyle {
224      get { return lineStyle; }
225      set { lineStyle = value; }
226    }
[4648]227    [Storable(Name = "StartIndexZero")]
228    private bool StorableStartIndexZero {
229      get { return startIndexZero; }
230      set { startIndexZero = value; }
231    }
[6342]232    [Storable(Name = "LineWidth")]
233    private int StorableLineWidth {
234      get { return lineWidth; }
235      set { lineWidth = value; }
236    }
237    [Storable(Name = "Bins")]
238    private int StorableBins {
239      get { return bins; }
240      set { bins = value; }
241    }
242    [Storable(Name = "ExactBins")]
243    private bool StorableExactBins {
244      get { return exactBins; }
245      set { exactBins = value; }
246    }
[14582]247    [Storable(Name = "Aggregation", DefaultValue = DataRowHistogramAggregation.Overlapping)]
248    private DataRowHistogramAggregation StorableAggregation {
249      get { return aggregation; }
250      set { aggregation = value; }
251    }
[6978]252    [Storable(Name = "ScaleFactor")]
253    private double StorableScaleFactor {
254      get { return scaleFactor; }
255      set { scaleFactor = value; }
256    }
[7126]257    [Storable(Name = "IsVisibleInLegend", DefaultValue = true)]
[7124]258    private bool StorableIsVisibleInLegend {
259      get { return isVisibleInLegend; }
260      set { isVisibleInLegend = value; }
261    }
[6628]262    [Storable(Name = "DisplayName")]
263    private string StorableDisplayName {
264      get { return displayName; }
265      set { displayName = value; }
266    }
[4648]267    #endregion
268
[4722]269    [StorableConstructor]
[15018]270    protected DataRowVisualProperties(StorableConstructorFlag deserializing) : base() { }
[4722]271    protected DataRowVisualProperties(DataRowVisualProperties original, Cloner cloner)
272      : base(original, cloner) {
273      this.chartType = original.chartType;
274      this.secondYAxis = original.secondYAxis;
[6342]275      this.secondXAxis = original.secondXAxis;
[4722]276      this.color = original.color;
[6342]277      this.lineStyle = original.lineStyle;
[4722]278      this.startIndexZero = original.startIndexZero;
[6342]279      this.lineWidth = original.lineWidth;
280      this.bins = original.bins;
281      this.exactBins = original.exactBins;
[14582]282      this.aggregation = original.aggregation;
[6978]283      this.scaleFactor = original.scaleFactor;
[6628]284      this.displayName = original.displayName;
[7124]285      this.isVisibleInLegend = original.isVisibleInLegend;
[4722]286    }
[4644]287    public DataRowVisualProperties() {
288      chartType = DataRowChartType.Line;
289      secondYAxis = false;
[6342]290      secondXAxis = false;
[4648]291      color = Color.Empty;
[6342]292      lineStyle = DataRowLineStyle.Solid;
[4648]293      startIndexZero = false;
[6342]294      lineWidth = 1;
295      bins = 10;
296      exactBins = false;
[14582]297      aggregation = DataRowHistogramAggregation.Overlapping;
[6978]298      scaleFactor = 1.0;
[6628]299      displayName = String.Empty;
[7124]300      isVisibleInLegend = true;
[4644]301    }
[6628]302    public DataRowVisualProperties(string displayName)
303      : this() {
304      this.displayName = displayName;
305    }
[4644]306
[4777]307    public override IDeepCloneable Clone(Cloner cloner) {
308      return new DataRowVisualProperties(this, cloner);
309    }
310
[4644]311    public event PropertyChangedEventHandler PropertyChanged;
312    protected virtual void OnPropertyChanged(string propertyName) {
313      PropertyChangedEventHandler handler = PropertyChanged;
314      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
315    }
[6676]316
317    [StorableHook(HookType.AfterDeserialization)]
318    private void AfterDeserialization() {
319      // BackwardsCompatibility3.3
320      #region Backwards compatible code, remove with 3.4
321      if (secondXAxis == default(bool)
322        && lineStyle == default(DataRowLineStyle)
323        && lineWidth == default(int) && bins == default(int) && exactBins == default(bool)
324        && displayName == default(string)) {
325        secondXAxis = false;
326        lineStyle = DataRowLineStyle.Solid;
327        lineWidth = 1;
328        bins = 10;
329        exactBins = false;
330        displayName = String.Empty;
331      }
332      #endregion
333    }
[4644]334  }
335}
Note: See TracBrowser for help on using the repository browser.