Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2989_MovingPeaksBenchmark/HeuristicLab.Analysis/3.3/DataVisualization/ScatterPlotVisualProperties.cs @ 17514

Last change on this file since 17514 was 15583, checked in by swagner, 7 years ago

#2640: Updated year of copyrights in license headers

File size: 11.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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 ScatterPlot.
30  /// </summary>
31  [StorableClass]
32  public class ScatterPlotVisualProperties : 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 bool xAxisGrid;
110    public bool XAxisGrid {
111      get { return xAxisGrid; }
112      set {
113        if (xAxisGrid != value) {
114          xAxisGrid = value;
115          OnPropertyChanged("XAxisGrid");
116        }
117      }
118    }
119
120    private bool yAxisGrid;
121    public bool YAxisGrid {
122      get { return yAxisGrid; }
123      set {
124        if (yAxisGrid != value) {
125          yAxisGrid = value;
126          OnPropertyChanged("YAxisGrid");
127        }
128      }
129    }
130
131    private bool xAxisMinimumAuto;
132    public bool XAxisMinimumAuto {
133      get { return xAxisMinimumAuto; }
134      set {
135        if (xAxisMinimumAuto != value) {
136          xAxisMinimumAuto = value;
137          if (value) xAxisMinimumFixedValue = double.NaN;
138          OnPropertyChanged("XAxisMinimumAuto");
139        }
140      }
141    }
142
143    private bool xAxisMaximumAuto;
144    public bool XAxisMaximumAuto {
145      get { return xAxisMaximumAuto; }
146      set {
147        if (xAxisMaximumAuto != value) {
148          xAxisMaximumAuto = value;
149          if (value) xAxisMaximumFixedValue = double.NaN;
150          OnPropertyChanged("XAxisMaximumAuto");
151        }
152      }
153    }
154
155    private double xAxisMinimumFixedValue;
156    public double XAxisMinimumFixedValue {
157      get { return xAxisMinimumFixedValue; }
158      set {
159        if (xAxisMinimumFixedValue != value) {
160          xAxisMinimumFixedValue = value;
161          OnPropertyChanged("XAxisMinimumFixedValue");
162        }
163      }
164    }
165
166    private double xAxisMaximumFixedValue;
167    public double XAxisMaximumFixedValue {
168      get { return xAxisMaximumFixedValue; }
169      set {
170        if (xAxisMaximumFixedValue != value) {
171          xAxisMaximumFixedValue = value;
172          OnPropertyChanged("XAxisMaximumFixedValue");
173        }
174      }
175    }
176
177    private bool yAxisMinimumAuto;
178    public bool YAxisMinimumAuto {
179      get { return yAxisMinimumAuto; }
180      set {
181        if (yAxisMinimumAuto != value) {
182          yAxisMinimumAuto = value;
183          if (value) yAxisMinimumFixedValue = double.NaN;
184          OnPropertyChanged("YAxisMinimumAuto");
185        }
186      }
187    }
188
189    private bool yAxisMaximumAuto;
190    public bool YAxisMaximumAuto {
191      get { return yAxisMaximumAuto; }
192      set {
193        if (yAxisMaximumAuto != value) {
194          yAxisMaximumAuto = value;
195          if (value) yAxisMaximumFixedValue = double.NaN;
196          OnPropertyChanged("YAxisMaximumAuto");
197        }
198      }
199    }
200
201    private double yAxisMinimumFixedValue;
202    public double YAxisMinimumFixedValue {
203      get { return yAxisMinimumFixedValue; }
204      set {
205        if (yAxisMinimumFixedValue != value) {
206          yAxisMinimumFixedValue = value;
207          OnPropertyChanged("YAxisMinimumFixedValue");
208        }
209      }
210    }
211
212    private double yAxisMaximumFixedValue;
213    public double YAxisMaximumFixedValue {
214      get { return yAxisMaximumFixedValue; }
215      set {
216        if (yAxisMaximumFixedValue != value) {
217          yAxisMaximumFixedValue = value;
218          OnPropertyChanged("YAxisMaximumFixedValue");
219        }
220      }
221    }
222
223    #region Persistence Properties
224    [Storable(Name = "TitleFont")]
225    private Font StorableTitleFont {
226      get { return titleFont; }
227      set { titleFont = value; }
228    }
229    [Storable(Name = "TitleColor")]
230    private Color StorableTitleColor {
231      get { return titleColor; }
232      set { titleColor = value; }
233    }
234    [Storable(Name = "Title")]
235    private string StorableTitle {
236      get { return title; }
237      set { title = value; }
238    }
239    [Storable(Name = "AxisTitleFont")]
240    private Font StorableAxisTitleFont {
241      get { return axisTitleFont; }
242      set { axisTitleFont = value; }
243    }
244    [Storable(Name = "AxisTitleColor")]
245    private Color StorableAxisTitleColor {
246      get { return axisTitleColor; }
247      set { axisTitleColor = value; }
248    }
249    [Storable(Name = "XAxisTitle")]
250    private string StorableXAxisTitle {
251      get { return xAxisTitle; }
252      set { xAxisTitle = value; }
253    }
254    [Storable(Name = "YAxisTitle")]
255    private string StorableYAxisTitle {
256      get { return yAxisTitle; }
257      set { yAxisTitle = value; }
258    }
259    [Storable(Name = "XAxisGrid")]
260    private bool StorableXAxisGrid {
261      get { return xAxisGrid; }
262      set { xAxisGrid = value; }
263    }
264    [Storable(Name = "YAxisGrid")]
265    private bool StorableYAxisGrid {
266      get { return yAxisGrid; }
267      set { yAxisGrid = value; }
268    }
269    [Storable(Name = "XAxisMinimumAuto")]
270    private bool StorableXAxisMinimumAuto {
271      get { return xAxisMinimumAuto; }
272      set { xAxisMinimumAuto = value; }
273    }
274    [Storable(Name = "XAxisMaximumAuto")]
275    private bool StorableXAxisMaximumAuto {
276      get { return xAxisMaximumAuto; }
277      set { xAxisMaximumAuto = value; }
278    }
279    [Storable(Name = "XAxisMinimumFixedValue")]
280    private double StorableXAxisMinimumFixedValue {
281      get { return xAxisMinimumFixedValue; }
282      set { xAxisMinimumFixedValue = value; }
283    }
284    [Storable(Name = "XAxisMaximumFixedValue")]
285    private double StorableXAxisMaximumFixedValue {
286      get { return xAxisMaximumFixedValue; }
287      set { xAxisMaximumFixedValue = value; }
288    }
289    [Storable(Name = "YAxisMinimumAuto")]
290    private bool StorableYAxisMinimumAuto {
291      get { return yAxisMinimumAuto; }
292      set { yAxisMinimumAuto = value; }
293    }
294    [Storable(Name = "YAxisMaximumAuto")]
295    private bool StorableYAxisMaximumAuto {
296      get { return yAxisMaximumAuto; }
297      set { yAxisMaximumAuto = value; }
298    }
299    [Storable(Name = "YAxisMinimumFixedValue")]
300    private double StorableYAxisMinimumFixedValue {
301      get { return yAxisMinimumFixedValue; }
302      set { yAxisMinimumFixedValue = value; }
303    }
304    [Storable(Name = "YAxisMaximumFixedValue")]
305    private double StorableYAxisMaximumFixedValue {
306      get { return yAxisMaximumFixedValue; }
307      set { yAxisMaximumFixedValue = value; }
308    }
309    #endregion
310
311    [StorableConstructor]
312    protected ScatterPlotVisualProperties(bool deserializing) : base() { }
313    protected ScatterPlotVisualProperties(ScatterPlotVisualProperties original, Cloner cloner)
314      : base(original, cloner) {
315      if (original.titleFont != null)
316        this.titleFont = (Font)original.titleFont.Clone();
317      if (original.axisTitleFont != null)
318        this.axisTitleFont = (Font)original.axisTitleFont.Clone();
319      this.title = original.title;
320      this.xAxisTitle = original.xAxisTitle;
321      this.yAxisTitle = original.yAxisTitle;
322      this.xAxisGrid = original.xAxisGrid;
323      this.yAxisGrid = original.yAxisGrid;
324      this.xAxisMinimumAuto = original.xAxisMinimumAuto;
325      this.xAxisMinimumFixedValue = original.xAxisMinimumFixedValue;
326      this.xAxisMaximumAuto = original.xAxisMaximumAuto;
327      this.xAxisMaximumFixedValue = original.xAxisMaximumFixedValue;
328      this.yAxisMinimumAuto = original.yAxisMinimumAuto;
329      this.yAxisMinimumFixedValue = original.yAxisMinimumFixedValue;
330      this.yAxisMaximumAuto = original.yAxisMaximumAuto;
331      this.yAxisMaximumFixedValue = original.yAxisMaximumFixedValue;
332    }
333    public ScatterPlotVisualProperties() {
334      this.titleColor = Color.Black;
335      this.axisTitleColor = Color.Black;
336      this.title = string.Empty;
337      this.xAxisTitle = string.Empty;
338      this.yAxisTitle = string.Empty;
339      this.xAxisGrid = true;
340      this.yAxisGrid = true;
341      this.xAxisMinimumAuto = true;
342      this.xAxisMinimumFixedValue = double.NaN;
343      this.xAxisMaximumAuto = true;
344      this.xAxisMaximumFixedValue = double.NaN;
345      this.yAxisMinimumAuto = true;
346      this.yAxisMinimumFixedValue = double.NaN;
347      this.yAxisMaximumAuto = true;
348      this.yAxisMaximumFixedValue = double.NaN;
349    }
350    public ScatterPlotVisualProperties(string title)
351      : this() {
352      this.title = title;
353    }
354
355    public override IDeepCloneable Clone(Cloner cloner) {
356      return new ScatterPlotVisualProperties(this, cloner);
357    }
358
359    public event PropertyChangedEventHandler PropertyChanged;
360    protected virtual void OnPropertyChanged(string propertyName) {
361      PropertyChangedEventHandler handler = PropertyChanged;
362      if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
363    }
364  }
365}
Note: See TracBrowser for help on using the repository browser.