Free cookie consent management tool by TermsFeed Policy Generator

source: branches/GeneralizedQAP/HeuristicLab.Analysis/3.3/DataVisualization/DataRowVisualProperties.cs @ 6759

Last change on this file since 6759 was 6685, checked in by abeham, 13 years ago

#1628

  • Updated branch from trunk
  • Changed ReferenceEqualityComparer<T> to become a non-generic class (generic implementation probably was only made because of lacking support for co- and contravariance in C# 3.5)
  • Added finished experiment from sample algorithms to the tests
  • Wrote a unit test to instantiate every IDeepCloneable type, clone it and compare the objects in the object graph for equal references
  • Wrote a unit test to load the experiment, clone it and compare again the objects in the object graph
  • Preliminary fix for a potential bug in ThreadSafeLog
  • Preliminary fix for a potential bug in OperatorGraphVisualizationInfo
  • Preliminary fix for a potential bug in Calculator (and added license headers)
  • Preliminary fix for a potential bug in ScrambleMove
File size: 7.8 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 string displayName;
145    public string DisplayName {
146      get { return displayName == null ? String.Empty : displayName; }
147      set {
148        if (displayName != value) {
149          if (value == null && displayName != String.Empty) {
150            displayName = String.Empty;
151            OnPropertyChanged("DisplayName");
152          } else if (value != null) {
153            displayName = value;
154            OnPropertyChanged("DisplayName");
155          }
156        }
157      }
158    }
159
160    #region Persistence Properties
161    [Storable(Name = "ChartType")]
162    private DataRowChartType StorableChartType {
163      get { return chartType; }
164      set { chartType = value; }
165    }
166    [Storable(Name = "SecondYAxis")]
167    private bool StorableSecondYAxis {
168      get { return secondYAxis; }
169      set { secondYAxis = value; }
170    }
171    [Storable(Name = "SecondXAxis")]
172    private bool StorableSecondXAxis {
173      get { return secondXAxis; }
174      set { secondXAxis = value; }
175    }
176    [Storable(Name = "Color")]
177    private Color StorableColor {
178      get { return color; }
179      set { color = value; }
180    }
181    [Storable(Name = "LineStyle")]
182    private DataRowLineStyle StorableLineStyle {
183      get { return lineStyle; }
184      set { lineStyle = value; }
185    }
186    [Storable(Name = "StartIndexZero")]
187    private bool StorableStartIndexZero {
188      get { return startIndexZero; }
189      set { startIndexZero = value; }
190    }
191    [Storable(Name = "LineWidth")]
192    private int StorableLineWidth {
193      get { return lineWidth; }
194      set { lineWidth = value; }
195    }
196    [Storable(Name = "Bins")]
197    private int StorableBins {
198      get { return bins; }
199      set { bins = value; }
200    }
201    [Storable(Name = "ExactBins")]
202    private bool StorableExactBins {
203      get { return exactBins; }
204      set { exactBins = value; }
205    }
206    [Storable(Name = "DisplayName")]
207    private string StorableDisplayName {
208      get { return displayName; }
209      set { displayName = value; }
210    }
211    #endregion
212
213    [StorableConstructor]
214    protected DataRowVisualProperties(bool deserializing) : base() { }
215    protected DataRowVisualProperties(DataRowVisualProperties original, Cloner cloner)
216      : base(original, cloner) {
217      this.chartType = original.chartType;
218      this.secondYAxis = original.secondYAxis;
219      this.secondXAxis = original.secondXAxis;
220      this.color = original.color;
221      this.lineStyle = original.lineStyle;
222      this.startIndexZero = original.startIndexZero;
223      this.lineWidth = original.lineWidth;
224      this.bins = original.bins;
225      this.exactBins = original.exactBins;
226      this.displayName = original.displayName;
227    }
228    public DataRowVisualProperties() {
229      chartType = DataRowChartType.Line;
230      secondYAxis = false;
231      secondXAxis = false;
232      color = Color.Empty;
233      lineStyle = DataRowLineStyle.Solid;
234      startIndexZero = false;
235      lineWidth = 1;
236      bins = 10;
237      exactBins = false;
238      displayName = String.Empty;
239    }
240    public DataRowVisualProperties(string displayName)
241      : this() {
242      this.displayName = displayName;
243    }
244
245    public override IDeepCloneable Clone(Cloner cloner) {
246      return new DataRowVisualProperties(this, cloner);
247    }
248
249    public event PropertyChangedEventHandler PropertyChanged;
250    protected virtual void OnPropertyChanged(string propertyName) {
251      PropertyChangedEventHandler handler = PropertyChanged;
252      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
253    }
254
255    [StorableHook(HookType.AfterDeserialization)]
256    private void AfterDeserialization() {
257      // BackwardsCompatibility3.3
258      #region Backwards compatible code, remove with 3.4
259      if (secondXAxis == default(bool)
260        && lineStyle == default(DataRowLineStyle)
261        && lineWidth == default(int) && bins == default(int) && exactBins == default(bool)
262        && displayName == default(string)) {
263        secondXAxis = false;
264        lineStyle = DataRowLineStyle.Solid;
265        lineWidth = 1;
266        bins = 10;
267        exactBins = false;
268        displayName = String.Empty;
269      }
270      #endregion
271    }
272  }
273}
Note: See TracBrowser for help on using the repository browser.