Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs @ 17105

Last change on this file since 17105 was 17105, checked in by mkommend, 5 years ago

#2520: Merged 16584, 16585,16594,16595, 16625, 16658, 16659, 16672, 16707, 16729, 16792, 16796, 16797, 16799, 16819, 16906, 16907, 16908, 16933, 16945, 16992, 16994, 16995, 16996, 16997, 17014, 17015, 17017, 17020, 17021, 17022, 17023, 17024, 17029, 17086, 17087, 17088, 17089 into stable.

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