source: branches/histogram/HeuristicLab.Analysis/3.3/DataVisualization/DataTableVisualProperties.cs @ 6020

Last change on this file since 6020 was 6020, checked in by abeham, 9 years ago

#1465

  • Fixed some bugs
  • Fixed out-of-sync issue in DataRowVisualPropertiesControl
  • Added border in histogram (white for very dark colors)
  • Added serializer for System.Drawing.Font
  • Added option to choose the font of the title as well as the axis of the chart
File size: 16.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.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 Font axisTitleFont;
55    public Font AxisTitleFont {
56      get { return axisTitleFont; }
57      set {
58        if (axisTitleFont == null || axisTitleFont == null
59          || axisTitleFont.Name != value.Name || axisTitleFont.Size != value.Size || axisTitleFont.Style != value.Style) {
60          axisTitleFont = value;
61          OnPropertyChanged("AxisTitleFont");
62        }
63      }
64    }
65    private Color axisTitleColor;
66    public Color AxisTitleColor {
67      get { return axisTitleColor; }
68      set {
69        if (axisTitleColor != value) {
70          axisTitleColor = value;
71          OnPropertyChanged("AxisTitleColor");
72        }
73      }
74    }
75    private string xAxisTitle;
76    public string XAxisTitle {
77      get { return xAxisTitle; }
78      set {
79        if (value == null) value = string.Empty;
80        if (xAxisTitle != value) {
81          xAxisTitle = value;
82          OnPropertyChanged("XAxisTitle");
83        }
84      }
85    }
86
87    private string yAxisTitle;
88    public string YAxisTitle {
89      get { return yAxisTitle; }
90      set {
91        if (value == null) value = string.Empty;
92        if (yAxisTitle != value) {
93          yAxisTitle = value;
94          OnPropertyChanged("YAxisTitle");
95        }
96      }
97    }
98
99    private string secondXAxisTitle;
100    public string SecondXAxisTitle {
101      get { return secondXAxisTitle; }
102      set {
103        if (value == null) value = string.Empty;
104        if (secondXAxisTitle != value) {
105          secondXAxisTitle = value;
106          OnPropertyChanged("SecondXAxisTitle");
107        }
108      }
109    }
110
111    private string secondYAxisTitle;
112    public string SecondYAxisTitle {
113      get { return secondYAxisTitle; }
114      set {
115        if (value == null) value = string.Empty;
116        if (secondYAxisTitle != value) {
117          secondYAxisTitle = value;
118          OnPropertyChanged("SecondYAxisTitle");
119        }
120      }
121    }
122
123    private bool xAxisMinimumAuto;
124    public bool XAxisMinimumAuto {
125      get { return xAxisMinimumAuto; }
126      set {
127        if (xAxisMinimumAuto != value) {
128          xAxisMinimumAuto = value;
129          if (value) xAxisMinimumFixedValue = double.NaN;
130          OnPropertyChanged("XAxisMinimumAuto");
131        }
132      }
133    }
134
135    private bool xAxisMaximumAuto;
136    public bool XAxisMaximumAuto {
137      get { return xAxisMaximumAuto; }
138      set {
139        if (xAxisMaximumAuto != value) {
140          xAxisMaximumAuto = value;
141          if (value) xAxisMaximumFixedValue = double.NaN;
142          OnPropertyChanged("XAxisMaximumAuto");
143        }
144      }
145    }
146
147    private double xAxisMinimumFixedValue;
148    public double XAxisMinimumFixedValue {
149      get { return xAxisMinimumFixedValue; }
150      set {
151        if (xAxisMinimumFixedValue != value) {
152          xAxisMinimumFixedValue = value;
153          OnPropertyChanged("XAxisMinimumFixedValue");
154        }
155      }
156    }
157
158    private double xAxisMaximumFixedValue;
159    public double XAxisMaximumFixedValue {
160      get { return xAxisMaximumFixedValue; }
161      set {
162        if (xAxisMaximumFixedValue != value) {
163          xAxisMaximumFixedValue = value;
164          OnPropertyChanged("XAxisMaximumFixedValue");
165        }
166      }
167    }
168
169    private bool secondXAxisMinimumAuto;
170    public bool SecondXAxisMinimumAuto {
171      get { return secondXAxisMinimumAuto; }
172      set {
173        if (secondXAxisMinimumAuto != value) {
174          secondXAxisMinimumAuto = value;
175          if (value) secondXAxisMinimumFixedValue = double.NaN;
176          OnPropertyChanged("SecondXAxisMinimumAuto");
177        }
178      }
179    }
180
181    private bool secondXAxisMaximumAuto;
182    public bool SecondXAxisMaximumAuto {
183      get { return secondXAxisMaximumAuto; }
184      set {
185        if (secondXAxisMaximumAuto != value) {
186          secondXAxisMaximumAuto = value;
187          if (value) secondXAxisMaximumFixedValue = double.NaN;
188          OnPropertyChanged("SecondXAxisMaximumAuto");
189        }
190      }
191    }
192
193    private double secondXAxisMinimumFixedValue;
194    public double SecondXAxisMinimumFixedValue {
195      get { return secondXAxisMinimumFixedValue; }
196      set {
197        if (secondXAxisMinimumFixedValue != value) {
198          secondXAxisMinimumFixedValue = value;
199          OnPropertyChanged("SecondXAxisMinimumFixedValue");
200        }
201      }
202    }
203
204    private double secondXAxisMaximumFixedValue;
205    public double SecondXAxisMaximumFixedValue {
206      get { return secondXAxisMaximumFixedValue; }
207      set {
208        if (secondXAxisMaximumFixedValue != value) {
209          secondXAxisMaximumFixedValue = value;
210          OnPropertyChanged("SecondXAxisMaximumFixedValue");
211        }
212      }
213    }
214
215    private bool yAxisMinimumAuto;
216    public bool YAxisMinimumAuto {
217      get { return yAxisMinimumAuto; }
218      set {
219        if (yAxisMinimumAuto != value) {
220          yAxisMinimumAuto = value;
221          if (value) yAxisMinimumFixedValue = double.NaN;
222          OnPropertyChanged("YAxisMinimumAuto");
223        }
224      }
225    }
226
227    private bool yAxisMaximumAuto;
228    public bool YAxisMaximumAuto {
229      get { return yAxisMaximumAuto; }
230      set {
231        if (yAxisMaximumAuto != value) {
232          yAxisMaximumAuto = value;
233          if (value) yAxisMaximumFixedValue = double.NaN;
234          OnPropertyChanged("YAxisMaximumAuto");
235        }
236      }
237    }
238
239    private double yAxisMinimumFixedValue;
240    public double YAxisMinimumFixedValue {
241      get { return yAxisMinimumFixedValue; }
242      set {
243        if (yAxisMinimumFixedValue != value) {
244          yAxisMinimumFixedValue = value;
245          OnPropertyChanged("YAxisMinimumFixedValue");
246        }
247      }
248    }
249
250    private double yAxisMaximumFixedValue;
251    public double YAxisMaximumFixedValue {
252      get { return yAxisMaximumFixedValue; }
253      set {
254        if (yAxisMaximumFixedValue != value) {
255          yAxisMaximumFixedValue = value;
256          OnPropertyChanged("YAxisMaximumFixedValue");
257        }
258      }
259    }
260
261    private bool secondYAxisMinimumAuto;
262    public bool SecondYAxisMinimumAuto {
263      get { return secondYAxisMinimumAuto; }
264      set {
265        if (secondYAxisMinimumAuto != value) {
266          secondYAxisMinimumAuto = value;
267          if (value) secondYAxisMinimumFixedValue = double.NaN;
268          OnPropertyChanged("SecondYAxisMinimumAuto");
269        }
270      }
271    }
272
273    private bool secondYAxisMaximumAuto;
274    public bool SecondYAxisMaximumAuto {
275      get { return secondYAxisMaximumAuto; }
276      set {
277        if (secondYAxisMaximumAuto != value) {
278          secondYAxisMaximumAuto = value;
279          if (value) secondYAxisMaximumFixedValue = double.NaN;
280          OnPropertyChanged("SecondYAxisMaximumAuto");
281        }
282      }
283    }
284
285    private double secondYAxisMinimumFixedValue;
286    public double SecondYAxisMinimumFixedValue {
287      get { return secondYAxisMinimumFixedValue; }
288      set {
289        if (secondYAxisMinimumFixedValue != value) {
290          secondYAxisMinimumFixedValue = value;
291          OnPropertyChanged("SecondYAxisMinimumFixedValue");
292        }
293      }
294    }
295
296    private double secondYAxisMaximumFixedValue;
297    public double SecondYAxisMaximumFixedValue {
298      get { return secondYAxisMaximumFixedValue; }
299      set {
300        if (secondYAxisMaximumFixedValue != value) {
301          secondYAxisMaximumFixedValue = value;
302          OnPropertyChanged("SecondYAxisMaximumFixedValue");
303        }
304      }
305    }
306
307    #region Persistence Properties
308    [Storable(Name = "TitleFont")]
309    private Font StorableTitleFont {
310      get { return titleFont; }
311      set { titleFont = value; }
312    }
313    [Storable(Name = "TitleColor")]
314    private Color StorableTitleColor {
315      get { return titleColor; }
316      set { titleColor = value; }
317    }
318    [Storable(Name = "AxisTitleFont")]
319    private Font StorableAxisTitleFont {
320      get { return axisTitleFont; }
321      set { axisTitleFont = value; }
322    }
323    [Storable(Name = "AxisTitleColor")]
324    private Color StorableAxisTitleColor {
325      get { return axisTitleColor; }
326      set { axisTitleColor = value; }
327    }
328    [Storable(Name = "XAxisTitle")]
329    private string StorableXAxisTitle {
330      get { return xAxisTitle; }
331      set { xAxisTitle = value; }
332    }
333    [Storable(Name = "YAxisTitle")]
334    private string StorableYAxisTitle {
335      get { return yAxisTitle; }
336      set { yAxisTitle = value; }
337    }
338    [Storable(Name = "SecondXAxisTitle")]
339    private string StorableSecondXAxisTitle {
340      get { return secondXAxisTitle; }
341      set { secondXAxisTitle = value; }
342    }
343    [Storable(Name = "SecondYAxisTitle")]
344    private string StorableSecondYAxisTitle {
345      get { return secondYAxisTitle; }
346      set { secondYAxisTitle = value; }
347    }
348    [Storable(Name = "XAxisMinimumAuto")]
349    private bool StorableXAxisMinimumAuto {
350      get { return xAxisMinimumAuto; }
351      set { xAxisMinimumAuto = value; }
352    }
353    [Storable(Name = "XAxisMaximumAuto")]
354    private bool StorableXAxisMaximumAuto {
355      get { return xAxisMaximumAuto; }
356      set { xAxisMaximumAuto = value; }
357    }
358    [Storable(Name = "XAxisMinimumFixedValue")]
359    private double StorableXAxisMinimumFixedValue {
360      get { return xAxisMinimumFixedValue; }
361      set { xAxisMinimumFixedValue = value; }
362    }
363    [Storable(Name = "XAxisMaximumFixedValue")]
364    private double StorableXAxisMaximumFixedValue {
365      get { return xAxisMaximumFixedValue; }
366      set { xAxisMaximumFixedValue = value; }
367    }
368    [Storable(Name = "SecondXAxisMinimumAuto")]
369    private bool StorableSecondXAxisMinimumAuto {
370      get { return secondXAxisMinimumAuto; }
371      set { secondXAxisMinimumAuto = value; }
372    }
373    [Storable(Name = "SecondXAxisMaximumAuto")]
374    private bool StorableSecondXAxisMaximumAuto {
375      get { return secondXAxisMaximumAuto; }
376      set { secondXAxisMaximumAuto = value; }
377    }
378    [Storable(Name = "SecondXAxisMinimumFixedValue")]
379    private double StorableSecondXAxisMinimumFixedValue {
380      get { return secondXAxisMinimumFixedValue; }
381      set { secondXAxisMinimumFixedValue = value; }
382    }
383    [Storable(Name = "SecondXAxisMaximumFixedValue")]
384    private double StorableSecondXAxisMaximumFixedValue {
385      get { return secondXAxisMaximumFixedValue; }
386      set { secondXAxisMaximumFixedValue = value; }
387    }
388    [Storable(Name = "YAxisMinimumAuto")]
389    private bool StorableYAxisMinimumAuto {
390      get { return yAxisMinimumAuto; }
391      set { yAxisMinimumAuto = value; }
392    }
393    [Storable(Name = "YAxisMaximumAuto")]
394    private bool StorableYAxisMaximumAuto {
395      get { return yAxisMaximumAuto; }
396      set { yAxisMaximumAuto = value; }
397    }
398    [Storable(Name = "YAxisMinimumFixedValue")]
399    private double StorableYAxisMinimumFixedValue {
400      get { return yAxisMinimumFixedValue; }
401      set { yAxisMinimumFixedValue = value; }
402    }
403    [Storable(Name = "YAxisMaximumFixedValue")]
404    private double StorableYAxisMaximumFixedValue {
405      get { return yAxisMaximumFixedValue; }
406      set { yAxisMaximumFixedValue = value; }
407    }
408    [Storable(Name = "SecondYAxisMinimumAuto")]
409    private bool StorableSecondYAxisMinimumAuto {
410      get { return secondYAxisMinimumAuto; }
411      set { secondYAxisMinimumAuto = value; }
412    }
413    [Storable(Name = "SecondYAxisMaximumAuto")]
414    private bool StorableSecondYAxisMaximumAuto {
415      get { return secondYAxisMaximumAuto; }
416      set { secondYAxisMaximumAuto = value; }
417    }
418    [Storable(Name = "SecondYAxisMinimumFixedValue")]
419    private double StorableSecondYAxisMinimumFixedValue {
420      get { return secondYAxisMinimumFixedValue; }
421      set { secondYAxisMinimumFixedValue = value; }
422    }
423    [Storable(Name = "SecondYAxisMaximumFixedValue")]
424    private double StorableSecondYAxisMaximumFixedValue {
425      get { return secondYAxisMaximumFixedValue; }
426      set { secondYAxisMaximumFixedValue = value; }
427    }
428    #endregion
429
430    [StorableConstructor]
431    protected DataTableVisualProperties(bool deserializing) : base() { }
432    protected DataTableVisualProperties(DataTableVisualProperties original, Cloner cloner)
433      : base(original, cloner) {
434      if (original.titleFont != null)
435        this.titleFont = (Font)original.titleFont.Clone();
436      if (original.axisTitleFont != null)
437        this.axisTitleFont = (Font)original.axisTitleFont.Clone();
438      this.xAxisTitle = original.xAxisTitle;
439      this.yAxisTitle = original.yAxisTitle;
440      this.secondXAxisTitle = original.secondXAxisTitle;
441      this.secondYAxisTitle = original.secondYAxisTitle;
442      this.xAxisMinimumAuto = original.xAxisMinimumAuto;
443      this.xAxisMinimumFixedValue = original.xAxisMinimumFixedValue;
444      this.xAxisMaximumAuto = original.xAxisMaximumAuto;
445      this.xAxisMaximumFixedValue = original.xAxisMaximumFixedValue;
446      this.secondXAxisMinimumAuto = original.secondXAxisMinimumAuto;
447      this.secondXAxisMinimumFixedValue = original.secondXAxisMinimumFixedValue;
448      this.secondXAxisMaximumAuto = original.secondXAxisMaximumAuto;
449      this.secondXAxisMaximumFixedValue = original.secondXAxisMaximumFixedValue;
450      this.yAxisMinimumAuto = original.yAxisMinimumAuto;
451      this.yAxisMinimumFixedValue = original.yAxisMinimumFixedValue;
452      this.yAxisMaximumAuto = original.yAxisMaximumAuto;
453      this.yAxisMaximumFixedValue = original.yAxisMaximumFixedValue;
454      this.secondYAxisMinimumAuto = original.secondYAxisMinimumAuto;
455      this.secondYAxisMinimumFixedValue = original.secondYAxisMinimumFixedValue;
456      this.secondYAxisMaximumAuto = original.secondYAxisMaximumAuto;
457      this.secondYAxisMaximumFixedValue = original.secondYAxisMaximumFixedValue;
458    }
459    public DataTableVisualProperties() {
460      titleColor = Color.Black;
461      axisTitleColor = Color.Black;
462      this.xAxisTitle = string.Empty;
463      this.yAxisTitle = string.Empty;
464      this.secondXAxisTitle = string.Empty;
465      this.secondYAxisTitle = string.Empty;
466      this.xAxisMinimumAuto = true;
467      this.xAxisMinimumFixedValue = double.NaN;
468      this.xAxisMaximumAuto = true;
469      this.xAxisMaximumFixedValue = double.NaN;
470      this.secondXAxisMinimumAuto = true;
471      this.secondXAxisMinimumFixedValue = double.NaN;
472      this.secondXAxisMaximumAuto = true;
473      this.secondXAxisMaximumFixedValue = double.NaN;
474      this.yAxisMinimumAuto = true;
475      this.yAxisMinimumFixedValue = double.NaN;
476      this.yAxisMaximumAuto = true;
477      this.yAxisMaximumFixedValue = double.NaN;
478      this.secondYAxisMinimumAuto = true;
479      this.secondYAxisMinimumFixedValue = double.NaN;
480      this.secondYAxisMaximumAuto = true;
481      this.secondYAxisMaximumFixedValue = double.NaN;
482    }
483
484    public override IDeepCloneable Clone(Cloner cloner) {
485      return new DataTableVisualProperties(this, cloner);
486    }
487
488    public event PropertyChangedEventHandler PropertyChanged;
489    protected virtual void OnPropertyChanged(string propertyName) {
490      PropertyChangedEventHandler handler = PropertyChanged;
491      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
492    }
493  }
494}
Note: See TracBrowser for help on using the repository browser.