#region License Information
/* HeuristicLab
* Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using HeuristicLab.Collections;
using HeuristicLab.Core.Views;
using HeuristicLab.Data;
using HeuristicLab.MainForm;
using HeuristicLab.Optimization;
namespace HeuristicLab.Analysis.Statistics.Views {
[View("Correlations")]
[Content(typeof(RunCollection), false)]
public sealed partial class CorrelationView : ItemView {
private const string PearsonName = "Pearson product-moment correlation coefficient";
private const string SpearmanName = "Spearman's rank correlation coefficient";
private enum ResultParameterType {
Result,
Parameter
}
private bool suppressUpdates = false;
public new RunCollection Content {
get { return (RunCollection)base.Content; }
set { base.Content = value; }
}
public override bool ReadOnly {
get { return true; }
set { /*not needed because results are always readonly */}
}
public CorrelationView() {
InitializeComponent();
stringConvertibleMatrixView.Minimum = -1.0;
stringConvertibleMatrixView.Maximum = 1.0;
stringConvertibleMatrixView.FormatPattern = "0.000";
methodComboBox.Items.Add(PearsonName);
methodComboBox.Items.Add(SpearmanName);
methodComboBox.SelectedIndex = 0;
}
protected override void OnContentChanged() {
base.OnContentChanged();
if (Content != null) {
RebuildCorrelationTable();
}
UpdateCaption();
}
private void UpdateCaption() {
Caption = Content != null ? Content.OptimizerName + " Correlations" : ViewAttribute.GetViewName(GetType());
}
#region events
protected override void RegisterContentEvents() {
base.RegisterContentEvents();
Content.ColumnsChanged += Content_ColumnsChanged;
Content.RowsChanged += Content_RowsChanged;
Content.CollectionReset += new CollectionItemsChangedEventHandler(Content_CollectionReset);
Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
}
protected override void DeregisterContentEvents() {
base.DeregisterContentEvents();
Content.ColumnsChanged -= Content_ColumnsChanged;
Content.RowsChanged -= Content_RowsChanged;
Content.CollectionReset -= new CollectionItemsChangedEventHandler(Content_CollectionReset);
Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
}
void Content_RowsChanged(object sender, EventArgs e) {
if (suppressUpdates) return;
if (InvokeRequired) Invoke((Action