[4644] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[7270] | 3 | * Copyright (C) 2002-2012 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 |
|
---|
[6628] | 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,
|
---|
[6342] | 39 | Bars,
|
---|
| 40 | Histogram
|
---|
[4644] | 41 | }
|
---|
| 42 | #endregion
|
---|
[6342] | 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 | }
|
---|
[6342] | 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 | }
|
---|
[6342] | 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 | }
|
---|
[6342] | 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 | }
|
---|
[6978] | 144 | private double scaleFactor;
|
---|
| 145 | public double ScaleFactor {
|
---|
| 146 | get { return scaleFactor; }
|
---|
| 147 | set {
|
---|
| 148 | if (scaleFactor != value) {
|
---|
| 149 | scaleFactor = value;
|
---|
| 150 | OnPropertyChanged("ScaleFactor");
|
---|
| 151 | }
|
---|
| 152 | }
|
---|
| 153 | }
|
---|
[7215] | 154 | private bool isVisibleInLegend;
|
---|
| 155 | public bool IsVisibleInLegend {
|
---|
| 156 | get { return isVisibleInLegend; }
|
---|
| 157 | set {
|
---|
| 158 | if (isVisibleInLegend != value) {
|
---|
| 159 | isVisibleInLegend = value;
|
---|
| 160 | OnPropertyChanged("IsVisibleInLegend");
|
---|
| 161 | }
|
---|
| 162 | }
|
---|
| 163 | }
|
---|
[6628] | 164 | private string displayName;
|
---|
| 165 | public string DisplayName {
|
---|
| 166 | get { return displayName == null ? String.Empty : displayName; }
|
---|
| 167 | set {
|
---|
| 168 | if (displayName != value) {
|
---|
| 169 | if (value == null && displayName != String.Empty) {
|
---|
| 170 | displayName = String.Empty;
|
---|
| 171 | OnPropertyChanged("DisplayName");
|
---|
| 172 | } else if (value != null) {
|
---|
| 173 | displayName = value;
|
---|
| 174 | OnPropertyChanged("DisplayName");
|
---|
| 175 | }
|
---|
| 176 | }
|
---|
| 177 | }
|
---|
| 178 | }
|
---|
[4644] | 179 |
|
---|
[4648] | 180 | #region Persistence Properties
|
---|
| 181 | [Storable(Name = "ChartType")]
|
---|
| 182 | private DataRowChartType StorableChartType {
|
---|
| 183 | get { return chartType; }
|
---|
| 184 | set { chartType = value; }
|
---|
| 185 | }
|
---|
| 186 | [Storable(Name = "SecondYAxis")]
|
---|
| 187 | private bool StorableSecondYAxis {
|
---|
| 188 | get { return secondYAxis; }
|
---|
| 189 | set { secondYAxis = value; }
|
---|
| 190 | }
|
---|
[6342] | 191 | [Storable(Name = "SecondXAxis")]
|
---|
| 192 | private bool StorableSecondXAxis {
|
---|
| 193 | get { return secondXAxis; }
|
---|
| 194 | set { secondXAxis = value; }
|
---|
| 195 | }
|
---|
[4648] | 196 | [Storable(Name = "Color")]
|
---|
| 197 | private Color StorableColor {
|
---|
| 198 | get { return color; }
|
---|
| 199 | set { color = value; }
|
---|
| 200 | }
|
---|
[6342] | 201 | [Storable(Name = "LineStyle")]
|
---|
| 202 | private DataRowLineStyle StorableLineStyle {
|
---|
| 203 | get { return lineStyle; }
|
---|
| 204 | set { lineStyle = value; }
|
---|
| 205 | }
|
---|
[4648] | 206 | [Storable(Name = "StartIndexZero")]
|
---|
| 207 | private bool StorableStartIndexZero {
|
---|
| 208 | get { return startIndexZero; }
|
---|
| 209 | set { startIndexZero = value; }
|
---|
| 210 | }
|
---|
[6342] | 211 | [Storable(Name = "LineWidth")]
|
---|
| 212 | private int StorableLineWidth {
|
---|
| 213 | get { return lineWidth; }
|
---|
| 214 | set { lineWidth = value; }
|
---|
| 215 | }
|
---|
| 216 | [Storable(Name = "Bins")]
|
---|
| 217 | private int StorableBins {
|
---|
| 218 | get { return bins; }
|
---|
| 219 | set { bins = value; }
|
---|
| 220 | }
|
---|
| 221 | [Storable(Name = "ExactBins")]
|
---|
| 222 | private bool StorableExactBins {
|
---|
| 223 | get { return exactBins; }
|
---|
| 224 | set { exactBins = value; }
|
---|
| 225 | }
|
---|
[6978] | 226 | [Storable(Name = "ScaleFactor")]
|
---|
| 227 | private double StorableScaleFactor {
|
---|
| 228 | get { return scaleFactor; }
|
---|
| 229 | set { scaleFactor = value; }
|
---|
| 230 | }
|
---|
[7215] | 231 | [Storable(Name = "IsVisibleInLegend", DefaultValue = true)]
|
---|
| 232 | private bool StorableIsVisibleInLegend {
|
---|
| 233 | get { return isVisibleInLegend; }
|
---|
| 234 | set { isVisibleInLegend = value; }
|
---|
| 235 | }
|
---|
[6628] | 236 | [Storable(Name = "DisplayName")]
|
---|
| 237 | private string StorableDisplayName {
|
---|
| 238 | get { return displayName; }
|
---|
| 239 | set { displayName = value; }
|
---|
| 240 | }
|
---|
[4648] | 241 | #endregion
|
---|
| 242 |
|
---|
[4722] | 243 | [StorableConstructor]
|
---|
| 244 | protected DataRowVisualProperties(bool deserializing) : base() { }
|
---|
| 245 | protected DataRowVisualProperties(DataRowVisualProperties original, Cloner cloner)
|
---|
| 246 | : base(original, cloner) {
|
---|
| 247 | this.chartType = original.chartType;
|
---|
| 248 | this.secondYAxis = original.secondYAxis;
|
---|
[6342] | 249 | this.secondXAxis = original.secondXAxis;
|
---|
[4722] | 250 | this.color = original.color;
|
---|
[6342] | 251 | this.lineStyle = original.lineStyle;
|
---|
[4722] | 252 | this.startIndexZero = original.startIndexZero;
|
---|
[6342] | 253 | this.lineWidth = original.lineWidth;
|
---|
| 254 | this.bins = original.bins;
|
---|
| 255 | this.exactBins = original.exactBins;
|
---|
[6978] | 256 | this.scaleFactor = original.scaleFactor;
|
---|
[6628] | 257 | this.displayName = original.displayName;
|
---|
[7215] | 258 | this.isVisibleInLegend = original.isVisibleInLegend;
|
---|
[4722] | 259 | }
|
---|
[4644] | 260 | public DataRowVisualProperties() {
|
---|
| 261 | chartType = DataRowChartType.Line;
|
---|
| 262 | secondYAxis = false;
|
---|
[6342] | 263 | secondXAxis = false;
|
---|
[4648] | 264 | color = Color.Empty;
|
---|
[6342] | 265 | lineStyle = DataRowLineStyle.Solid;
|
---|
[4648] | 266 | startIndexZero = false;
|
---|
[6342] | 267 | lineWidth = 1;
|
---|
| 268 | bins = 10;
|
---|
| 269 | exactBins = false;
|
---|
[6978] | 270 | scaleFactor = 1.0;
|
---|
[6628] | 271 | displayName = String.Empty;
|
---|
[7215] | 272 | isVisibleInLegend = true;
|
---|
[4644] | 273 | }
|
---|
[6628] | 274 | public DataRowVisualProperties(string displayName)
|
---|
| 275 | : this() {
|
---|
| 276 | this.displayName = displayName;
|
---|
| 277 | }
|
---|
[4644] | 278 |
|
---|
[4777] | 279 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 280 | return new DataRowVisualProperties(this, cloner);
|
---|
| 281 | }
|
---|
| 282 |
|
---|
[4644] | 283 | public event PropertyChangedEventHandler PropertyChanged;
|
---|
| 284 | protected virtual void OnPropertyChanged(string propertyName) {
|
---|
| 285 | PropertyChangedEventHandler handler = PropertyChanged;
|
---|
| 286 | if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
---|
| 287 | }
|
---|
[6676] | 288 |
|
---|
| 289 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 290 | private void AfterDeserialization() {
|
---|
| 291 | // BackwardsCompatibility3.3
|
---|
| 292 | #region Backwards compatible code, remove with 3.4
|
---|
| 293 | if (secondXAxis == default(bool)
|
---|
| 294 | && lineStyle == default(DataRowLineStyle)
|
---|
| 295 | && lineWidth == default(int) && bins == default(int) && exactBins == default(bool)
|
---|
| 296 | && displayName == default(string)) {
|
---|
| 297 | secondXAxis = false;
|
---|
| 298 | lineStyle = DataRowLineStyle.Solid;
|
---|
| 299 | lineWidth = 1;
|
---|
| 300 | bins = 10;
|
---|
| 301 | exactBins = false;
|
---|
| 302 | displayName = String.Empty;
|
---|
| 303 | }
|
---|
| 304 | #endregion
|
---|
| 305 | }
|
---|
[4644] | 306 | }
|
---|
| 307 | }
|
---|