Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Analysis/3.3/DataVisualization/DataTableVisualProperties.cs @ 12654

Last change on this file since 12654 was 12012, checked in by ascheibe, 10 years ago

#2212 merged r12008, r12009, r12010 back into trunk

File size: 21.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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 HeuristicLab.Common;
23using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
24using System.ComponentModel;
25using System.Drawing;
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    private bool xAxisLogScale;
318    public bool XAxisLogScale {
319      get { return xAxisLogScale; }
320      set {
321        if (xAxisLogScale == value) return;
322        xAxisLogScale = value;
323        OnPropertyChanged("XAxisLogScale");
324      }
325    }
326
327    private bool secondXAxisLogScale;
328    public bool SecondXAxisLogScale {
329      get { return secondXAxisLogScale; }
330      set {
331        if (secondXAxisLogScale == value) return;
332        secondXAxisLogScale = value;
333        OnPropertyChanged("SecondXAxisLogScale");
334      }
335    }
336
337    private bool yAxisLogScale;
338    public bool YAxisLogScale {
339      get { return yAxisLogScale; }
340      set {
341        if (yAxisLogScale == value) return;
342        yAxisLogScale = value;
343        OnPropertyChanged("YAxisLogScale");
344      }
345    }
346
347    private bool secondYAxisLogScale;
348    public bool SecondYAxisLogScale {
349      get { return secondYAxisLogScale; }
350      set {
351        if (secondYAxisLogScale == value) return;
352        secondYAxisLogScale = value;
353        OnPropertyChanged("SecondYAxisLogScale");
354      }
355    }
356
357    #region Persistence Properties
358    [Storable(Name = "TitleFont")]
359    private Font StorableTitleFont {
360      get { return titleFont; }
361      set { titleFont = value; }
362    }
363    [Storable(Name = "TitleColor")]
364    private Color StorableTitleColor {
365      get { return titleColor; }
366      set { titleColor = value; }
367    }
368    [Storable(Name = "Title")]
369    private string StorableTitle {
370      get { return title; }
371      set { title = value; }
372    }
373    [Storable(Name = "AxisTitleFont")]
374    private Font StorableAxisTitleFont {
375      get { return axisTitleFont; }
376      set { axisTitleFont = value; }
377    }
378    [Storable(Name = "AxisTitleColor")]
379    private Color StorableAxisTitleColor {
380      get { return axisTitleColor; }
381      set { axisTitleColor = value; }
382    }
383    [Storable(Name = "XAxisTitle")]
384    private string StorableXAxisTitle {
385      get { return xAxisTitle; }
386      set { xAxisTitle = value; }
387    }
388    [Storable(Name = "YAxisTitle")]
389    private string StorableYAxisTitle {
390      get { return yAxisTitle; }
391      set { yAxisTitle = value; }
392    }
393    [Storable(Name = "SecondXAxisTitle")]
394    private string StorableSecondXAxisTitle {
395      get { return secondXAxisTitle; }
396      set { secondXAxisTitle = value; }
397    }
398    [Storable(Name = "SecondYAxisTitle")]
399    private string StorableSecondYAxisTitle {
400      get { return secondYAxisTitle; }
401      set { secondYAxisTitle = value; }
402    }
403    [Storable(Name = "XAxisMinimumAuto")]
404    private bool StorableXAxisMinimumAuto {
405      get { return xAxisMinimumAuto; }
406      set { xAxisMinimumAuto = value; }
407    }
408    [Storable(Name = "XAxisMaximumAuto")]
409    private bool StorableXAxisMaximumAuto {
410      get { return xAxisMaximumAuto; }
411      set { xAxisMaximumAuto = value; }
412    }
413    [Storable(Name = "XAxisMinimumFixedValue")]
414    private double StorableXAxisMinimumFixedValue {
415      get { return xAxisMinimumFixedValue; }
416      set { xAxisMinimumFixedValue = value; }
417    }
418    [Storable(Name = "XAxisMaximumFixedValue")]
419    private double StorableXAxisMaximumFixedValue {
420      get { return xAxisMaximumFixedValue; }
421      set { xAxisMaximumFixedValue = value; }
422    }
423    [Storable(Name = "SecondXAxisMinimumAuto")]
424    private bool StorableSecondXAxisMinimumAuto {
425      get { return secondXAxisMinimumAuto; }
426      set { secondXAxisMinimumAuto = value; }
427    }
428    [Storable(Name = "SecondXAxisMaximumAuto")]
429    private bool StorableSecondXAxisMaximumAuto {
430      get { return secondXAxisMaximumAuto; }
431      set { secondXAxisMaximumAuto = value; }
432    }
433    [Storable(Name = "SecondXAxisMinimumFixedValue")]
434    private double StorableSecondXAxisMinimumFixedValue {
435      get { return secondXAxisMinimumFixedValue; }
436      set { secondXAxisMinimumFixedValue = value; }
437    }
438    [Storable(Name = "SecondXAxisMaximumFixedValue")]
439    private double StorableSecondXAxisMaximumFixedValue {
440      get { return secondXAxisMaximumFixedValue; }
441      set { secondXAxisMaximumFixedValue = value; }
442    }
443    [Storable(Name = "YAxisMinimumAuto")]
444    private bool StorableYAxisMinimumAuto {
445      get { return yAxisMinimumAuto; }
446      set { yAxisMinimumAuto = value; }
447    }
448    [Storable(Name = "YAxisMaximumAuto")]
449    private bool StorableYAxisMaximumAuto {
450      get { return yAxisMaximumAuto; }
451      set { yAxisMaximumAuto = value; }
452    }
453    [Storable(Name = "YAxisMinimumFixedValue")]
454    private double StorableYAxisMinimumFixedValue {
455      get { return yAxisMinimumFixedValue; }
456      set { yAxisMinimumFixedValue = value; }
457    }
458    [Storable(Name = "YAxisMaximumFixedValue")]
459    private double StorableYAxisMaximumFixedValue {
460      get { return yAxisMaximumFixedValue; }
461      set { yAxisMaximumFixedValue = value; }
462    }
463    [Storable(Name = "SecondYAxisMinimumAuto")]
464    private bool StorableSecondYAxisMinimumAuto {
465      get { return secondYAxisMinimumAuto; }
466      set { secondYAxisMinimumAuto = value; }
467    }
468    [Storable(Name = "SecondYAxisMaximumAuto")]
469    private bool StorableSecondYAxisMaximumAuto {
470      get { return secondYAxisMaximumAuto; }
471      set { secondYAxisMaximumAuto = value; }
472    }
473    [Storable(Name = "SecondYAxisMinimumFixedValue")]
474    private double StorableSecondYAxisMinimumFixedValue {
475      get { return secondYAxisMinimumFixedValue; }
476      set { secondYAxisMinimumFixedValue = value; }
477    }
478    [Storable(Name = "SecondYAxisMaximumFixedValue")]
479    private double StorableSecondYAxisMaximumFixedValue {
480      get { return secondYAxisMaximumFixedValue; }
481      set { secondYAxisMaximumFixedValue = value; }
482    }
483    [Storable(Name = "XAxisLogScale")]
484    private bool StorableXAxisLogScale {
485      get { return xAxisLogScale; }
486      set { xAxisLogScale = value; }
487    }
488    [Storable(Name = "SecondXAxisLogScale")]
489    private bool StorableSecondXAxisLogScale {
490      get { return secondXAxisLogScale; }
491      set { secondXAxisLogScale = value; }
492    }
493    [Storable(Name = "YAxisLogScale")]
494    private bool StorableYAxisLogScale {
495      get { return yAxisLogScale; }
496      set { yAxisLogScale = value; }
497    }
498    [Storable(Name = "SecondYAxisLogScale")]
499    private bool StorableSecondYAxisLogScale {
500      get { return secondYAxisLogScale; }
501      set { secondYAxisLogScale = value; }
502    }
503    #endregion
504
505    [StorableConstructor]
506    protected DataTableVisualProperties(bool deserializing) : base() { }
507    protected DataTableVisualProperties(DataTableVisualProperties original, Cloner cloner)
508      : base(original, cloner) {
509      if (original.titleFont != null)
510        this.titleFont = (Font)original.titleFont.Clone();
511      if (original.axisTitleFont != null)
512        this.axisTitleFont = (Font)original.axisTitleFont.Clone();
513      this.title = original.title;
514      this.xAxisTitle = original.xAxisTitle;
515      this.yAxisTitle = original.yAxisTitle;
516      this.secondXAxisTitle = original.secondXAxisTitle;
517      this.secondYAxisTitle = original.secondYAxisTitle;
518      this.xAxisMinimumAuto = original.xAxisMinimumAuto;
519      this.xAxisMinimumFixedValue = original.xAxisMinimumFixedValue;
520      this.xAxisMaximumAuto = original.xAxisMaximumAuto;
521      this.xAxisMaximumFixedValue = original.xAxisMaximumFixedValue;
522      this.secondXAxisMinimumAuto = original.secondXAxisMinimumAuto;
523      this.secondXAxisMinimumFixedValue = original.secondXAxisMinimumFixedValue;
524      this.secondXAxisMaximumAuto = original.secondXAxisMaximumAuto;
525      this.secondXAxisMaximumFixedValue = original.secondXAxisMaximumFixedValue;
526      this.yAxisMinimumAuto = original.yAxisMinimumAuto;
527      this.yAxisMinimumFixedValue = original.yAxisMinimumFixedValue;
528      this.yAxisMaximumAuto = original.yAxisMaximumAuto;
529      this.yAxisMaximumFixedValue = original.yAxisMaximumFixedValue;
530      this.secondYAxisMinimumAuto = original.secondYAxisMinimumAuto;
531      this.secondYAxisMinimumFixedValue = original.secondYAxisMinimumFixedValue;
532      this.secondYAxisMaximumAuto = original.secondYAxisMaximumAuto;
533      this.secondYAxisMaximumFixedValue = original.secondYAxisMaximumFixedValue;
534      this.xAxisLogScale = original.xAxisLogScale;
535      this.secondXAxisLogScale = original.secondXAxisLogScale;
536      this.yAxisLogScale = original.yAxisLogScale;
537      this.secondYAxisLogScale = original.secondYAxisLogScale;
538    }
539    public DataTableVisualProperties() {
540      this.titleColor = Color.Black;
541      this.axisTitleColor = Color.Black;
542      this.title = string.Empty;
543      this.xAxisTitle = string.Empty;
544      this.yAxisTitle = string.Empty;
545      this.secondXAxisTitle = string.Empty;
546      this.secondYAxisTitle = string.Empty;
547      this.xAxisMinimumAuto = true;
548      this.xAxisMinimumFixedValue = double.NaN;
549      this.xAxisMaximumAuto = true;
550      this.xAxisMaximumFixedValue = double.NaN;
551      this.secondXAxisMinimumAuto = true;
552      this.secondXAxisMinimumFixedValue = double.NaN;
553      this.secondXAxisMaximumAuto = true;
554      this.secondXAxisMaximumFixedValue = double.NaN;
555      this.yAxisMinimumAuto = true;
556      this.yAxisMinimumFixedValue = double.NaN;
557      this.yAxisMaximumAuto = true;
558      this.yAxisMaximumFixedValue = double.NaN;
559      this.secondYAxisMinimumAuto = true;
560      this.secondYAxisMinimumFixedValue = double.NaN;
561      this.secondYAxisMaximumAuto = true;
562      this.secondYAxisMaximumFixedValue = double.NaN;
563      this.xAxisLogScale = false;
564      this.secondXAxisLogScale = false;
565      this.yAxisLogScale = false;
566      this.secondYAxisLogScale = false;
567    }
568    public DataTableVisualProperties(string title)
569      : this() {
570      this.title = title;
571    }
572
573    public override IDeepCloneable Clone(Cloner cloner) {
574      return new DataTableVisualProperties(this, cloner);
575    }
576
577    public event PropertyChangedEventHandler PropertyChanged;
578    protected virtual void OnPropertyChanged(string propertyName) {
579      var handler = PropertyChanged;
580      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
581    }
582
583    [StorableHook(HookType.AfterDeserialization)]
584    private void AfterDeserialization() {
585      // BackwardsCompatibility3.3
586      #region Backwards compatible code, remove with 3.4
587      // 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
588      if (xAxisMinimumAuto == default(bool) && xAxisMaximumAuto == default(bool)
589        && yAxisMinimumAuto == default(bool) && yAxisMaximumAuto == default(bool)
590        && secondXAxisMinimumAuto == default(bool) && secondXAxisMaximumAuto == default(bool)
591        && secondYAxisMinimumAuto == default(bool) && secondYAxisMaximumAuto == default(bool)
592        && titleColor == default(Color) && axisTitleColor == default(Color)
593        && secondXAxisTitle == default(string)
594        && xAxisMinimumFixedValue == default(double) && xAxisMaximumFixedValue == default(double)
595        && yAxisMinimumFixedValue == default(double) && yAxisMaximumFixedValue == default(double)
596        && secondXAxisMinimumFixedValue == default(double) && secondXAxisMaximumFixedValue == default(double)
597        && secondYAxisMinimumFixedValue == default(double) && secondYAxisMaximumFixedValue == default(double)) {
598        titleColor = Color.Black;
599        axisTitleColor = Color.Black;
600        this.secondXAxisTitle = string.Empty;
601        this.xAxisMinimumAuto = true;
602        this.xAxisMinimumFixedValue = double.NaN;
603        this.xAxisMaximumAuto = true;
604        this.xAxisMaximumFixedValue = double.NaN;
605        this.secondXAxisMinimumAuto = true;
606        this.secondXAxisMinimumFixedValue = double.NaN;
607        this.secondXAxisMaximumAuto = true;
608        this.secondXAxisMaximumFixedValue = double.NaN;
609        this.yAxisMinimumAuto = true;
610        this.yAxisMinimumFixedValue = double.NaN;
611        this.yAxisMaximumAuto = true;
612        this.yAxisMaximumFixedValue = double.NaN;
613        this.secondYAxisMinimumAuto = true;
614        this.secondYAxisMinimumFixedValue = double.NaN;
615        this.secondYAxisMaximumAuto = true;
616        this.secondYAxisMaximumFixedValue = double.NaN;
617      }
618      #endregion
619    }
620  }
621}
Note: See TracBrowser for help on using the repository browser.