[3442] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2010 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 | using System;
|
---|
| 22 | using System.Linq;
|
---|
| 23 | using System.Windows.Forms;
|
---|
[4068] | 24 | using HeuristicLab.Data;
|
---|
| 25 | using HeuristicLab.Data.Views;
|
---|
[3442] | 26 | using HeuristicLab.MainForm;
|
---|
| 27 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
| 30 | [View("Estimated Values View")]
|
---|
| 31 | [Content(typeof(DataAnalysisSolution))]
|
---|
| 32 | public partial class EstimatedValuesView : AsynchronousContentView {
|
---|
| 33 | private const string TARGETVARIABLE_SERIES_NAME = "TargetVariable";
|
---|
| 34 | private const string ESTIMATEDVALUES_SERIES_NAME = "EstimatedValues";
|
---|
| 35 |
|
---|
| 36 | public new DataAnalysisSolution Content {
|
---|
| 37 | get { return (DataAnalysisSolution)base.Content; }
|
---|
| 38 | set {
|
---|
| 39 | base.Content = value;
|
---|
| 40 | }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | private StringConvertibleMatrixView matrixView;
|
---|
| 44 |
|
---|
| 45 | public EstimatedValuesView()
|
---|
| 46 | : base() {
|
---|
| 47 | InitializeComponent();
|
---|
| 48 | matrixView = new StringConvertibleMatrixView();
|
---|
| 49 | matrixView.Dock = DockStyle.Fill;
|
---|
| 50 | this.Controls.Add(matrixView);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | #region events
|
---|
| 54 | protected override void RegisterContentEvents() {
|
---|
| 55 | base.RegisterContentEvents();
|
---|
[3462] | 56 | Content.EstimatedValuesChanged += new EventHandler(Content_EstimatedValuesChanged);
|
---|
[3442] | 57 | Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | protected override void DeregisterContentEvents() {
|
---|
| 61 | base.DeregisterContentEvents();
|
---|
[3462] | 62 | Content.EstimatedValuesChanged -= new EventHandler(Content_EstimatedValuesChanged);
|
---|
[3442] | 63 | Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged);
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | void Content_ProblemDataChanged(object sender, EventArgs e) {
|
---|
| 67 | OnContentChanged();
|
---|
| 68 | }
|
---|
| 69 |
|
---|
[3462] | 70 | void Content_EstimatedValuesChanged(object sender, EventArgs e) {
|
---|
[3442] | 71 | OnContentChanged();
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | protected override void OnContentChanged() {
|
---|
| 75 | base.OnContentChanged();
|
---|
| 76 | UpdateEstimatedValues();
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | private void UpdateEstimatedValues() {
|
---|
| 80 | if (InvokeRequired) Invoke((Action)UpdateEstimatedValues);
|
---|
| 81 | else {
|
---|
[4011] | 82 | DoubleMatrix matrix = null;
|
---|
| 83 | if (Content != null) {
|
---|
| 84 | double[,] values =
|
---|
| 85 | MatrixExtensions<double>.Create(
|
---|
| 86 | Content.ProblemData.Dataset.GetVariableValues(Content.ProblemData.TargetVariable.Value),
|
---|
| 87 | Content.EstimatedValues.ToArray());
|
---|
| 88 | matrix = new DoubleMatrix(values);
|
---|
| 89 | matrix.ColumnNames = new string[] { "Original", "Estimated" };
|
---|
| 90 | }
|
---|
| 91 | matrixView.Content = matrix;
|
---|
[3442] | 92 | }
|
---|
| 93 | }
|
---|
| 94 | #endregion
|
---|
| 95 | }
|
---|
| 96 | }
|
---|