Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataPreprocessingView.cs @ 10908

Last change on this file since 10908 was 10908, checked in by mleitner, 10 years ago

Add Feature correlation matrix, Add limit for distinct values in histogramm classification.

File size: 4.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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.Windows.Forms;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Core.Views;
27using HeuristicLab.MainForm;
28using HeuristicLab.DataPreprocessing;
29using HeuristicLab.Problems.DataAnalysis;
30
31namespace HeuristicLab.DataPreprocessing.Views {
32  [View("DataPreprocessing View")]
33  [Content(typeof(PreprocessingContext), true)]
34  [Content(typeof(IPreprocessingContext), false)]
35  public partial class DataPreprocessingView : ItemView {
36    public DataPreprocessingView() {
37      InitializeComponent();
38    }
39
40    public new IPreprocessingContext Content {
41      get { return (IPreprocessingContext)base.Content; }
42      set { base.Content = value; }
43    }
44
45    protected override void OnContentChanged() {
46      base.OnContentChanged();
47      if (Content != null) {
48        var data = Content.Data;
49        var searchLogic = new SearchLogic(data);
50        var dataGridLogic = new DataGridLogic(data);
51        var statisticsLogic = new StatisticsLogic(data, searchLogic);
52        var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic);
53        var chartLogic = new ChartLogic(data);
54        var correlationMatrixLogic = new ChartLogic(data);
55        var filterLogic = new FilterLogic(data);
56        var creator = new ProblemDataCreator(Content);
57        var problemData = (DataAnalysisProblemData)creator.CreateProblemData();
58        var dataCompletenessLogic = new ChartLogic(data);
59
60        var viewShortcuts = new ItemList<IViewShortcut> {
61          new DataGridContent(dataGridLogic, manipulationLogic, filterLogic),
62          new StatisticsContent(statisticsLogic),
63          new FilterContent(filterLogic),
64          new TransformationContent(data),
65          new ManipulationContent(manipulationLogic, searchLogic, dataGridLogic),
66          new LineChartContent(chartLogic),
67          new HistogramContent(chartLogic),
68          new ScatterPlotContent(chartLogic),
69          new CorrelationMatrixContent(problemData)
70        };
71
72        viewShortcutListView.Content = viewShortcuts.AsReadOnly();
73
74        viewShortcutListView.ItemsListView.Items[0].Selected = true;
75        viewShortcutListView.Select();
76
77      } else {
78        viewShortcutListView.Content = null;
79      }
80    }
81
82    protected override void SetEnabledStateOfControls() {
83      base.SetEnabledStateOfControls();
84      viewShortcutListView.Enabled = Content != null;
85      applyInNewTabButton.Enabled = Content != null;
86      exportProblemButton.Enabled = Content != null;
87      undoButton.Enabled = Content != null;
88    }
89
90    private void exportProblemButton_Click(object sender, EventArgs e) {
91      var problem = Content.ExportProblem();
92
93      var saveFileDialog = new SaveFileDialog {
94        Title = "Save Item",
95        DefaultExt = "hl",
96        Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
97        FilterIndex = 2
98      };
99
100      var content = problem as IStorableContent;
101      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
102        bool compressed = saveFileDialog.FilterIndex != 1;
103        ContentManager.Save(content, saveFileDialog.FileName, compressed);
104      }
105    }
106
107    private void applyInNewTabButton_Click(object sender, EventArgs e) {
108      var item = Content.ExportAlgorithmOrProblem();
109
110      MainFormManager.MainForm.ShowContent(item);
111    }
112
113    private void undoButton_Click(object sender, EventArgs e) {
114      Content.Data.Undo();
115    }
116  }
117}
Note: See TracBrowser for help on using the repository browser.