Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/07/16 13:50:21 (7 years ago)
Author:
pfleck
Message:

#2709

  • Removed the PreprocessingDataTable and PreprocessingDataTableView and use dhe HL DatatTableControl instead.
  • Moved and refactored some code of PreprocessingChart and moved unnecessary code from base classes to actual derivative classes.
Location:
branches/DataPreprocessing Enhancements
Files:
3 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj

    r14446 r14459  
    239239    </Compile>
    240240    <Compile Include="DataPreprocessorStarter.cs" />
    241     <Compile Include="PreprocessingDataTableView.cs">
    242       <SubType>UserControl</SubType>
    243     </Compile>
    244     <Compile Include="PreprocessingDataTableView.Designer.cs">
    245       <DependentUpon>PreprocessingDataTableView.cs</DependentUpon>
    246     </Compile>
    247241    <Compile Include="FilterView.cs">
    248242      <SubType>UserControl</SubType>
     
    326320      <Name>HeuristicLab.DataPreprocessing-3.4</Name>
    327321    </ProjectReference>
     322  </ItemGroup>
     323  <ItemGroup>
     324    <EmbeddedResource Include="PreprocessingChartView.resx">
     325      <DependentUpon>PreprocessingChartView.cs</DependentUpon>
     326    </EmbeddedResource>
    328327  </ItemGroup>
    329328  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.Designer.cs

    r14268 r14459  
    4646    private void InitializeComponent() {
    4747      this.optionsBox = new System.Windows.Forms.GroupBox();
    48       this.displayDetailsCheckBox = new System.Windows.Forms.CheckBox();
    4948      this.label1 = new System.Windows.Forms.Label();
    5049      this.classifierComboBox = new System.Windows.Forms.ComboBox();
     
    6665      this.optionsBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
    6766            | System.Windows.Forms.AnchorStyles.Right)));
    68       this.optionsBox.Controls.Add(this.displayDetailsCheckBox);
    6967      this.optionsBox.Controls.Add(this.label1);
    7068      this.optionsBox.Controls.Add(this.classifierComboBox);
     
    7573      this.optionsBox.TabStop = false;
    7674      this.optionsBox.Text = "Options";
    77       //
    78       // displayDetailsCheckBox
    79       //
    80       this.displayDetailsCheckBox.AutoSize = true;
    81       this.displayDetailsCheckBox.Location = new System.Drawing.Point(5, 58);
    82       this.displayDetailsCheckBox.Margin = new System.Windows.Forms.Padding(2);
    83       this.displayDetailsCheckBox.Name = "displayDetailsCheckBox";
    84       this.displayDetailsCheckBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
    85       this.displayDetailsCheckBox.Size = new System.Drawing.Size(119, 17);
    86       this.displayDetailsCheckBox.TabIndex = 3;
    87       this.displayDetailsCheckBox.Text = "Display value count";
    88       this.displayDetailsCheckBox.UseVisualStyleBackColor = true;
    89       this.displayDetailsCheckBox.CheckedChanged += new System.EventHandler(this.displayDetailsCheckBox_CheckedChanged);
    9075      //
    9176      // label1
     
    130115    private System.Windows.Forms.ComboBox classifierComboBox;
    131116    private System.Windows.Forms.Label label1;
    132     private System.Windows.Forms.CheckBox displayDetailsCheckBox;
    133117
    134118  }
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs

    r14185 r14459  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using HeuristicLab.Analysis;
    2426using HeuristicLab.MainForm;
     
    2931  [Content(typeof(HistogramContent), true)]
    3032  public partial class HistogramView : PreprocessingChartView {
    31     private const string HISTOGRAM_CHART_TITLE = "Histogram";
     33
     34    public List<double> Classification { get; set; }
     35    public bool IsDetailedChartViewEnabled { get; set; }
    3236
    3337    public HistogramView() {
    3438      InitializeComponent();
    35       chartType = DataRowVisualProperties.DataRowChartType.Histogram;
    36       chartTitle = HISTOGRAM_CHART_TITLE;
    3739    }
    3840
     
    5355    }
    5456
     57    protected override DataTable CreateDataTable(string variableName) {
     58      var dt = new DataTable();
     59      var row = Content.CreateDataRow(variableName, DataRowVisualProperties.DataRowChartType.Histogram);
     60      if (Classification == null) {
     61        dt.Rows.Add(row);
     62      } else {
     63        dt.VisualProperties.Title = variableName;
     64        //var valuesPerClass = row.Values.Zip(Classification, (value, @class) => new { value, @class })
     65        //                        .GroupBy(x => x.@class)
     66        //                        .ToDictionary(x => x.Key, x => x.Select(v => v.value));
     67        var valuesPerClass = row.Values.Select((i, index) => new { i, j = Classification.ToList()[index] })
     68                                       .GroupBy((x) => x.j)
     69                                       .ToDictionary(x => x.Key, x => x.Select(v => v.i)
     70                                       .ToList());
     71        foreach (var entry in valuesPerClass) {
     72          var classRow = new DataRow(entry.Key.ToString());
     73          classRow.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
     74          classRow.Values.AddRange(entry.Value);
     75          dt.Rows.Add(classRow);
     76        }
     77      }
     78      return dt;
     79    }
     80
    5581    public new HistogramContent Content {
    5682      get { return (HistogramContent)base.Content; }
     
    6490      if (classifierComboBox.SelectedIndex != 0) {
    6591        int columndIndex = Content.PreprocessingData.GetColumnIndex(classifierComboBox.SelectedItem.ToString());
    66         Classification = Content.PreprocessingData.GetValues<double>(columndIndex);
     92        Classification = Content.PreprocessingData.GetValues<double>(columndIndex).ToList();
    6793      } else {
    6894        Classification = null;
     
    7096
    7197      Content.ClassifierVariableIndex = classifierComboBox.SelectedIndex;
    72       if (Content.IsDetailedChartViewEnabled != IsDetailedChartViewEnabled) {
    73         displayDetailsCheckBox.Checked = Content.IsDetailedChartViewEnabled;
    74       } else {
    75         GenerateChart();
    76       }
    77     }
    78     private void displayDetailsCheckBox_CheckedChanged(object sender, EventArgs e) {
    79       bool isChecked = displayDetailsCheckBox.Checked;
    80       if (IsDetailedChartViewEnabled != isChecked) {
    81         IsDetailedChartViewEnabled = isChecked;
    82         Content.IsDetailedChartViewEnabled = isChecked;
    83         GenerateChart();
    84       }
     98
     99      // rebuild datatables
     100      InitData();
     101      GenerateLayout();
    85102    }
    86103  }
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/LineChartView.cs

    r14185 r14459  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using HeuristicLab.Analysis;
     26using HeuristicLab.Analysis.Views;
     27using HeuristicLab.Collections;
     28using HeuristicLab.Data;
    2429using HeuristicLab.MainForm;
    2530
     
    3035  public partial class LineChartView : PreprocessingChartView {
    3136
    32     private const string LINE_CHART_TITLE = "Line Chart";
     37    protected Dictionary<string, DataRow> allInOneDataRows;
     38    protected DataTable allInOneDataTable;
     39    protected DataTableControl allInOneDataTableControl;
    3340
    3441    public LineChartView() {
    3542      InitializeComponent();
    36       chartType = DataRowVisualProperties.DataRowChartType.Line;
    37       chartTitle = LINE_CHART_TITLE;
     43      allInOneDataRows = new Dictionary<string, DataRow>();
     44      allInOneDataTable= new DataTable();
    3845    }
    3946
     
    4350    }
    4451
     52    protected override void InitData() {
     53      base.InitData();
     54
     55      allInOneDataRows.Clear();
     56      foreach (var x in Content.VariableItemList.Select((v, i) => new { variable = v.Value, i })) {
     57        var row = Content.CreateDataRow(x.variable, DataRowVisualProperties.DataRowChartType.Line);
     58        row.VisualProperties.Color = Colors[x.i % Colors.Length];
     59        allInOneDataRows.Add(x.variable, row);
     60      }
     61
     62      allInOneDataTable.Rows.Clear();
     63      foreach (var variable in Content.VariableItemList.CheckedItems) {
     64        allInOneDataTable.Rows.Add(allInOneDataRows[variable.Value.Value]);
     65      }
     66    }
     67
     68    protected override int GetNumberOfVisibleDataTables() {
     69      return Content.AllInOneMode ? 1 : base.GetNumberOfVisibleDataTables();
     70    }
     71    protected override IEnumerable<DataTableControl> GetVisibleDataTables() {
     72      if (Content.AllInOneMode) {
     73        if (allInOneDataTableControl == null)
     74          allInOneDataTableControl = new DataTableControl() { Content = allInOneDataTable };
     75        return new[] { allInOneDataTableControl };
     76      }
     77      return base.GetVisibleDataTables();
     78    }
     79    protected override DataTable CreateDataTable(string variableName) {
     80      var dt = new DataTable();
     81      dt.Rows.Add(Content.CreateDataRow(variableName, DataRowVisualProperties.DataRowChartType.Line));
     82      return dt;
     83    }
     84
    4585    private void allInOneCheckBox_CheckedChanged(object sender, EventArgs e) {
    4686      Content.AllInOneMode = allInOneCheckBox.Checked;
    4787
    48       GenerateChart();
     88      GenerateLayout();
    4989    }
    5090
     
    5595      }
    5696    }
     97
     98    protected override void CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> checkedItems) {
     99      base.CheckedItemsChanged(sender, checkedItems);
     100
     101      foreach (IndexedItem<StringValue> item in checkedItems.Items) {
     102        string variableName = item.Value.Value;
     103
     104        if (IsVariableChecked(variableName)) {
     105          // ToDo: avoid clearing all rows, but how?
     106          allInOneDataTable.Rows.Clear();
     107          foreach (var variable in Content.VariableItemList.CheckedItems) {
     108            allInOneDataTable.Rows.Add(allInOneDataRows[variable.Value.Value]);
     109          }
     110        } else {
     111          allInOneDataTable.Rows.Remove(variableName);
     112        }
     113      }
     114    }
     115
     116    #region Add/Remove/Update Variable, Reset
     117    protected override void AddVariable(string name) {
     118      base.AddVariable(name);
     119      var row = Content.CreateDataRow(name, DataRowVisualProperties.DataRowChartType.Line);
     120      allInOneDataTable.Rows.Add(row);
     121    }
     122
     123    // remove variable from data table and item list
     124    protected override void RemoveVariable(string name) {
     125      base.RemoveVariable(name);
     126      allInOneDataTable.Rows.Remove(name);
     127    }
     128
     129    protected override void UpdateVariable(string name) {
     130      base.UpdateVariable(name);
     131      allInOneDataTable.Rows.Remove(name);
     132      var newRow = Content.CreateDataRow(name, DataRowVisualProperties.DataRowChartType.Line);
     133      allInOneDataTable.Rows.Add(newRow);
     134    }
     135    #endregion
    57136  }
    58137}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.Designer.cs

    r14381 r14459  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.dataTableView = new HeuristicLab.DataPreprocessing.Views.PreprocessingDataTableView();
    4847      this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
    4948      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     
    5150      this.splitContainer.Panel2.SuspendLayout();
    5251      this.splitContainer.SuspendLayout();
    53       this.tableLayoutPanel.SuspendLayout();
    5452      this.SuspendLayout();
    5553      //
     
    6159      this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel);
    6260      //
    63       // dataTableView
    64       //
    65       this.dataTableView.AutoScroll = true;
    66       this.dataTableView.Caption = "DataTable View";
    67       this.dataTableView.Classification = null;
    68       this.dataTableView.Content = null;
    69       this.dataTableView.Dock = System.Windows.Forms.DockStyle.Fill;
    70       this.dataTableView.IsDetailedChartViewEnabled = false;
    71       this.dataTableView.Location = new System.Drawing.Point(3, 3);
    72       this.dataTableView.Name = "dataTableView";
    73       this.dataTableView.ReadOnly = false;
    74       this.dataTableView.ShowLegend = true;
    75       this.dataTableView.Size = new System.Drawing.Size(553, 397);
    76       this.dataTableView.TabIndex = 0;
    77       this.dataTableView.XAxisFormat = "";
    78       this.dataTableView.YAxisFormat = "";
    79       //
    8061      // tableLayoutPanel
    8162      //
     63      this.tableLayoutPanel.AutoScroll = true;
    8264      this.tableLayoutPanel.ColumnCount = 1;
    8365      this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
    8466      this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
    85       this.tableLayoutPanel.Controls.Add(this.dataTableView, 0, 0);
    8667      this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
    8768      this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
     
    10384      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    10485      this.splitContainer.ResumeLayout(false);
    105       this.tableLayoutPanel.ResumeLayout(false);
    10686      this.ResumeLayout(false);
    10787
     
    11090    #endregion
    11191
    112     private DataPreprocessing.Views.PreprocessingDataTableView dataTableView;
    113     private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
     92    protected System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
    11493  }
    11594}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs

    r14418 r14459  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
     23using System.Drawing;
    2424using System.Linq;
    2525using System.Windows.Forms;
    2626using HeuristicLab.Analysis;
     27using HeuristicLab.Analysis.Views;
    2728using HeuristicLab.Collections;
    2829using HeuristicLab.Data;
    2930using HeuristicLab.MainForm;
     31using HeuristicLab.MainForm.WindowsForms;
    3032
    3133namespace HeuristicLab.DataPreprocessing.Views {
     
    3436  public partial class PreprocessingChartView : PreprocessingCheckedVariablesView {
    3537
    36     protected PreprocessingDataTable dataTable;
    37     protected List<PreprocessingDataTable> dataTablePerVariable;
    38     protected List<DataRow> dataRows;
    39     protected List<DataRow> selectedDataRows;
    40 
    41     protected DataRowVisualProperties.DataRowChartType chartType;
    42     protected string chartTitle;
    43 
    44     private const string DEFAULT_CHART_TITLE = "Chart";
     38    protected Dictionary<string, DataTable> dataTables;
     39    protected Dictionary<string, DataTableControl> dataTableControls;
     40
    4541    private const int FIXED_CHART_SIZE = 300;
    4642    private const int MAX_TABLE_AUTO_SIZE_ROWS = 3;
    4743
    48 
    49     public IEnumerable<double> Classification { get; set; }
    50     public bool IsDetailedChartViewEnabled { get; set; }
     44    protected static readonly Color[] Colors = {
     45      Color.FromArgb(59, 136, 239), Color.FromArgb(252, 177, 59), Color.FromArgb(226, 64, 10),
     46      Color.FromArgb(5, 100, 146), Color.FromArgb(191, 191, 191), Color.FromArgb(26, 59, 105),
     47      Color.FromArgb(255, 226, 126), Color.FromArgb(18, 156, 221), Color.FromArgb(202, 107, 75),
     48      Color.FromArgb(0, 92, 219), Color.FromArgb(243, 210, 136), Color.FromArgb(80, 99, 129),
     49      Color.FromArgb(241, 185, 168), Color.FromArgb(224, 131, 10), Color.FromArgb(120, 147, 190)
     50    };
     51
    5152
    5253    public PreprocessingChartView() {
    5354      InitializeComponent();
    54       chartType = DataRowVisualProperties.DataRowChartType.Line;
    55       chartTitle = DEFAULT_CHART_TITLE;
     55      dataTables = new Dictionary<string, DataTable>();
     56      dataTableControls= new Dictionary<string, DataTableControl>();
    5657    }
    5758
     
    6061      if (Content != null) {
    6162        InitData();
    62         GenerateChart();
    63 
    64         foreach (var row in dataRows) {
    65           string variableName = row.Name;
    66           if (!IsVariableChecked(variableName)) {
    67             dataTableView.SetRowEnabled(variableName, false);
    68             dataTable.SelectedRows.Remove(variableName);
    69             dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName)));
    70           }
    71         }
    72       }
    73     }
    74 
    75     private void InitData() {
    76       //Create data tables and data rows
    77       dataRows = Content.CreateAllDataRows(chartType);
    78       dataTable = new PreprocessingDataTable(chartTitle);
    79       dataTablePerVariable = new List<PreprocessingDataTable>();
    80 
    81       //add data rows to data tables according to checked item list
    82       foreach (var row in dataRows) {
    83         string variableName = row.Name;
    84 
    85         //add row to data table
    86         dataTable.Rows.Add(row);
    87 
    88         //add row to data table per variable
    89         PreprocessingDataTable d = new PreprocessingDataTable(variableName);
    90         d.Rows.Add(row);
    91         dataTablePerVariable.Add(d);
    92       }
    93 
    94       UpdateSelection();
     63        GenerateLayout();
     64      }
     65    }
     66
     67    protected virtual int GetNumberOfVisibleDataTables() {
     68      return checkedItemList.Content.CheckedItems.Count();
     69    }
     70
     71    protected virtual IEnumerable<DataTableControl> GetVisibleDataTables() {
     72      foreach (var name in Content.VariableItemList.CheckedItems) {
     73        if (!dataTableControls.ContainsKey(name.Value.Value))
     74          dataTableControls.Add(name.Value.Value, new DataTableControl() { Content = dataTables[name.Value.Value] });
     75        yield return dataTableControls[name.Value.Value];
     76      }
     77    }
     78
     79    protected virtual DataTable CreateDataTable(string variableName) {
     80      return null;
     81    }
     82
     83    protected virtual void InitData() {
     84      dataTables.Clear();
     85      dataTableControls.Clear();
     86      foreach (var variable in Content.VariableItemList.Select(v => v.Value)) {
     87        dataTables.Add(variable, CreateDataTable(variable));
     88      }
    9589    }
    9690
     
    10195        string variableName = item.Value.Value;
    10296
    103 
    10497        if (!IsVariableChecked(variableName)) {
    10598          // not checked -> remove
    106           dataTableView.SetRowEnabled(variableName, false);
    107           dataTable.SelectedRows.Remove(variableName);
    108           dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName)));
     99          //dataTableView.SetRowEnabled(variableName, false);
     100          //dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName)));
    109101        } else {
    110102          // checked -> add
    111           DataRow row = GetDataRow(variableName);
    112           DataRow selectedRow = GetSelectedDataRow(variableName);
    113           dataTableView.SetRowEnabled(variableName, true);
    114 
    115           PreprocessingDataTable pdt = new PreprocessingDataTable(variableName);
    116           pdt.Rows.Add(row);
     103          //DataRow row = GetDataRow(variableName);
     104          //dataTableView.SetRowEnabled(variableName, true);
     105
     106          //var pdt = new DataTable(variableName);
     107          //pdt.VisualProperties.Title = string.Empty;
     108          //pdt.Rows.Add(row);
    117109          // dataTablePerVariable does not contain unchecked variables => reduce insert position by number of uncheckt variables to correct the index
    118           int uncheckedUntilVariable = checkedItemList.Content.TakeWhile(x => x.Value != variableName).Count(x => !checkedItemList.Content.ItemChecked(x));
    119           dataTablePerVariable.Insert(item.Index - uncheckedUntilVariable, pdt);
    120 
    121           //update selection
    122           if (selectedRow != null) {
    123             dataTable.SelectedRows.Add(selectedRow);
    124             pdt.SelectedRows.Add(selectedRow);
    125           }
     110          //int uncheckedUntilVariable = checkedItemList.Content.TakeWhile(x => x.Value != variableName).Count(x => !checkedItemList.Content.ItemChecked(x));
     111          //dataTables.Insert(item.Index - uncheckedUntilVariable, pdt);
    126112        }
    127113      }
    128114
    129115      // update chart if not in all in one mode
    130       if (Content != null && !Content.AllInOneMode)
    131         GenerateChart();
    132     }
    133 
    134     private DataRow GetSelectedDataRow(string variableName) {
    135       foreach (DataRow row in selectedDataRows) {
    136         if (row.Name == variableName)
    137           return row;
    138       }
    139       return null;
    140     }
    141     private DataRow GetDataRow(string variableName) {
    142       foreach (DataRow row in dataRows) {
    143         if (row.Name == variableName)
    144           return row;
    145       }
    146       return null;
    147     }
     116      //if (Content != null && !Content.AllInOneMode)
     117      //GenerateChart();??
     118      GenerateLayout();
     119    }
     120
    148121
    149122    #region Add/Remove/Update Variable, Reset
    150123    protected override void AddVariable(string name) {
    151124      base.AddVariable(name);
    152       DataRow row = Content.CreateDataRow(name, chartType);
    153       dataTable.Rows.Add(row);
    154       PreprocessingDataTable d = new PreprocessingDataTable(name);
    155       d.Rows.Add(row);
    156       dataTablePerVariable.Add(d);
    157 
    158       if (!Content.AllInOneMode)
    159         GenerateChart();
     125      dataTables.Add(name, CreateDataTable(name));
     126
     127      GenerateLayout();
    160128    }
    161129
     
    163131    protected override void RemoveVariable(string name) {
    164132      base.RemoveVariable(name);
    165       dataTable.Rows.Remove(name);
    166       dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == name)));
    167 
    168       if (!Content.AllInOneMode)
    169         GenerateChart();
     133      dataTables.Remove(name);
     134      dataTableControls.Remove(name);
     135
     136      GenerateLayout();
    170137    }
    171138
    172139    protected override void UpdateVariable(string name) {
    173140      base.UpdateVariable(name);
    174       DataRow newRow = Content.CreateDataRow(name, chartType);
    175       dataTable.Rows.Remove(name);
    176       dataTable.Rows.Add(newRow);
    177       DataTable dt = dataTablePerVariable.Find(x => x.Rows.Find(y => y.Name == name) != null);
    178       if (dt != null) {
    179         dt.Rows.Remove(name);
    180         dt.Rows.Add(newRow);
    181       }
     141      dataTables.Remove(name);
     142      var newDataTable = CreateDataTable(name);
     143      dataTables.Add(name, newDataTable);
     144      dataTableControls[name].Content = newDataTable;
     145      GenerateLayout();
    182146    }
    183147    protected override void ResetAllVariables() {
     
    186150    #endregion
    187151
    188     #region Generate Charts
    189     protected void GenerateChart() {
     152    #region Generate Layout
     153    protected void GenerateLayout() {
     154      tableLayoutPanel.SuspendRepaint();
     155
    190156      ClearTableLayout();
    191       if (Content.AllInOneMode) {
    192         GenerateSingleChartLayout();
    193       } else
    194         GenerateMultiChartLayout();
    195     }
    196 
    197     private void GenerateSingleChartLayout() {
    198       tableLayoutPanel.ColumnCount = 1;
    199       tableLayoutPanel.RowCount = 1;
    200       tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
    201       tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
    202       tableLayoutPanel.Controls.Add(dataTableView, 0, 0);
    203       dataTableView.Content = dataTable;
    204     }
    205 
    206     private void GenerateMultiChartLayout() {
    207       int checkedItemsCnt = 0;
    208       foreach (var item in Content.VariableItemList.CheckedItems)
    209         checkedItemsCnt++;
    210 
    211       // set columns and rows based on number of items
    212       int columns = GetNrOfMultiChartColumns(checkedItemsCnt);
    213       int rows = GetNrOfMultiChartRows(checkedItemsCnt, columns);
     157
     158      int nrCharts = GetNumberOfVisibleDataTables();
     159
     160      // Set columns and rows based on number of items
     161      int columns = GetNrOfMultiChartColumns(nrCharts);
     162      int rows = GetNrOfMultiChartRows(nrCharts, columns);
    214163
    215164      tableLayoutPanel.ColumnCount = columns;
    216165      tableLayoutPanel.RowCount = rows;
    217166
    218       List<PreprocessingDataTable>.Enumerator enumerator = dataTablePerVariable.GetEnumerator();
    219       for (int x = 0; x < columns; x++) {
    220 
    221         if (rows <= MAX_TABLE_AUTO_SIZE_ROWS)
    222           tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns));
    223         else
    224           //scrollbar is shown if there are more than 3 rows -> remove scroll bar width from total width
    225           tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - System.Windows.Forms.SystemInformation.VerticalScrollBarWidth) / columns));
    226         for (int y = 0; y < rows; y++) {
    227           //Add a row only when creating the first column
    228           if (x == 0) {
    229             // fixed chart size when there are more than 3 tables
    230             if (rows > MAX_TABLE_AUTO_SIZE_ROWS)
    231               tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, FIXED_CHART_SIZE));
    232             else
    233               tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / rows));
     167      using (var enumerator = GetVisibleDataTables().GetEnumerator()) {
     168        for (int x = 0; x < columns; x++) {
     169          var columnStyle = rows <= MAX_TABLE_AUTO_SIZE_ROWS
     170            ? new ColumnStyle(SizeType.Percent, 100 / columns)
     171            : new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - SystemInformation.VerticalScrollBarWidth) / columns);
     172          tableLayoutPanel.ColumnStyles.Add(columnStyle);
     173
     174          for (int y = 0; y < rows; y++) {
     175            // Add a row only when creating the first column
     176            if (x == 0) {
     177              var rowStyle = rows > MAX_TABLE_AUTO_SIZE_ROWS
     178                ? new RowStyle(SizeType.Absolute, FIXED_CHART_SIZE)
     179                : new RowStyle(SizeType.Percent, 100 / rows);
     180              tableLayoutPanel.RowStyles.Add(rowStyle);
     181            }
     182
     183            if (enumerator.MoveNext())
     184              AddDataTableToTableLayout(enumerator.Current, x, y);
    234185          }
    235 
    236           enumerator.MoveNext();
    237           PreprocessingDataTable d = enumerator.Current;
    238           AddDataTableToTableLayout(d, x, y);
    239 
    240186        }
    241187      }
    242     }
     188
     189      tableLayoutPanel.ResumeRepaint(true);
     190    }
     191
    243192    private int GetNrOfMultiChartColumns(int itemCount) {
    244193      int columns = 0;
     
    262211    }
    263212
    264     private void AddDataTableToTableLayout(PreprocessingDataTable dataTable, int x, int y) {
    265       PreprocessingDataTableView dataView = new PreprocessingDataTableView();
    266       dataView.Classification = Classification;
    267       dataView.IsDetailedChartViewEnabled = IsDetailedChartViewEnabled;
     213    private void AddDataTableToTableLayout(DataTableControl dataTable, int x, int y) {
     214      //dataView.Classification = Classification;
     215      //dataView.IsDetailedChartViewEnabled = IsDetailedChartViewEnabled;
    268216
    269217      if (dataTable == null) {
    270218        // dummy panel for empty field
    271         Panel p = new Panel();
    272         p.Dock = DockStyle.Fill;
     219        Panel p = new Panel { Dock = DockStyle.Fill };
    273220        tableLayoutPanel.Controls.Add(p, y, x);
    274221      } else {
    275         dataView.Content = dataTable;
    276         dataView.Dock = DockStyle.Fill;
    277         tableLayoutPanel.Controls.Add(dataView, y, x);
     222        dataTable.Dock = DockStyle.Fill;
     223        tableLayoutPanel.Controls.Add(dataTable, y, x);
    278224      }
    279225    }
     
    286232      tableLayoutPanel.ColumnStyles.Clear();
    287233      tableLayoutPanel.RowStyles.Clear();
     234
     235      tableLayoutPanel.Width = 0;
     236      tableLayoutPanel.Height = 0;
     237
    288238      tableLayoutPanel.AutoScroll = false;
    289239      tableLayoutPanel.AutoScroll = true;
     
    301251    }
    302252    #endregion
    303 
    304     #region Update Selection
    305     protected override void PreprocessingData_SelctionChanged(object sender, EventArgs e) {
    306       base.PreprocessingData_SelctionChanged(sender, e);
    307       UpdateSelection();
    308     }
    309 
    310     private void UpdateSelection() {
    311       //update data table selection
    312       selectedDataRows = Content.CreateAllSelectedDataRows(chartType);
    313       dataTable.SelectedRows.Clear();
    314       foreach (var selectedRow in selectedDataRows) {
    315         if (IsVariableChecked(selectedRow.Name))
    316           dataTable.SelectedRows.Add(selectedRow);
    317       }
    318 
    319       //update data table per variable selection
    320       foreach (PreprocessingDataTable d in dataTablePerVariable) {
    321         d.SelectedRows.Clear();
    322         DataRow row = selectedDataRows.Find(x => x.Name == d.Name);
    323         if (row != null)
    324           d.SelectedRows.Add(row);
    325       }
    326     }
    327     #endregion
    328253  }
    329254}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingCheckedVariablesView.cs

    r14425 r14459  
    3333  [View("Preprocessing Checked Variables View")]
    3434  [Content(typeof(PreprocessingChartContent), false)]
    35   public abstract partial class PreprocessingCheckedVariablesView : ItemView {
     35  public partial class PreprocessingCheckedVariablesView : ItemView {
    3636
    3737    public new PreprocessingChartContent Content {
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs

    r14446 r14459  
    253253      if (!bodyCache.ContainsKey(key)) {
    254254        if (rowVariable == colVariable) { // use historgram if x and y variable are equal
    255           PreprocessingDataTable dataTable = new PreprocessingDataTable();
     255          var dataTable = new DataTable();
    256256          DataRow dataRow = Content.CreateDataRow(rowVariable, DataRowVisualProperties.DataRowChartType.Histogram);
     257          dataRow.VisualProperties.IsVisibleInLegend = false;
    257258          dataTable.Rows.Add(dataRow);
    258           PreprocessingDataTableView pcv = new PreprocessingDataTableView {
     259          var pcv = new DataTableControl {
    259260            Name = key.ToString(),
    260261            Content = dataTable,
    261262            Dock = DockStyle.Fill,
    262             ShowLegend = false,
    263             XAxisFormat = "G3"
     263            //ShowLegend = false,
     264            //XAxisFormat = "G3"
    264265          };
    265           pcv.ChartDoubleClick += HistogramDoubleClick;
     266          //pcv.ChartDoubleClick += HistogramDoubleClick;
    266267          bodyCache.Add(key, pcv);
    267268        } else { //scatter plot
     
    361362    //open histogram in new tab with new content when double clicked
    362363    private void HistogramDoubleClick(object sender, EventArgs e) {
    363       PreprocessingDataTableView pcv = (PreprocessingDataTableView)sender;
     364      DataTableControl pcv = (DataTableControl)sender;
    364365      HistogramContent histoContent = new HistogramContent(Content.PreprocessingData);  // create new content     
    365366      histoContent.VariableItemList = Content.CreateVariableItemList();
    366       PreprocessingDataTable dataTable = pcv.Content;
     367      var dataTable = pcv.Content;
    367368
    368369      //Set variable item list from with variable from data table
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/HistogramContent.cs

    r14185 r14459  
    3535    private const int MAX_DISTINCT_VALUES_FOR_CLASSIFCATION = 20;
    3636
    37     private int classifierVariableIndex = 0;
     37    public int ClassifierVariableIndex { get; set; }
    3838
    39     public int ClassifierVariableIndex {
    40       get { return this.classifierVariableIndex; }
    41       set { this.classifierVariableIndex = value; }
    42     }
    43     public bool IsDetailedChartViewEnabled { get; set; }
    44 
     39    public int Bins { get; set; }
     40    public bool ExactBins { get; set; }
    4541
    4642    public HistogramContent(IFilteredPreprocessingData preprocessingData)
    4743      : base(preprocessingData) {
    48       AllInOneMode = false;
     44      Bins = 10;
     45      ExactBins = false;
    4946    }
    5047
     
    7067      return doubleVariableNames;
    7168    }
    72 
    7369  }
    7470}
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/LineChartContent.cs

    r14185 r14459  
    2929  public class LineChartContent : PreprocessingChartContent {
    3030
     31    private bool allInOneMode = true;
     32    public bool AllInOneMode {
     33      get { return this.allInOneMode; }
     34      set { this.allInOneMode = value; }
     35    }
     36
    3137    public static new Image StaticItemImage {
    3238      get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }
     
    3945    public LineChartContent(LineChartContent content, Cloner cloner)
    4046      : base(content, cloner) {
     47      this.allInOneMode = content.allInOneMode;
    4148    }
    4249    public override IDeepCloneable Clone(Cloner cloner) {
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs

    r14418 r14459  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Drawing;
     
    3332    public static new Image StaticItemImage {
    3433      get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; }
    35     }
    36 
    37     private bool allInOneMode = true;
    38     public bool AllInOneMode {
    39       get { return this.allInOneMode; }
    40       set { this.allInOneMode = value; }
    4134    }
    4235
     
    5548    public PreprocessingChartContent(PreprocessingChartContent content, Cloner cloner)
    5649      : base(content, cloner) {
    57       this.allInOneMode = content.allInOneMode;
    5850      this.PreprocessingData = content.PreprocessingData;
    5951      this.variableItemList = cloner.Clone<ICheckedItemList<StringValue>>(variableItemList);
     
    6254      return new PreprocessingChartContent(this, cloner);
    6355    }
    64 
    6556
    6657    public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
     
    7162    }
    7263
    73     public List<DataRow> CreateAllDataRows(DataRowVisualProperties.DataRowChartType chartType) {
    74       List<DataRow> dataRows = new List<DataRow>();
    75       foreach (var name in PreprocessingData.GetDoubleVariableNames())
    76         dataRows.Add(CreateDataRow(name, chartType));
    77       return dataRows;
    78     }
    7964
    80     public DataRow CreateSelectedDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
    81 
    82       IDictionary<int, IList<int>> selection = PreprocessingData.Selection;
    83       int variableIndex = PreprocessingData.GetColumnIndex(variableName);
    84 
    85       if (selection.Keys.Contains(variableIndex)) {
    86         List<int> selectedIndices = new List<int>(selection[variableIndex]);
    87         //need selection with more than 1 value
    88         if (selectedIndices.Count < 2)
    89           return null;
    90 
    91         selectedIndices.Sort();
    92         int start = selectedIndices[0];
    93         int end = selectedIndices[selectedIndices.Count - 1];
    94 
    95         DataRow rowSelect = CreateDataRowRange(variableName, start, end, chartType);
    96         return rowSelect;
    97       } else
    98         return null;
    99     }
    100 
    101     public DataRow CreateDataRowRange(string variableName, int start, int end, DataRowVisualProperties.DataRowChartType chartType) {
    102       IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName));
    103       IList<double> valuesRange = new List<double>();
    104       for (int i = 0; i < values.Count; i++) {
    105         if (i >= start && i <= end)
    106           valuesRange.Add(values[i]);
    107         else
    108           valuesRange.Add(Double.NaN);
    109       }
    110 
    111       DataRow row = new DataRow(variableName, "", valuesRange);
    112       row.VisualProperties.ChartType = chartType;
    113       return row;
    114     }
    115 
    116     public List<DataRow> CreateAllSelectedDataRows(DataRowVisualProperties.DataRowChartType chartType) {
    117       List<DataRow> dataRows = new List<DataRow>();
    118       foreach (var name in PreprocessingData.GetDoubleVariableNames()) {
    119         DataRow row = CreateSelectedDataRow(name, chartType);
    120         if (row != null)
    121           dataRows.Add(row);
    122       }
    123       return dataRows;
    124     }
    12565
    12666
  • branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj

    r14445 r14459  
    126126    <Compile Include="Content\PreprocessingChartContent.cs" />
    127127    <Compile Include="Data\PreprocessingData.cs" />
    128     <Compile Include="Content\PreprocessingDataTable.cs" />
    129128    <Compile Include="Content\IViewChartShortcut.cs" />
    130129    <Compile Include="Data\IFilteredPreprocessingData.cs" />
Note: See TracChangeset for help on using the changeset viewer.