Ignore:
Timestamp:
01/12/16 17:05:37 (7 years ago)
Author:
pfleck
Message:

#2559

  • Adapted import and export for preprocessing.
  • Added MenuItem to be able to open Preprocessing without creating a DataAnalysisProblem before.
  • Added coloring in ScatterPlot.
  • Removed IPreprocessingContext interface.
  • Reformatted code:
    • Added missing copyright headers.
    • Corrected namespaces.
    • Deleted unnecessary usings.
    • Applied correct formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/FilterView.cs

    r11044 r13502  
    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;
    223using System.Collections.Generic;
    324using System.Linq;
    4 using System.Windows.Forms;
    525using HeuristicLab.Collections;
    6 using HeuristicLab.Core;
    726using HeuristicLab.Core.Views;
    8 using HeuristicLab.Data;
    927using HeuristicLab.DataPreprocessing.Filter;
    1028using HeuristicLab.MainForm;
     
    2240    }
    2341
    24     private void InitData()
    25     {
    26         checkedFilterView.Content = Content.Filters;
    27         checkedFilterView.Content.ItemsAdded += Content_ItemsAdded;
    28         checkedFilterView.Content.ItemsRemoved += Content_ItemsRemoved;
    29         checkedFilterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged;
     42    private void InitData() {
     43      checkedFilterView.Content = Content.Filters;
     44      checkedFilterView.Content.ItemsAdded += Content_ItemsAdded;
     45      checkedFilterView.Content.ItemsRemoved += Content_ItemsRemoved;
     46      checkedFilterView.Content.CheckedItemsChanged += Content_CheckedItemsChanged;
    3047    }
    3148
     
    3552    }
    3653
    37     protected override void OnContentChanged()
    38     {
     54    protected override void OnContentChanged() {
    3955      base.OnContentChanged();
    40       if (Content != null)
    41       {
     56      if (Content != null) {
    4257        InitData();
    4358        UpdateFilterInfo();
     
    4661
    4762    private void Content_CheckedItemsChanged(object sender, Collections.CollectionItemsChangedEventArgs<IFilter> e) {
    48       if (Content != null)
    49       {
    50         foreach (IFilter filter in e.Items)
    51         {
     63      if (Content != null) {
     64        foreach (IFilter filter in e.Items) {
    5265          filter.Active = checkedFilterView.Content.ItemChecked(filter);
    5366        }
     
    5770
    5871    private void UpdateFilterInfo() {
    59         List<IFilter> filters = Content.Filters.ToList();
    60         int activeFilters = filters.Count(c => c.Active);
    61         applyFilterButton.Enabled = (activeFilters > 0);
    62         rBtnAnd.Enabled = (activeFilters > 0);
    63         rBtnOr.Enabled = (activeFilters > 0);
    64         Content.FilterLogic.Reset();
    65         bool[] result = Content.FilterLogic.Preview(filters, rBtnAnd.Checked);
     72      List<IFilter> filters = Content.Filters.ToList();
     73      int activeFilters = filters.Count(c => c.Active);
     74      applyFilterButton.Enabled = (activeFilters > 0);
     75      rBtnAnd.Enabled = (activeFilters > 0);
     76      rBtnOr.Enabled = (activeFilters > 0);
     77      Content.FilterLogic.Reset();
     78      bool[] result = Content.FilterLogic.Preview(filters, rBtnAnd.Checked);
    6679
    67         int filteredCnt = result.Count(c => !c);
     80      int filteredCnt = result.Count(c => !c);
    6881
    69         tbRemaining.Text = filteredCnt.ToString();
    70         double percentage = result.Length == 0 ? 0.0 : filteredCnt * 100 / (double)result.Length;
    71         tbPercentage.Text = String.Format("{0:0.0000}%", percentage);
    72         tbTotal.Text = result.Length.ToString();
     82      tbRemaining.Text = filteredCnt.ToString();
     83      double percentage = result.Length == 0 ? 0.0 : filteredCnt * 100 / (double)result.Length;
     84      tbPercentage.Text = String.Format("{0:0.0000}%", percentage);
     85      tbTotal.Text = result.Length.ToString();
    7386    }
    7487
    7588    private void applyFilterButton_Click(object sender, EventArgs e) {
    76       if (Content != null)
    77       {
     89      if (Content != null) {
    7890        List<IFilter> filters = Content.Filters.ToList();
    7991        //apply filters
     
    8193        //deactivate checked filters
    8294        filters = checkedFilterView.Content.CheckedItems.ToList();
    83         foreach (IFilter filter in filters)
    84         {
     95        foreach (IFilter filter in filters) {
    8596          checkedFilterView.Content.SetItemCheckedState(filter, false);
    8697          filter.Active = false;
     
    92103    //whenever a new filter is added the preprocessing data is set to the filter
    93104    private void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IFilter> e) {
    94       if (Content != null)
    95       {
    96         foreach (IFilter filter in e.Items)
    97         {
     105      if (Content != null) {
     106        foreach (IFilter filter in e.Items) {
    98107          filter.ConstrainedValue = Content.FilterLogic.PreprocessingData;
    99108        }
     
    102111
    103112    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IFilter> e) {
    104       if (Content != null)
    105       {
     113      if (Content != null) {
    106114        UpdateFilterInfo();
    107115      }
    108116    }
    109117
    110     private void rBtnAnd_CheckedChanged(object sender, EventArgs e)
    111     {
    112       if (Content != null)
    113       {
     118    private void rBtnAnd_CheckedChanged(object sender, EventArgs e) {
     119      if (Content != null) {
    114120        UpdateFilterInfo();
    115121        Content.IsAndCombination = rBtnAnd.Checked;
Note: See TracChangeset for help on using the changeset viewer.