Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive.Azure/HeuristicLab.Analysis/3.3/DataVisualization/DataTableVisualProperties.cs @ 7270

Last change on this file since 7270 was 7270, checked in by spimming, 13 years ago

#1680:

  • merged changes from trunk into branch
File size: 19.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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.ComponentModel;
23using System.Drawing;
24using HeuristicLab.Common;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26
27namespace HeuristicLab.Analysis {
28  /// <summary>
29  /// Visual properties of a DataTable.
30  /// </summary>
31  [StorableClass]
32  public class DataTableVisualProperties : DeepCloneable, INotifyPropertyChanged {
33    private Font titleFont;
34    public Font TitleFont {
35      get { return titleFont; }
36      set {
37        if (titleFont == null || value == null
38          || titleFont.Name != value.Name || titleFont.Size != value.Size || titleFont.Style != value.Style) {
39          titleFont = value;
40          OnPropertyChanged("TitleFont");
41        }
42      }
43    }
44    private Color titleColor;
45    public Color TitleColor {
46      get { return titleColor; }
47      set {
48        if (titleColor != value) {
49          titleColor = value;
50          OnPropertyChanged("TitleFontColor");
51        }
52      }
53    }
54    private string title;
55    public string Title {
56      get { return title; }
57      set {
58        if (title != value) {
59          title = value;
60          OnPropertyChanged("Title");
61        }
62      }
63    }
64    private Font axisTitleFont;
65    public Font AxisTitleFont {
66      get { return axisTitleFont; }
67      set {
68        if (axisTitleFont == null || axisTitleFont == null
69          || axisTitleFont.Name != value.Name || axisTitleFont.Size != value.Size || axisTitleFont.Style != value.Style) {
70          axisTitleFont = value;
71          OnPropertyChanged("AxisTitleFont");
72        }
73      }
74    }
75    private Color axisTitleColor;
76    public Color AxisTitleColor {
77      get { return axisTitleColor; }
78      set {
79        if (axisTitleColor != value) {
80          axisTitleColor = value;
81          OnPropertyChanged("AxisTitleColor");
82        }
83      }
84    }
85    private string xAxisTitle;
86    public string XAxisTitle {
87      get { return xAxisTitle; }
88      set {
89        if (value == null) value = string.Empty;
90        if (xAxisTitle != value) {
91          xAxisTitle = value;
92          OnPropertyChanged("XAxisTitle");
93        }
94      }
95    }
96
97    private string yAxisTitle;
98    public string YAxisTitle {
99      get { return yAxisTitle; }
100      set {
101        if (value == null) value = string.Empty;
102        if (yAxisTitle != value) {
103          yAxisTitle = value;
104          OnPropertyChanged("YAxisTitle");
105        }
106      }
107    }
108
109    private string secondXAxisTitle;
110    public string SecondXAxisTitle {
111      get { return secondXAxisTitle; }
112      set {
113        if (value == null) value = string.Empty;
114        if (secondXAxisTitle != value) {
115          secondXAxisTitle = value;
116          OnPropertyChanged("SecondXAxisTitle");
117        }
118      }
119    }
120
121    private string secondYAxisTitle;
122    public string SecondYAxisTitle {
123      get { return secondYAxisTitle; }
124      set {
125        if (value == null) value = string.Empty;
126        if (secondYAxisTitle != value) {
127          secondYAxisTitle = value;
128          OnPropertyChanged("SecondYAxisTitle");
129        }
130      }
131    }
132
133    private bool xAxisMinimumAuto;
134    public bool XAxisMinimumAuto {
135      get { return xAxisMinimumAuto; }
136      set {
137        if (xAxisMinimumAuto != value) {
138          xAxisMinimumAuto = value;
139          if (value) xAxisMinimumFixedValue = double.NaN;
140          OnPropertyChanged("XAxisMinimumAuto");
141        }
142      }
143    }
144
145    private bool xAxisMaximumAuto;
146    public bool XAxisMaximumAuto {
147      get { return xAxisMaximumAuto; }
148      set {
149        if (xAxisMaximumAuto != value) {
150          xAxisMaximumAuto = value;
151          if (value) xAxisMaximumFixedValue = double.NaN;
152          OnPropertyChanged("XAxisMaximumAuto");
153        }
154      }
155    }
156
157    private double xAxisMinimumFixedValue;
158    public double XAxisMinimumFixedValue {
159      get { return xAxisMinimumFixedValue; }
160      set {
161        if (xAxisMinimumFixedValue != value) {
162          xAxisMinimumFixedValue = value;
163          OnPropertyChanged("XAxisMinimumFixedValue");
164        }
165      }
166    }
167
168    private double xAxisMaximumFixedValue;
169    public double XAxisMaximumFixedValue {
170      get { return xAxisMaximumFixedValue; }
171      set {
172        if (xAxisMaximumFixedValue != value) {
173          xAxisMaximumFixedValue = value;
174          OnPropertyChanged("XAxisMaximumFixedValue");
175        }
176      }
177    }
178
179    private bool secondXAxisMinimumAuto;
180    public bool SecondXAxisMinimumAuto {
181      get { return secondXAxisMinimumAuto; }
182      set {
183        if (secondXAxisMinimumAuto != value) {
184          secondXAxisMinimumAuto = value;
185          if (value) secondXAxisMinimumFixedValue = double.NaN;
186          OnPropertyChanged("SecondXAxisMinimumAuto");
187        }
188      }
189    }
190
191    private bool secondXAxisMaximumAuto;
192    public bool SecondXAxisMaximumAuto {
193      get { return secondXAxisMaximumAuto; }
194      set {
195        if (secondXAxisMaximumAuto != value) {
196          secondXAxisMaximumAuto = value;
197          if (value) secondXAxisMaximumFixedValue = double.NaN;
198          OnPropertyChanged("SecondXAxisMaximumAuto");
199        }
200      }
201    }
202
203    private double secondXAxisMinimumFixedValue;
204    public double SecondXAxisMinimumFixedValue {
205      get { return secondXAxisMinimumFixedValue; }
206      set {
207        if (secondXAxisMinimumFixedValue != value) {
208          secondXAxisMinimumFixedValue = value;
209          OnPropertyChanged("SecondXAxisMinimumFixedValue");
210        }
211      }
212    }
213
214    private double secondXAxisMaximumFixedValue;
215    public double SecondXAxisMaximumFixedValue {
216      get { return secondXAxisMaximumFixedValue; }
217      set {
218        if (secondXAxisMaximumFixedValue != value) {
219          secondXAxisMaximumFixedValue = value;
220          OnPropertyChanged("SecondXAxisMaximumFixedValue");
221        }
222      }
223    }
224
225    private bool yAxisMinimumAuto;
226    public bool YAxisMinimumAuto {
227      get { return yAxisMinimumAuto; }
228      set {
229        if (yAxisMinimumAuto != value) {
230          yAxisMinimumAuto = value;
231          if (value) yAxisMinimumFixedValue = double.NaN;
232          OnPropertyChanged("YAxisMinimumAuto");
233        }
234      }
235    }
236
237    private bool yAxisMaximumAuto;
238    public bool YAxisMaximumAuto {
239      get { return yAxisMaximumAuto; }
240      set {
241        if (yAxisMaximumAuto != value) {
242          yAxisMaximumAuto = value;
243          if (value) yAxisMaximumFixedValue = double.NaN;
244          OnPropertyChanged("YAxisMaximumAuto");
245        }
246      }
247    }
248
249    private double yAxisMinimumFixedValue;
250    public double YAxisMinimumFixedValue {
251      get { return yAxisMinimumFixedValue; }
252      set {
253        if (yAxisMinimumFixedValue != value) {
254          yAxisMinimumFixedValue = value;
255          OnPropertyChanged("YAxisMinimumFixedValue");
256        }
257      }
258    }
259
260    private double yAxisMaximumFixedValue;
261    public double YAxisMaximumFixedValue {
262      get { return yAxisMaximumFixedValue; }
263      set {
264        if (yAxisMaximumFixedValue != value) {
265          yAxisMaximumFixedValue = value;
266          OnPropertyChanged("YAxisMaximumFixedValue");
267        }
268      }
269    }
270
271    private bool secondYAxisMinimumAuto;
272    public bool SecondYAxisMinimumAuto {
273      get { return secondYAxisMinimumAuto; }
274      set {
275        if (secondYAxisMinimumAuto != value) {
276          secondYAxisMinimumAuto = value;
277          if (value) secondYAxisMinimumFixedValue = double.NaN;
278          OnPropertyChanged("SecondYAxisMinimumAuto");
279        }
280      }
281    }
282
283    private bool secondYAxisMaximumAuto;
284    public bool SecondYAxisMaximumAuto {
285      get { return secondYAxisMaximumAuto; }
286      set {
287        if (secondYAxisMaximumAuto != value) {
288          secondYAxisMaximumAuto = value;
289          if (value) secondYAxisMaximumFixedValue = double.NaN;
290          OnPropertyChanged("SecondYAxisMaximumAuto");
291        }
292      }
293    }
294
295    private double secondYAxisMinimumFixedValue;
296    public double SecondYAxisMinimumFixedValue {
297      get { return secondYAxisMinimumFixedValue; }
298      set {
299        if (secondYAxisMinimumFixedValue != value) {
300          secondYAxisMinimumFixedValue = value;
301          OnPropertyChanged("SecondYAxisMinimumFixedValue");
302        }
303      }
304    }
305
306    private double secondYAxisMaximumFixedValue;
307    public double SecondYAxisMaximumFixedValue {
308      get { return secondYAxisMaximumFixedValue; }
309      set {
310        if (secondYAxisMaximumFixedValue != value) {
311          secondYAxisMaximumFixedValue = value;
312          OnPropertyChanged("SecondYAxisMaximumFixedValue");
313        }
314      }
315    }
316
317    #region Persistence Properties
318    [Storable(Name = "TitleFont")]
319    private Font StorableTitleFont {
320      get { return titleFont; }
321      set { titleFont = value; }
322    }
323    [Storable(Name = "TitleColor")]
324    private Color StorableTitleColor {
325      get { return titleColor; }
326      set { titleColor = value; }
327    }
328    [Storable(Name = "Title")]
329    private string StorableTitle {
330      get { return title; }
331      set { title = value; }
332    }
333    [Storable(Name = "AxisTitleFont")]
334    private Font StorableAxisTitleFont {
335      get { return axisTitleFont; }
336      set { axisTitleFont = value; }
337    }
338    [Storable(Name = "AxisTitleColor")]
339    private Color StorableAxisTitleColor {
340      get { return axisTitleColor; }
341      set { axisTitleColor = value; }
342    }
343    [Storable(Name = "XAxisTitle")]
344    private string StorableXAxisTitle {
345      get { return xAxisTitle; }
346      set { xAxisTitle = value; }
347    }
348    [Storable(Name = "YAxisTitle")]
349    private string StorableYAxisTitle {
350      get { return yAxisTitle; }
351      set { yAxisTitle = value; }
352    }
353    [Storable(Name = "SecondXAxisTitle")]
354    private string StorableSecondXAxisTitle {
355      get { return secondXAxisTitle; }
356      set { secondXAxisTitle = value; }
357    }
358    [Storable(Name = "SecondYAxisTitle")]
359    private string StorableSecondYAxisTitle {
360      get { return secondYAxisTitle; }
361      set { secondYAxisTitle = value; }
362    }
363    [Storable(Name = "XAxisMinimumAuto")]
364    private bool StorableXAxisMinimumAuto {
365      get { return xAxisMinimumAuto; }
366      set { xAxisMinimumAuto = value; }
367    }
368    [Storable(Name = "XAxisMaximumAuto")]
369    private bool StorableXAxisMaximumAuto {
370      get { return xAxisMaximumAuto; }
371      set { xAxisMaximumAuto = value; }
372    }
373    [Storable(Name = "XAxisMinimumFixedValue")]
374    private double StorableXAxisMinimumFixedValue {
375      get { return xAxisMinimumFixedValue; }
376      set { xAxisMinimumFixedValue = value; }
377    }
378    [Storable(Name = "XAxisMaximumFixedValue")]
379    private double StorableXAxisMaximumFixedValue {
380      get { return xAxisMaximumFixedValue; }
381      set { xAxisMaximumFixedValue = value; }
382    }
383    [Storable(Name = "SecondXAxisMinimumAuto")]
384    private bool StorableSecondXAxisMinimumAuto {
385      get { return secondXAxisMinimumAuto; }
386      set { secondXAxisMinimumAuto = value; }
387    }
388    [Storable(Name = "SecondXAxisMaximumAuto")]
389    private bool StorableSecondXAxisMaximumAuto {
390      get { return secondXAxisMaximumAuto; }
391      set { secondXAxisMaximumAuto = value; }
392    }
393    [Storable(Name = "SecondXAxisMinimumFixedValue")]
394    private double StorableSecondXAxisMinimumFixedValue {
395      get { return secondXAxisMinimumFixedValue; }
396      set { secondXAxisMinimumFixedValue = value; }
397    }
398    [Storable(Name = "SecondXAxisMaximumFixedValue")]
399    private double StorableSecondXAxisMaximumFixedValue {
400      get { return secondXAxisMaximumFixedValue; }
401      set { secondXAxisMaximumFixedValue = value; }
402    }
403    [Storable(Name = "YAxisMinimumAuto")]
404    private bool StorableYAxisMinimumAuto {
405      get { return yAxisMinimumAuto; }
406      set { yAxisMinimumAuto = value; }
407    }
408    [Storable(Name = "YAxisMaximumAuto")]
409    private bool StorableYAxisMaximumAuto {
410      get { return yAxisMaximumAuto; }
411      set { yAxisMaximumAuto = value; }
412    }
413    [Storable(Name = "YAxisMinimumFixedValue")]
414    private double StorableYAxisMinimumFixedValue {
415      get { return yAxisMinimumFixedValue; }
416      set { yAxisMinimumFixedValue = value; }
417    }
418    [Storable(Name = "YAxisMaximumFixedValue")]
419    private double StorableYAxisMaximumFixedValue {
420      get { return yAxisMaximumFixedValue; }
421      set { yAxisMaximumFixedValue = value; }
422    }
423    [Storable(Name = "SecondYAxisMinimumAuto")]
424    private bool StorableSecondYAxisMinimumAuto {
425      get { return secondYAxisMinimumAuto; }
426      set { secondYAxisMinimumAuto = value; }
427    }
428    [Storable(Name = "SecondYAxisMaximumAuto")]
429    private bool StorableSecondYAxisMaximumAuto {
430      get { return secondYAxisMaximumAuto; }
431      set { secondYAxisMaximumAuto = value; }
432    }
433    [Storable(Name = "SecondYAxisMinimumFixedValue")]
434    private double StorableSecondYAxisMinimumFixedValue {
435      get { return secondYAxisMinimumFixedValue; }
436      set { secondYAxisMinimumFixedValue = value; }
437    }
438    [Storable(Name = "SecondYAxisMaximumFixedValue")]
439    private double StorableSecondYAxisMaximumFixedValue {
440      get { return secondYAxisMaximumFixedValue; }
441      set { secondYAxisMaximumFixedValue = value; }
442    }
443    #endregion
444
445    [StorableConstructor]
446    protected DataTableVisualProperties(bool deserializing) : base() { }
447    protected DataTableVisualProperties(DataTableVisualProperties original, Cloner cloner)
448      : base(original, cloner) {
449      if (original.titleFont != null)
450        this.titleFont = (Font)original.titleFont.Clone();
451      if (original.axisTitleFont != null)
452        this.axisTitleFont = (Font)original.axisTitleFont.Clone();
453      this.title = original.title;
454      this.xAxisTitle = original.xAxisTitle;
455      this.yAxisTitle = original.yAxisTitle;
456      this.secondXAxisTitle = original.secondXAxisTitle;
457      this.secondYAxisTitle = original.secondYAxisTitle;
458      this.xAxisMinimumAuto = original.xAxisMinimumAuto;
459      this.xAxisMinimumFixedValue = original.xAxisMinimumFixedValue;
460      this.xAxisMaximumAuto = original.xAxisMaximumAuto;
461      this.xAxisMaximumFixedValue = original.xAxisMaximumFixedValue;
462      this.secondXAxisMinimumAuto = original.secondXAxisMinimumAuto;
463      this.secondXAxisMinimumFixedValue = original.secondXAxisMinimumFixedValue;
464      this.secondXAxisMaximumAuto = original.secondXAxisMaximumAuto;
465      this.secondXAxisMaximumFixedValue = original.secondXAxisMaximumFixedValue;
466      this.yAxisMinimumAuto = original.yAxisMinimumAuto;
467      this.yAxisMinimumFixedValue = original.yAxisMinimumFixedValue;
468      this.yAxisMaximumAuto = original.yAxisMaximumAuto;
469      this.yAxisMaximumFixedValue = original.yAxisMaximumFixedValue;
470      this.secondYAxisMinimumAuto = original.secondYAxisMinimumAuto;
471      this.secondYAxisMinimumFixedValue = original.secondYAxisMinimumFixedValue;
472      this.secondYAxisMaximumAuto = original.secondYAxisMaximumAuto;
473      this.secondYAxisMaximumFixedValue = original.secondYAxisMaximumFixedValue;
474    }
475    public DataTableVisualProperties() {
476      this.titleColor = Color.Black;
477      this.axisTitleColor = Color.Black;
478      this.title = string.Empty;
479      this.xAxisTitle = string.Empty;
480      this.yAxisTitle = string.Empty;
481      this.secondXAxisTitle = string.Empty;
482      this.secondYAxisTitle = string.Empty;
483      this.xAxisMinimumAuto = true;
484      this.xAxisMinimumFixedValue = double.NaN;
485      this.xAxisMaximumAuto = true;
486      this.xAxisMaximumFixedValue = double.NaN;
487      this.secondXAxisMinimumAuto = true;
488      this.secondXAxisMinimumFixedValue = double.NaN;
489      this.secondXAxisMaximumAuto = true;
490      this.secondXAxisMaximumFixedValue = double.NaN;
491      this.yAxisMinimumAuto = true;
492      this.yAxisMinimumFixedValue = double.NaN;
493      this.yAxisMaximumAuto = true;
494      this.yAxisMaximumFixedValue = double.NaN;
495      this.secondYAxisMinimumAuto = true;
496      this.secondYAxisMinimumFixedValue = double.NaN;
497      this.secondYAxisMaximumAuto = true;
498      this.secondYAxisMaximumFixedValue = double.NaN;
499    }
500    public DataTableVisualProperties(string title)
501      : this() {
502      this.title = title;
503    }
504
505    public override IDeepCloneable Clone(Cloner cloner) {
506      return new DataTableVisualProperties(this, cloner);
507    }
508
509    public event PropertyChangedEventHandler PropertyChanged;
510    protected virtual void OnPropertyChanged(string propertyName) {
511      PropertyChangedEventHandler handler = PropertyChanged;
512      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
513    }
514
515    [StorableHook(HookType.AfterDeserialization)]
516    private void AfterDeserialization() {
517      // BackwardsCompatibility3.3
518      #region Backwards compatible code, remove with 3.4
519      // check if most of the properties that were added in Mai'11 were set to their default values, then we want to reset them to our default values
520      if (xAxisMinimumAuto == default(bool) && xAxisMaximumAuto == default(bool)
521        && yAxisMinimumAuto == default(bool) && yAxisMaximumAuto == default(bool)
522        && secondXAxisMinimumAuto == default(bool) && secondXAxisMaximumAuto == default(bool)
523        && secondYAxisMinimumAuto == default(bool) && secondYAxisMaximumAuto == default(bool)
524        && titleColor == default(Color) && axisTitleColor == default(Color)
525        && secondXAxisTitle == default(string)
526        && xAxisMinimumFixedValue == default(double) && xAxisMaximumFixedValue == default(double)
527        && yAxisMinimumFixedValue == default(double) && yAxisMaximumFixedValue == default(double)
528        && secondXAxisMinimumFixedValue == default(double) && secondXAxisMaximumFixedValue == default(double)
529        && secondYAxisMinimumFixedValue == default(double) && secondYAxisMaximumFixedValue == default(double)) {
530        titleColor = Color.Black;
531        axisTitleColor = Color.Black;
532        this.secondXAxisTitle = string.Empty;
533        this.xAxisMinimumAuto = true;
534        this.xAxisMinimumFixedValue = double.NaN;
535        this.xAxisMaximumAuto = true;
536        this.xAxisMaximumFixedValue = double.NaN;
537        this.secondXAxisMinimumAuto = true;
538        this.secondXAxisMinimumFixedValue = double.NaN;
539        this.secondXAxisMaximumAuto = true;
540        this.secondXAxisMaximumFixedValue = double.NaN;
541        this.yAxisMinimumAuto = true;
542        this.yAxisMinimumFixedValue = double.NaN;
543        this.yAxisMaximumAuto = true;
544        this.yAxisMaximumFixedValue = double.NaN;
545        this.secondYAxisMinimumAuto = true;
546        this.secondYAxisMinimumFixedValue = double.NaN;
547        this.secondYAxisMaximumAuto = true;
548        this.secondYAxisMaximumFixedValue = double.NaN;
549      #endregion
550      }
551    }
552  }
553}
Note: See TracBrowser for help on using the repository browser.