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