Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/14/16 22:38:23 (8 years ago)
Author:
mkommend
Message:

#2559: Merged r13502, r13504, r13507, r13508, r13512, r13514, r13517 into stable.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.DataPreprocessing.Views

  • stable/HeuristicLab.DataPreprocessing.Views/3.4/DataCompletenessView.cs

    r11002 r14075  
    1 using System;
     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
     22using System;
     23using System.Collections.Generic;
     24using System.Drawing;
    225using System.Windows.Forms;
    3 using HeuristicLab.Analysis;
     26using System.Windows.Forms.DataVisualization.Charting;
     27using HeuristicLab.Core.Views;
    428using HeuristicLab.MainForm;
    5 using HeuristicLab.Core.Views;
    6 using System.Collections.Generic;
    7 using HeuristicLab.DataPreprocessing.Implementations;
    8 using System.Drawing;
    9 using System.Windows.Forms.DataVisualization.Charting;
    1029
    1130namespace HeuristicLab.DataPreprocessing.Views {
     
    1332  [View("Histogram View")]
    1433  [Content(typeof(DataCompletenessChartContent), true)]
    15   public partial class DataCompletenessView : ItemView
    16   {
     34  public partial class DataCompletenessView : ItemView {
    1735
    1836    //list of columns, bool indicates wether the cell is a missing value or not
     
    2240    private static Color colorMissingVal = Color.Orange;
    2341
    24     public new DataCompletenessChartContent Content
    25     {
     42    public new DataCompletenessChartContent Content {
    2643      get { return (DataCompletenessChartContent)base.Content; }
    2744      set { base.Content = value; }
     
    2946
    3047
    31     public DataCompletenessView()
    32     {
     48    public DataCompletenessView() {
    3349      InitializeComponent();
    3450    }
    3551
    36     protected override void OnContentChanged()
    37     {
     52    protected override void OnContentChanged() {
    3853      base.OnContentChanged();
    39       if (Content != null)
    40       {
     54      if (Content != null) {
    4155        InitData();
    4256      }
    4357    }
    4458
    45     private void InitData()
    46     {
     59    private void InitData() {
    4760      IDictionary<int, IList<int>> missingValueIndices = Content.SearchLogic.GetMissingValueIndices();
    48       for (int i = 0; i < Content.SearchLogic.Columns; i++)
    49       {
     61      for (int i = 0; i < Content.SearchLogic.Columns; i++) {
    5062        //append column
    5163        List<bool> column = new List<bool>();
     
    6072    }
    6173
    62     private void PrepareChart()
    63     {
     74    private void PrepareChart() {
    6475      chart.Titles.Add("DataCompletenessChart");
    6576      chart.EnableDoubleClickResetsZoom = true;
     
    7485      //custom x axis label
    7586      double from = 0.5;
    76       foreach (String columnName in Content.SearchLogic.VariableNames)
    77       {
     87      foreach (String columnName in Content.SearchLogic.VariableNames) {
    7888        double to = from + 1;
    7989        chart.ChartAreas[0].AxisX.CustomLabels.Add(from, to, columnName);
     
    8494    }
    8595
    86     private void CreateSeries(List<List<int>> yValuesPerColumn)
    87     {
     96    private void CreateSeries(List<List<int>> yValuesPerColumn) {
    8897      //prepare series
    8998      int seriesCount = DetermineSeriesCount(yValuesPerColumn);
    90       for (int i = 0; i < seriesCount; i++)
    91       {
     99      for (int i = 0; i < seriesCount; i++) {
    92100        chart.Series.Add(CreateSeriesName(i));
    93101        Series series = chart.Series[CreateSeriesName(i)];
     
    95103        series.IsVisibleInLegend = false;
    96104        series["PointWidth"] = "1.0";
    97         if (i % 2 == 0)
    98         {
     105        if (i % 2 == 0) {
    99106          if (i == 0) //show legend for non missing values only once
    100107            series.IsVisibleInLegend = true;
    101108          series.Color = colorNonMissingVal;
    102         }
    103         else
    104         {
     109        } else {
    105110          if (i == 1) //show legend for missing values only once
    106111            series.IsVisibleInLegend = true;
     
    109114      }
    110115      //fill series
    111       for (int i = 0; i < yValuesPerColumn.Count; i++)
    112       {
     116      for (int i = 0; i < yValuesPerColumn.Count; i++) {
    113117        List<int> column = yValuesPerColumn[i];
    114118        for (int j = 0; j < seriesCount; j++) {
     
    122126    }
    123127
    124     private String CreateSeriesName(int index)
    125     {
     128    private String CreateSeriesName(int index) {
    126129      if (index == 0)
    127130        return "non-missing value";
     
    132135
    133136    #region data_preparation_for_chartseries
    134     private int DetermineSeriesCount(List<List<int>> yValuesPerColumn)
    135     {
     137    private int DetermineSeriesCount(List<List<int>> yValuesPerColumn) {
    136138      int highest = 0;
    137139      foreach (List<int> values in yValuesPerColumn) {
     
    141143    }
    142144
    143     private List<List<int>> ProcessMatrixForCharting(List<List<bool>> matrix, IDictionary<int, IList<int>> missingValueIndices)
    144     {
     145    private List<List<int>> ProcessMatrixForCharting(List<List<bool>> matrix, IDictionary<int, IList<int>> missingValueIndices) {
    145146      List<List<int>> columnsYValues = new List<List<int>>();
    146       for (int i=0; i < matrix.Count; i++) //column
     147      for (int i = 0; i < matrix.Count; i++) //column
    147148      {
    148149        List<int> yValues = new List<int>();
     
    150151        bool missingState = false;
    151152        int valueCount = 0;
    152         for (int j = 0; j < column.Count; j++ ) {
    153           if (missingState == missingValueIndices[i].Contains(j))
    154           {
     153        for (int j = 0; j < column.Count; j++) {
     154          if (missingState == missingValueIndices[i].Contains(j)) {
    155155            valueCount++;
    156           }
    157           else
    158           {
     156          } else {
    159157            yValues.Add(valueCount);
    160158            valueCount = 1;
Note: See TracChangeset for help on using the changeset viewer.