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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.ComponentModel;
|
---|
25 | using HeuristicLab.Collections;
|
---|
26 | using HeuristicLab.Common;
|
---|
27 | using HeuristicLab.Core;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Analysis {
|
---|
31 | /// <summary>
|
---|
32 | /// A row of data values for a scatter plot.
|
---|
33 | /// </summary>
|
---|
34 | [Item("ScatterPlotDataRow", "A row of data values for a scatter plot.")]
|
---|
35 | [StorableClass("C4D54853-19FF-461D-8873-041383226999")]
|
---|
36 | public class ScatterPlotDataRow : NamedItem {
|
---|
37 | private ScatterPlotDataRowVisualProperties visualProperties;
|
---|
38 | public ScatterPlotDataRowVisualProperties VisualProperties {
|
---|
39 | get { return visualProperties; }
|
---|
40 | set {
|
---|
41 | if (visualProperties != value) {
|
---|
42 | if (value == null) throw new ArgumentNullException("VisualProperties");
|
---|
43 | if (visualProperties != null) visualProperties.PropertyChanged -= new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
|
---|
44 | visualProperties = value;
|
---|
45 | visualProperties.PropertyChanged += new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
|
---|
46 | OnVisualPropertiesChanged();
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
50 | private ObservableList<Point2D<double>> points;
|
---|
51 | public ObservableList<Point2D<double>> Points {
|
---|
52 | get { return points; }
|
---|
53 | }
|
---|
54 |
|
---|
55 | #region Persistence Properties
|
---|
56 | [Storable(Name = "VisualProperties")]
|
---|
57 | private ScatterPlotDataRowVisualProperties StorableVisualProperties {
|
---|
58 | get { return visualProperties; }
|
---|
59 | set {
|
---|
60 | visualProperties = value;
|
---|
61 | visualProperties.PropertyChanged += new PropertyChangedEventHandler(VisualProperties_PropertyChanged);
|
---|
62 | }
|
---|
63 | }
|
---|
64 | [Storable(Name = "Points")]
|
---|
65 | private IEnumerable<Point2D<double>> StorablePoints {
|
---|
66 | get { return points; }
|
---|
67 | set { points = new ObservableList<Point2D<double>>(value); }
|
---|
68 | }
|
---|
69 | #endregion
|
---|
70 |
|
---|
71 | [StorableConstructor]
|
---|
72 | protected ScatterPlotDataRow(bool deserializing) : base(deserializing) { }
|
---|
73 | protected ScatterPlotDataRow(ScatterPlotDataRow original, Cloner cloner)
|
---|
74 | : base(original, cloner) {
|
---|
75 | VisualProperties = cloner.Clone(original.visualProperties);
|
---|
76 | points = new ObservableList<Point2D<double>>(original.points);
|
---|
77 | }
|
---|
78 | public ScatterPlotDataRow()
|
---|
79 | : base() {
|
---|
80 | Name = "ScatterPlotDataRow";
|
---|
81 | VisualProperties = new ScatterPlotDataRowVisualProperties();
|
---|
82 | points = new ObservableList<Point2D<double>>();
|
---|
83 | }
|
---|
84 | public ScatterPlotDataRow(string name, string description, IEnumerable<Point2D<double>> points)
|
---|
85 | : base(name, description) {
|
---|
86 | VisualProperties = new ScatterPlotDataRowVisualProperties(name);
|
---|
87 | this.points = new ObservableList<Point2D<double>>(points);
|
---|
88 | }
|
---|
89 | public ScatterPlotDataRow(string name, string description, IEnumerable<Point2D<double>> points, ScatterPlotDataRowVisualProperties visualProperties)
|
---|
90 | : base(name, description) {
|
---|
91 | VisualProperties = visualProperties;
|
---|
92 | this.points = new ObservableList<Point2D<double>>(points);
|
---|
93 | }
|
---|
94 |
|
---|
95 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
96 | return new ScatterPlotDataRow(this, cloner);
|
---|
97 | }
|
---|
98 |
|
---|
99 | public event EventHandler VisualPropertiesChanged;
|
---|
100 | protected virtual void OnVisualPropertiesChanged() {
|
---|
101 | EventHandler handler = VisualPropertiesChanged;
|
---|
102 | if (handler != null) handler(this, EventArgs.Empty);
|
---|
103 | }
|
---|
104 |
|
---|
105 | private void VisualProperties_PropertyChanged(object sender, PropertyChangedEventArgs e) {
|
---|
106 | OnVisualPropertiesChanged();
|
---|
107 | }
|
---|
108 | }
|
---|
109 | }
|
---|