1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2016 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 |
|
---|
22 | using System;
|
---|
23 | using System.ComponentModel;
|
---|
24 | using System.Drawing;
|
---|
25 | using HeuristicLab.Common;
|
---|
26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
27 |
|
---|
28 | namespace 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 | StepLine
|
---|
42 | }
|
---|
43 | #endregion
|
---|
44 | #region LineStyle
|
---|
45 | public enum DataRowLineStyle {
|
---|
46 | Dash,
|
---|
47 | DashDot,
|
---|
48 | DashDotDot,
|
---|
49 | Dot,
|
---|
50 | NotSet,
|
---|
51 | Solid
|
---|
52 | }
|
---|
53 | #endregion
|
---|
54 | #region Histogram Aggregation
|
---|
55 | public enum DataRowHistogramAggregation {
|
---|
56 | Overlapping,
|
---|
57 | SideBySide,
|
---|
58 | Stacked
|
---|
59 | }
|
---|
60 | #endregion
|
---|
61 |
|
---|
62 | private DataRowChartType chartType;
|
---|
63 | public DataRowChartType ChartType {
|
---|
64 | get { return chartType; }
|
---|
65 | set {
|
---|
66 | if (chartType != value) {
|
---|
67 | chartType = value;
|
---|
68 | OnPropertyChanged("ChartType");
|
---|
69 | }
|
---|
70 | }
|
---|
71 | }
|
---|
72 | private bool secondYAxis;
|
---|
73 | public bool SecondYAxis {
|
---|
74 | get { return secondYAxis; }
|
---|
75 | set {
|
---|
76 | if (secondYAxis != value) {
|
---|
77 | secondYAxis = value;
|
---|
78 | OnPropertyChanged("SecondYAxis");
|
---|
79 | }
|
---|
80 | }
|
---|
81 | }
|
---|
82 | private bool secondXAxis;
|
---|
83 | public bool SecondXAxis {
|
---|
84 | get { return secondXAxis; }
|
---|
85 | set {
|
---|
86 | if (secondXAxis != value) {
|
---|
87 | secondXAxis = value;
|
---|
88 | OnPropertyChanged("SecondXAxis");
|
---|
89 | }
|
---|
90 | }
|
---|
91 | }
|
---|
92 | private Color color;
|
---|
93 | public Color Color {
|
---|
94 | get { return color; }
|
---|
95 | set {
|
---|
96 | if (color != value) {
|
---|
97 | color = value;
|
---|
98 | OnPropertyChanged("Color");
|
---|
99 | }
|
---|
100 | }
|
---|
101 | }
|
---|
102 | private DataRowLineStyle lineStyle;
|
---|
103 | public DataRowLineStyle LineStyle {
|
---|
104 | get { return lineStyle; }
|
---|
105 | set {
|
---|
106 | if (lineStyle != value) {
|
---|
107 | lineStyle = value;
|
---|
108 | OnPropertyChanged("LineStyle");
|
---|
109 | }
|
---|
110 | }
|
---|
111 | }
|
---|
112 | private bool startIndexZero;
|
---|
113 | public bool StartIndexZero {
|
---|
114 | get { return startIndexZero; }
|
---|
115 | set {
|
---|
116 | if (startIndexZero != value) {
|
---|
117 | startIndexZero = value;
|
---|
118 | OnPropertyChanged("StartIndexZero");
|
---|
119 | }
|
---|
120 | }
|
---|
121 | }
|
---|
122 | private int lineWidth;
|
---|
123 | public int LineWidth {
|
---|
124 | get { return lineWidth; }
|
---|
125 | set {
|
---|
126 | if (lineWidth != value) {
|
---|
127 | lineWidth = value;
|
---|
128 | OnPropertyChanged("LineWidth");
|
---|
129 | }
|
---|
130 | }
|
---|
131 | }
|
---|
132 | private int bins;
|
---|
133 | public int Bins {
|
---|
134 | get { return bins; }
|
---|
135 | set {
|
---|
136 | if (bins != value) {
|
---|
137 | bins = value;
|
---|
138 | OnPropertyChanged("Bins");
|
---|
139 | }
|
---|
140 | }
|
---|
141 | }
|
---|
142 | private bool exactBins;
|
---|
143 | public bool ExactBins {
|
---|
144 | get { return exactBins; }
|
---|
145 | set {
|
---|
146 | if (exactBins != value) {
|
---|
147 | exactBins = value;
|
---|
148 | OnPropertyChanged("ExactBins");
|
---|
149 | }
|
---|
150 | }
|
---|
151 | }
|
---|
152 | private DataRowHistogramAggregation aggregation;
|
---|
153 | public DataRowHistogramAggregation Aggregation {
|
---|
154 | get { return aggregation; }
|
---|
155 | set {
|
---|
156 | if (aggregation != value) {
|
---|
157 | aggregation = value;
|
---|
158 | OnPropertyChanged("Aggregation");
|
---|
159 | }
|
---|
160 | }
|
---|
161 | }
|
---|
162 | private double scaleFactor;
|
---|
163 | public double ScaleFactor {
|
---|
164 | get { return scaleFactor; }
|
---|
165 | set {
|
---|
166 | if (scaleFactor != value) {
|
---|
167 | scaleFactor = value;
|
---|
168 | OnPropertyChanged("ScaleFactor");
|
---|
169 | }
|
---|
170 | }
|
---|
171 | }
|
---|
172 | private bool isVisibleInLegend;
|
---|
173 | public bool IsVisibleInLegend {
|
---|
174 | get { return isVisibleInLegend; }
|
---|
175 | set {
|
---|
176 | if (isVisibleInLegend != value) {
|
---|
177 | isVisibleInLegend = value;
|
---|
178 | OnPropertyChanged("IsVisibleInLegend");
|
---|
179 | }
|
---|
180 | }
|
---|
181 | }
|
---|
182 | private string displayName;
|
---|
183 | public string DisplayName {
|
---|
184 | get { return displayName == null ? String.Empty : displayName; }
|
---|
185 | set {
|
---|
186 | if (displayName != value) {
|
---|
187 | if (value == null && displayName != String.Empty) {
|
---|
188 | displayName = String.Empty;
|
---|
189 | OnPropertyChanged("DisplayName");
|
---|
190 | } else if (value != null) {
|
---|
191 | displayName = value;
|
---|
192 | OnPropertyChanged("DisplayName");
|
---|
193 | }
|
---|
194 | }
|
---|
195 | }
|
---|
196 | }
|
---|
197 |
|
---|
198 | #region Persistence Properties
|
---|
199 | [Storable(Name = "ChartType")]
|
---|
200 | private DataRowChartType StorableChartType {
|
---|
201 | get { return chartType; }
|
---|
202 | set { chartType = value; }
|
---|
203 | }
|
---|
204 | [Storable(Name = "SecondYAxis")]
|
---|
205 | private bool StorableSecondYAxis {
|
---|
206 | get { return secondYAxis; }
|
---|
207 | set { secondYAxis = value; }
|
---|
208 | }
|
---|
209 | [Storable(Name = "SecondXAxis")]
|
---|
210 | private bool StorableSecondXAxis {
|
---|
211 | get { return secondXAxis; }
|
---|
212 | set { secondXAxis = value; }
|
---|
213 | }
|
---|
214 | [Storable(Name = "Color")]
|
---|
215 | private Color StorableColor {
|
---|
216 | get { return color; }
|
---|
217 | set { color = value; }
|
---|
218 | }
|
---|
219 | [Storable(Name = "LineStyle")]
|
---|
220 | private DataRowLineStyle StorableLineStyle {
|
---|
221 | get { return lineStyle; }
|
---|
222 | set { lineStyle = value; }
|
---|
223 | }
|
---|
224 | [Storable(Name = "StartIndexZero")]
|
---|
225 | private bool StorableStartIndexZero {
|
---|
226 | get { return startIndexZero; }
|
---|
227 | set { startIndexZero = value; }
|
---|
228 | }
|
---|
229 | [Storable(Name = "LineWidth")]
|
---|
230 | private int StorableLineWidth {
|
---|
231 | get { return lineWidth; }
|
---|
232 | set { lineWidth = value; }
|
---|
233 | }
|
---|
234 | [Storable(Name = "Bins")]
|
---|
235 | private int StorableBins {
|
---|
236 | get { return bins; }
|
---|
237 | set { bins = value; }
|
---|
238 | }
|
---|
239 | [Storable(Name = "ExactBins")]
|
---|
240 | private bool StorableExactBins {
|
---|
241 | get { return exactBins; }
|
---|
242 | set { exactBins = value; }
|
---|
243 | }
|
---|
244 | [Storable(Name = "Aggregation", DefaultValue = DataRowHistogramAggregation.Overlapping)]
|
---|
245 | private DataRowHistogramAggregation StorableAggregation {
|
---|
246 | get { return aggregation; }
|
---|
247 | set { aggregation = value; }
|
---|
248 | }
|
---|
249 | [Storable(Name = "ScaleFactor")]
|
---|
250 | private double StorableScaleFactor {
|
---|
251 | get { return scaleFactor; }
|
---|
252 | set { scaleFactor = value; }
|
---|
253 | }
|
---|
254 | [Storable(Name = "IsVisibleInLegend", DefaultValue = true)]
|
---|
255 | private bool StorableIsVisibleInLegend {
|
---|
256 | get { return isVisibleInLegend; }
|
---|
257 | set { isVisibleInLegend = value; }
|
---|
258 | }
|
---|
259 | [Storable(Name = "DisplayName")]
|
---|
260 | private string StorableDisplayName {
|
---|
261 | get { return displayName; }
|
---|
262 | set { displayName = value; }
|
---|
263 | }
|
---|
264 | #endregion
|
---|
265 |
|
---|
266 | [StorableConstructor]
|
---|
267 | protected DataRowVisualProperties(bool deserializing) : base() { }
|
---|
268 | protected DataRowVisualProperties(DataRowVisualProperties original, Cloner cloner)
|
---|
269 | : base(original, cloner) {
|
---|
270 | this.chartType = original.chartType;
|
---|
271 | this.secondYAxis = original.secondYAxis;
|
---|
272 | this.secondXAxis = original.secondXAxis;
|
---|
273 | this.color = original.color;
|
---|
274 | this.lineStyle = original.lineStyle;
|
---|
275 | this.startIndexZero = original.startIndexZero;
|
---|
276 | this.lineWidth = original.lineWidth;
|
---|
277 | this.bins = original.bins;
|
---|
278 | this.exactBins = original.exactBins;
|
---|
279 | this.aggregation = original.aggregation;
|
---|
280 | this.scaleFactor = original.scaleFactor;
|
---|
281 | this.displayName = original.displayName;
|
---|
282 | this.isVisibleInLegend = original.isVisibleInLegend;
|
---|
283 | }
|
---|
284 | public DataRowVisualProperties() {
|
---|
285 | chartType = DataRowChartType.Line;
|
---|
286 | secondYAxis = false;
|
---|
287 | secondXAxis = false;
|
---|
288 | color = Color.Empty;
|
---|
289 | lineStyle = DataRowLineStyle.Solid;
|
---|
290 | startIndexZero = false;
|
---|
291 | lineWidth = 1;
|
---|
292 | bins = 10;
|
---|
293 | exactBins = false;
|
---|
294 | aggregation = DataRowHistogramAggregation.Overlapping;
|
---|
295 | scaleFactor = 1.0;
|
---|
296 | displayName = String.Empty;
|
---|
297 | isVisibleInLegend = true;
|
---|
298 | }
|
---|
299 | public DataRowVisualProperties(string displayName)
|
---|
300 | : this() {
|
---|
301 | this.displayName = displayName;
|
---|
302 | }
|
---|
303 |
|
---|
304 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
305 | return new DataRowVisualProperties(this, cloner);
|
---|
306 | }
|
---|
307 |
|
---|
308 | public event PropertyChangedEventHandler PropertyChanged;
|
---|
309 | protected virtual void OnPropertyChanged(string propertyName) {
|
---|
310 | PropertyChangedEventHandler handler = PropertyChanged;
|
---|
311 | if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
---|
312 | }
|
---|
313 |
|
---|
314 | [StorableHook(HookType.AfterDeserialization)]
|
---|
315 | private void AfterDeserialization() {
|
---|
316 | // BackwardsCompatibility3.3
|
---|
317 | #region Backwards compatible code, remove with 3.4
|
---|
318 | if (secondXAxis == default(bool)
|
---|
319 | && lineStyle == default(DataRowLineStyle)
|
---|
320 | && lineWidth == default(int) && bins == default(int) && exactBins == default(bool)
|
---|
321 | && displayName == default(string)) {
|
---|
322 | secondXAxis = false;
|
---|
323 | lineStyle = DataRowLineStyle.Solid;
|
---|
324 | lineWidth = 1;
|
---|
325 | bins = 10;
|
---|
326 | exactBins = false;
|
---|
327 | displayName = String.Empty;
|
---|
328 | }
|
---|
329 | #endregion
|
---|
330 | }
|
---|
331 | }
|
---|
332 | }
|
---|