[4644] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[5445] | 3 | * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[4644] | 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 |
|
---|
[6760] | 22 | using System;
|
---|
[4644] | 23 | using System.ComponentModel;
|
---|
[4722] | 24 | using System.Drawing;
|
---|
[4644] | 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,
|
---|
[6760] | 39 | Bars,
|
---|
| 40 | Histogram
|
---|
[4644] | 41 | }
|
---|
| 42 | #endregion
|
---|
[6760] | 43 | #region LineStyle
|
---|
| 44 | public enum DataRowLineStyle {
|
---|
| 45 | Dash,
|
---|
| 46 | DashDot,
|
---|
| 47 | DashDotDot,
|
---|
| 48 | Dot,
|
---|
| 49 | NotSet,
|
---|
| 50 | Solid
|
---|
| 51 | }
|
---|
| 52 | #endregion
|
---|
[4644] | 53 |
|
---|
| 54 | private DataRowChartType chartType;
|
---|
| 55 | public DataRowChartType ChartType {
|
---|
| 56 | get { return chartType; }
|
---|
| 57 | set {
|
---|
| 58 | if (chartType != value) {
|
---|
| 59 | chartType = value;
|
---|
| 60 | OnPropertyChanged("ChartType");
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | private bool secondYAxis;
|
---|
| 65 | public bool SecondYAxis {
|
---|
| 66 | get { return secondYAxis; }
|
---|
| 67 | set {
|
---|
| 68 | if (secondYAxis != value) {
|
---|
| 69 | secondYAxis = value;
|
---|
| 70 | OnPropertyChanged("SecondYAxis");
|
---|
| 71 | }
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
[6760] | 74 | private bool secondXAxis;
|
---|
| 75 | public bool SecondXAxis {
|
---|
| 76 | get { return secondXAxis; }
|
---|
| 77 | set {
|
---|
| 78 | if (secondXAxis != value) {
|
---|
| 79 | secondXAxis = value;
|
---|
| 80 | OnPropertyChanged("SecondXAxis");
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
[4648] | 84 | private Color color;
|
---|
| 85 | public Color Color {
|
---|
| 86 | get { return color; }
|
---|
| 87 | set {
|
---|
| 88 | if (color != value) {
|
---|
| 89 | color = value;
|
---|
| 90 | OnPropertyChanged("Color");
|
---|
| 91 | }
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
[6760] | 94 | private DataRowLineStyle lineStyle;
|
---|
| 95 | public DataRowLineStyle LineStyle {
|
---|
| 96 | get { return lineStyle; }
|
---|
| 97 | set {
|
---|
| 98 | if (lineStyle != value) {
|
---|
| 99 | lineStyle = value;
|
---|
| 100 | OnPropertyChanged("LineStyle");
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
[4648] | 104 | private bool startIndexZero;
|
---|
| 105 | public bool StartIndexZero {
|
---|
| 106 | get { return startIndexZero; }
|
---|
| 107 | set {
|
---|
| 108 | if (startIndexZero != value) {
|
---|
| 109 | startIndexZero = value;
|
---|
| 110 | OnPropertyChanged("StartIndexZero");
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
[6760] | 114 | private int lineWidth;
|
---|
| 115 | public int LineWidth {
|
---|
| 116 | get { return lineWidth; }
|
---|
| 117 | set {
|
---|
| 118 | if (lineWidth != value) {
|
---|
| 119 | lineWidth = value;
|
---|
| 120 | OnPropertyChanged("LineWidth");
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 | }
|
---|
| 124 | private int bins;
|
---|
| 125 | public int Bins {
|
---|
| 126 | get { return bins; }
|
---|
| 127 | set {
|
---|
| 128 | if (bins != value) {
|
---|
| 129 | bins = value;
|
---|
| 130 | OnPropertyChanged("Bins");
|
---|
| 131 | }
|
---|
| 132 | }
|
---|
| 133 | }
|
---|
| 134 | private bool exactBins;
|
---|
| 135 | public bool ExactBins {
|
---|
| 136 | get { return exactBins; }
|
---|
| 137 | set {
|
---|
| 138 | if (exactBins != value) {
|
---|
| 139 | exactBins = value;
|
---|
| 140 | OnPropertyChanged("ExactBins");
|
---|
| 141 | }
|
---|
| 142 | }
|
---|
| 143 | }
|
---|
| 144 | private string displayName;
|
---|
| 145 | public string DisplayName {
|
---|
| 146 | get { return displayName == null ? String.Empty : displayName; }
|
---|
| 147 | set {
|
---|
| 148 | if (displayName != value) {
|
---|
| 149 | if (value == null && displayName != String.Empty) {
|
---|
| 150 | displayName = String.Empty;
|
---|
| 151 | OnPropertyChanged("DisplayName");
|
---|
| 152 | } else if (value != null) {
|
---|
| 153 | displayName = value;
|
---|
| 154 | OnPropertyChanged("DisplayName");
|
---|
| 155 | }
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 | }
|
---|
[4644] | 159 |
|
---|
[4648] | 160 | #region Persistence Properties
|
---|
| 161 | [Storable(Name = "ChartType")]
|
---|
| 162 | private DataRowChartType StorableChartType {
|
---|
| 163 | get { return chartType; }
|
---|
| 164 | set { chartType = value; }
|
---|
| 165 | }
|
---|
| 166 | [Storable(Name = "SecondYAxis")]
|
---|
| 167 | private bool StorableSecondYAxis {
|
---|
| 168 | get { return secondYAxis; }
|
---|
| 169 | set { secondYAxis = value; }
|
---|
| 170 | }
|
---|
[6760] | 171 | [Storable(Name = "SecondXAxis")]
|
---|
| 172 | private bool StorableSecondXAxis {
|
---|
| 173 | get { return secondXAxis; }
|
---|
| 174 | set { secondXAxis = value; }
|
---|
| 175 | }
|
---|
[4648] | 176 | [Storable(Name = "Color")]
|
---|
| 177 | private Color StorableColor {
|
---|
| 178 | get { return color; }
|
---|
| 179 | set { color = value; }
|
---|
| 180 | }
|
---|
[6760] | 181 | [Storable(Name = "LineStyle")]
|
---|
| 182 | private DataRowLineStyle StorableLineStyle {
|
---|
| 183 | get { return lineStyle; }
|
---|
| 184 | set { lineStyle = value; }
|
---|
| 185 | }
|
---|
[4648] | 186 | [Storable(Name = "StartIndexZero")]
|
---|
| 187 | private bool StorableStartIndexZero {
|
---|
| 188 | get { return startIndexZero; }
|
---|
| 189 | set { startIndexZero = value; }
|
---|
| 190 | }
|
---|
[6760] | 191 | [Storable(Name = "LineWidth")]
|
---|
| 192 | private int StorableLineWidth {
|
---|
| 193 | get { return lineWidth; }
|
---|
| 194 | set { lineWidth = value; }
|
---|
| 195 | }
|
---|
| 196 | [Storable(Name = "Bins")]
|
---|
| 197 | private int StorableBins {
|
---|
| 198 | get { return bins; }
|
---|
| 199 | set { bins = value; }
|
---|
| 200 | }
|
---|
| 201 | [Storable(Name = "ExactBins")]
|
---|
| 202 | private bool StorableExactBins {
|
---|
| 203 | get { return exactBins; }
|
---|
| 204 | set { exactBins = value; }
|
---|
| 205 | }
|
---|
| 206 | [Storable(Name = "DisplayName")]
|
---|
| 207 | private string StorableDisplayName {
|
---|
| 208 | get { return displayName; }
|
---|
| 209 | set { displayName = value; }
|
---|
| 210 | }
|
---|
[4648] | 211 | #endregion
|
---|
| 212 |
|
---|
[4722] | 213 | [StorableConstructor]
|
---|
| 214 | protected DataRowVisualProperties(bool deserializing) : base() { }
|
---|
| 215 | protected DataRowVisualProperties(DataRowVisualProperties original, Cloner cloner)
|
---|
| 216 | : base(original, cloner) {
|
---|
| 217 | this.chartType = original.chartType;
|
---|
| 218 | this.secondYAxis = original.secondYAxis;
|
---|
[6760] | 219 | this.secondXAxis = original.secondXAxis;
|
---|
[4722] | 220 | this.color = original.color;
|
---|
[6760] | 221 | this.lineStyle = original.lineStyle;
|
---|
[4722] | 222 | this.startIndexZero = original.startIndexZero;
|
---|
[6760] | 223 | this.lineWidth = original.lineWidth;
|
---|
| 224 | this.bins = original.bins;
|
---|
| 225 | this.exactBins = original.exactBins;
|
---|
| 226 | this.displayName = original.displayName;
|
---|
[4722] | 227 | }
|
---|
[4644] | 228 | public DataRowVisualProperties() {
|
---|
| 229 | chartType = DataRowChartType.Line;
|
---|
| 230 | secondYAxis = false;
|
---|
[6760] | 231 | secondXAxis = false;
|
---|
[4648] | 232 | color = Color.Empty;
|
---|
[6760] | 233 | lineStyle = DataRowLineStyle.Solid;
|
---|
[4648] | 234 | startIndexZero = false;
|
---|
[6760] | 235 | lineWidth = 1;
|
---|
| 236 | bins = 10;
|
---|
| 237 | exactBins = false;
|
---|
| 238 | displayName = String.Empty;
|
---|
[4644] | 239 | }
|
---|
[6760] | 240 | public DataRowVisualProperties(string displayName)
|
---|
| 241 | : this() {
|
---|
| 242 | this.displayName = displayName;
|
---|
| 243 | }
|
---|
[4644] | 244 |
|
---|
[4777] | 245 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 246 | return new DataRowVisualProperties(this, cloner);
|
---|
| 247 | }
|
---|
| 248 |
|
---|
[4644] | 249 | public event PropertyChangedEventHandler PropertyChanged;
|
---|
| 250 | protected virtual void OnPropertyChanged(string propertyName) {
|
---|
| 251 | PropertyChangedEventHandler handler = PropertyChanged;
|
---|
| 252 | if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
---|
| 253 | }
|
---|
[6760] | 254 |
|
---|
| 255 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 256 | private void AfterDeserialization() {
|
---|
| 257 | // BackwardsCompatibility3.3
|
---|
| 258 | #region Backwards compatible code, remove with 3.4
|
---|
| 259 | if (secondXAxis == default(bool)
|
---|
| 260 | && lineStyle == default(DataRowLineStyle)
|
---|
| 261 | && lineWidth == default(int) && bins == default(int) && exactBins == default(bool)
|
---|
| 262 | && displayName == default(string)) {
|
---|
| 263 | secondXAxis = false;
|
---|
| 264 | lineStyle = DataRowLineStyle.Solid;
|
---|
| 265 | lineWidth = 1;
|
---|
| 266 | bins = 10;
|
---|
| 267 | exactBins = false;
|
---|
| 268 | displayName = String.Empty;
|
---|
| 269 | }
|
---|
| 270 | #endregion
|
---|
| 271 | }
|
---|
[4644] | 272 | }
|
---|
| 273 | }
|
---|