Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14963


Ignore:
Timestamp:
05/11/17 13:44:01 (7 years ago)
Author:
gkronber
Message:

#2698: merged r14381 r14382 r14384 r14388 r14418 r14425 from trunk to stable

Location:
stable
Files:
12 edited
4 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.DataPreprocessing.Views

  • stable/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj

    r14075 r14963  
    9898  <ItemGroup>
    9999    <Compile Include="DataPreprocessingMenuItem.cs" />
     100    <Compile Include="PreprocessingChartView.cs">
     101      <SubType>UserControl</SubType>
     102    </Compile>
     103    <Compile Include="PreprocessingChartView.Designer.cs">
     104      <DependentUpon>PreprocessingChartView.cs</DependentUpon>
     105    </Compile>
    100106    <Compile Include="PreprocessingFeatureCorrelationView.cs">
    101107      <SubType>UserControl</SubType>
     
    202208    </Compile>
    203209    <Compile Include="Plugin.cs" />
    204     <Compile Include="PreprocessingChartView.cs">
    205       <SubType>UserControl</SubType>
    206     </Compile>
    207     <Compile Include="PreprocessingChartView.Designer.cs">
    208       <DependentUpon>PreprocessingChartView.cs</DependentUpon>
     210    <Compile Include="PreprocessingCheckedVariablesView.cs">
     211      <SubType>UserControl</SubType>
     212    </Compile>
     213    <Compile Include="PreprocessingCheckedVariablesView.Designer.cs">
     214      <DependentUpon>PreprocessingCheckedVariablesView.cs</DependentUpon>
    209215    </Compile>
    210216    <Compile Include="PreprocessingCheckedItemListView.cs">
  • stable/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs

    r14382 r14963  
    6161        InitData();
    6262        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        }
    6372      }
    6473    }
     
    7180
    7281      //add data rows to data tables according to checked item list
    73       foreach (var checkedItem in Content.VariableItemList.CheckedItems) {
    74         string variableName = Content.VariableItemList[checkedItem.Index].Value;
     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
    7589        PreprocessingDataTable d = new PreprocessingDataTable(variableName);
    76         DataRow row = GetDataRow(variableName);
    77 
    78         if (row != null) {
    79           //add row to data table
    80           dataTable.Rows.Add(row);
    81 
    82           //add row to data table per variable
    83           d.Rows.Add(row);
    84           dataTablePerVariable.Add(d);
    85         }
     90        d.Rows.Add(row);
     91        dataTablePerVariable.Add(d);
    8692      }
    8793
     
    95101        string variableName = item.Value.Value;
    96102
    97         // not checked -> remove
    98         if (!VariableIsChecked(variableName)) {
     103
     104        if (!IsVariableChecked(variableName)) {
     105          // not checked -> remove
    99106          dataTableView.SetRowEnabled(variableName, false);
    100107          dataTable.SelectedRows.Remove(variableName);
    101108          dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName)));
    102109        } else {
     110          // checked -> add
    103111          DataRow row = GetDataRow(variableName);
    104112          DataRow selectedRow = GetSelectedDataRow(variableName);
     
    305313      dataTable.SelectedRows.Clear();
    306314      foreach (var selectedRow in selectedDataRows) {
    307         if (VariableIsChecked(selectedRow.Name))
     315        if (IsVariableChecked(selectedRow.Name))
    308316          dataTable.SelectedRows.Add(selectedRow);
    309317      }
  • stable/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingCheckedVariablesView.cs

    r14382 r14963  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    2425using System.Linq;
     
    4344    }
    4445
    45     protected bool VariableIsChecked(string name) {
     46    protected bool IsVariableChecked(string name) {
    4647      return Content.VariableItemList.CheckedItems.Any(x => x.Value.Value == name);
    4748    }
    48 
     49    protected IList<string> GetCheckedVariables() {
     50      return checkedItemList.Content.CheckedItems.Select(i => i.Value.Value).ToList();
     51    }
    4952
    5053    protected override void OnContentChanged() {
     
    5356
    5457      if (Content.VariableItemList == null) {
    55         Content.VariableItemList = Content.CreateVariableItemList();
     58        IList<string> inputs = Content.PreprocessingData.InputVariables;
     59        if (Content.PreprocessingData.TargetVariable != null)
     60          inputs = inputs.Union(new[] { Content.PreprocessingData.TargetVariable }).ToList();
     61        Content.VariableItemList = Content.CreateVariableItemList(inputs);
    5662      } else {
    5763        var checkedNames = Content.VariableItemList.CheckedItems.Select(x => x.Value.Value);
    58         Content.VariableItemList = Content.CreateVariableItemList(checkedNames);
     64        Content.VariableItemList = Content.CreateVariableItemList(checkedNames.ToList());
    5965      }
    6066      Content.VariableItemList.CheckedItemsChanged += CheckedItemsChanged;
     
    6470      var inputAndTarget = Content.PreprocessingData.InputVariables.Union(target != null ? new[] { target } : new string[] { });
    6571      foreach (var col in Content.PreprocessingData.GetDoubleVariableNames().Except(inputAndTarget)) {
    66         var listViewItem = checkedItemList.ItemsListView.FindItemWithText(col);
     72        var listViewItem = checkedItemList.ItemsListView.FindItemWithText(col, false, 0, false);
    6773        listViewItem.ForeColor = Color.LightGray;
    6874      }
     
    103109      Content.VariableItemList.Add(new StringValue(name));
    104110      if (!Content.PreprocessingData.InputVariables.Contains(name) && Content.PreprocessingData.TargetVariable != name) {
    105         var listViewItem = checkedItemList.ItemsListView.FindItemWithText(name);
     111        var listViewItem = checkedItemList.ItemsListView.FindItemWithText(name, false, 0, false);
    106112        listViewItem.ForeColor = Color.LightGray;
    107113      }
  • stable/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingDataTableView.cs

    r14796 r14963  
    4343      get { return (PreprocessingDataTable)base.Content; }
    4444      set { base.Content = value; }
     45    }
     46
     47    public bool ShowLegend {
     48      get { return chart.Legends[0].Enabled; }
     49      set { chart.Legends[0].Enabled = value; }
     50    }
     51
     52    public string XAxisFormat {
     53      get { return chart.ChartAreas[0].AxisX.LabelStyle.Format; }
     54      set { chart.ChartAreas[0].AxisX.LabelStyle.Format = value; }
     55    }
     56    public string YAxisFormat {
     57      get { return chart.ChartAreas[0].AxisY.LabelStyle.Format; }
     58      set { chart.ChartAreas[0].AxisY.LabelStyle.Format = value; }
    4559    }
    4660
  • stable/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingScatterPlotView.cs

    r14186 r14963  
    4444      get { return (ScatterPlot)base.Content; }
    4545      set { base.Content = value; }
     46    }
     47
     48    public bool ShowLegend {
     49      get { return chart.Legends[0].Enabled; }
     50      set { chart.Legends[0].Enabled = value; }
     51    }
     52
     53    public string XAxisFormat {
     54      get { return chart.ChartAreas[0].AxisX.LabelStyle.Format; }
     55      set { chart.ChartAreas[0].AxisX.LabelStyle.Format = value; }
     56    }
     57    public string YAxisFormat {
     58      get { return chart.ChartAreas[0].AxisY.LabelStyle.Format; }
     59      set { chart.ChartAreas[0].AxisY.LabelStyle.Format = value; }
    4660    }
    4761
  • stable/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.Designer.cs

    r14186 r14963  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     47      this.frameTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     48      this.columnHeaderScrollPanel = new System.Windows.Forms.Panel();
     49      this.columnHeaderTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     50      this.rowHeaderScrollPanel = new System.Windows.Forms.Panel();
     51      this.rowHeaderTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     52      this.bodyScrollPanel = new System.Windows.Forms.Panel();
     53      this.bodyTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     54      this.sizeGroupBox = new System.Windows.Forms.GroupBox();
     55      this.heightLabel = new System.Windows.Forms.Label();
     56      this.widthLabel = new System.Windows.Forms.Label();
     57      this.heightTrackBar = new System.Windows.Forms.TrackBar();
     58      this.widthTrackBar = new System.Windows.Forms.TrackBar();
     59      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     60      this.splitContainer.Panel1.SuspendLayout();
     61      this.splitContainer.Panel2.SuspendLayout();
     62      this.splitContainer.SuspendLayout();
     63      this.frameTableLayoutPanel.SuspendLayout();
     64      this.columnHeaderScrollPanel.SuspendLayout();
     65      this.rowHeaderScrollPanel.SuspendLayout();
     66      this.bodyScrollPanel.SuspendLayout();
     67      this.sizeGroupBox.SuspendLayout();
     68      ((System.ComponentModel.ISupportInitialize)(this.heightTrackBar)).BeginInit();
     69      ((System.ComponentModel.ISupportInitialize)(this.widthTrackBar)).BeginInit();
    4870      this.SuspendLayout();
    4971      //
    50       // tableLayoutPanel
    51       //
    52       this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    53             | System.Windows.Forms.AnchorStyles.Left)
     72      // checkedItemList
     73      //
     74      this.checkedItemList.Size = new System.Drawing.Size(113, 369);
     75      //
     76      // splitContainer
     77      //
     78      //
     79      // splitContainer.Panel1
     80      //
     81      this.splitContainer.Panel1.Controls.Add(this.sizeGroupBox);
     82      //
     83      // splitContainer.Panel2
     84      //
     85      this.splitContainer.Panel2.Controls.Add(this.frameTableLayoutPanel);
     86      this.splitContainer.Size = new System.Drawing.Size(863, 520);
     87      this.splitContainer.SplitterDistance = 120;
     88      //
     89      // frameTableLayoutPanel
     90      //
     91      this.frameTableLayoutPanel.ColumnCount = 2;
     92      this.frameTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
     93      this.frameTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
     94      this.frameTableLayoutPanel.Controls.Add(this.columnHeaderScrollPanel, 1, 0);
     95      this.frameTableLayoutPanel.Controls.Add(this.rowHeaderScrollPanel, 0, 1);
     96      this.frameTableLayoutPanel.Controls.Add(this.bodyScrollPanel, 1, 1);
     97      this.frameTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
     98      this.frameTableLayoutPanel.Location = new System.Drawing.Point(0, 0);
     99      this.frameTableLayoutPanel.Name = "frameTableLayoutPanel";
     100      this.frameTableLayoutPanel.RowCount = 2;
     101      this.frameTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
     102      this.frameTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
     103      this.frameTableLayoutPanel.Size = new System.Drawing.Size(739, 520);
     104      this.frameTableLayoutPanel.TabIndex = 0;
     105      //
     106      // columnHeaderScrollPanel
     107      //
     108      this.columnHeaderScrollPanel.Controls.Add(this.columnHeaderTableLayoutPanel);
     109      this.columnHeaderScrollPanel.Dock = System.Windows.Forms.DockStyle.Fill;
     110      this.columnHeaderScrollPanel.Location = new System.Drawing.Point(40, 0);
     111      this.columnHeaderScrollPanel.Margin = new System.Windows.Forms.Padding(0);
     112      this.columnHeaderScrollPanel.Name = "columnHeaderScrollPanel";
     113      this.columnHeaderScrollPanel.Size = new System.Drawing.Size(699, 40);
     114      this.columnHeaderScrollPanel.TabIndex = 3;
     115      //
     116      // columnHeaderTableLayoutPanel
     117      //
     118      this.columnHeaderTableLayoutPanel.AutoSize = true;
     119      this.columnHeaderTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     120      this.columnHeaderTableLayoutPanel.ColumnCount = 2;
     121      this.columnHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     122      this.columnHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     123      this.columnHeaderTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Left;
     124      this.columnHeaderTableLayoutPanel.Location = new System.Drawing.Point(0, 0);
     125      this.columnHeaderTableLayoutPanel.Margin = new System.Windows.Forms.Padding(0);
     126      this.columnHeaderTableLayoutPanel.Name = "columnHeaderTableLayoutPanel";
     127      this.columnHeaderTableLayoutPanel.RowCount = 1;
     128      this.columnHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     129      this.columnHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     130      this.columnHeaderTableLayoutPanel.Size = new System.Drawing.Size(0, 40);
     131      this.columnHeaderTableLayoutPanel.TabIndex = 1;
     132      //
     133      // rowHeaderScrollPanel
     134      //
     135      this.rowHeaderScrollPanel.Controls.Add(this.rowHeaderTableLayoutPanel);
     136      this.rowHeaderScrollPanel.Dock = System.Windows.Forms.DockStyle.Fill;
     137      this.rowHeaderScrollPanel.Location = new System.Drawing.Point(0, 40);
     138      this.rowHeaderScrollPanel.Margin = new System.Windows.Forms.Padding(0);
     139      this.rowHeaderScrollPanel.Name = "rowHeaderScrollPanel";
     140      this.rowHeaderScrollPanel.Size = new System.Drawing.Size(40, 480);
     141      this.rowHeaderScrollPanel.TabIndex = 4;
     142      //
     143      // rowHeaderTableLayoutPanel
     144      //
     145      this.rowHeaderTableLayoutPanel.AutoSize = true;
     146      this.rowHeaderTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     147      this.rowHeaderTableLayoutPanel.ColumnCount = 1;
     148      this.rowHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     149      this.rowHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     150      this.rowHeaderTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Top;
     151      this.rowHeaderTableLayoutPanel.Location = new System.Drawing.Point(0, 0);
     152      this.rowHeaderTableLayoutPanel.Margin = new System.Windows.Forms.Padding(0);
     153      this.rowHeaderTableLayoutPanel.Name = "rowHeaderTableLayoutPanel";
     154      this.rowHeaderTableLayoutPanel.RowCount = 2;
     155      this.rowHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     156      this.rowHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     157      this.rowHeaderTableLayoutPanel.Size = new System.Drawing.Size(40, 0);
     158      this.rowHeaderTableLayoutPanel.TabIndex = 2;
     159      //
     160      // bodyScrollPanel
     161      //
     162      this.bodyScrollPanel.AutoScroll = true;
     163      this.bodyScrollPanel.Controls.Add(this.bodyTableLayoutPanel);
     164      this.bodyScrollPanel.Dock = System.Windows.Forms.DockStyle.Fill;
     165      this.bodyScrollPanel.Location = new System.Drawing.Point(40, 40);
     166      this.bodyScrollPanel.Margin = new System.Windows.Forms.Padding(0);
     167      this.bodyScrollPanel.Name = "bodyScrollPanel";
     168      this.bodyScrollPanel.Size = new System.Drawing.Size(699, 480);
     169      this.bodyScrollPanel.TabIndex = 5;
     170      this.bodyScrollPanel.Scroll += new System.Windows.Forms.ScrollEventHandler(this.bodyScrollPanel_Scroll);
     171      //
     172      // bodyTableLayoutPanel
     173      //
     174      this.bodyTableLayoutPanel.AutoSize = true;
     175      this.bodyTableLayoutPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     176      this.bodyTableLayoutPanel.ColumnCount = 2;
     177      this.bodyTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     178      this.bodyTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     179      this.bodyTableLayoutPanel.Location = new System.Drawing.Point(0, 0);
     180      this.bodyTableLayoutPanel.Margin = new System.Windows.Forms.Padding(0);
     181      this.bodyTableLayoutPanel.Name = "bodyTableLayoutPanel";
     182      this.bodyTableLayoutPanel.RowCount = 2;
     183      this.bodyTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     184      this.bodyTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     185      this.bodyTableLayoutPanel.Size = new System.Drawing.Size(0, 0);
     186      this.bodyTableLayoutPanel.TabIndex = 0;
     187      //
     188      // sizeGroupBox
     189      //
     190      this.sizeGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
    54191            | System.Windows.Forms.AnchorStyles.Right)));
    55       this.tableLayoutPanel.AutoScroll = true;
    56       this.tableLayoutPanel.ColumnCount = 1;
    57       this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
    58       this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    59       this.tableLayoutPanel.Location = new System.Drawing.Point(3, 3);
    60       this.tableLayoutPanel.Name = "tableLayoutPanel";
    61       this.tableLayoutPanel.RowCount = 1;
    62       this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
    63       this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 514F));
    64       this.tableLayoutPanel.Size = new System.Drawing.Size(860, 514);
    65       this.tableLayoutPanel.TabIndex = 1;
    66       //
    67       // MultiScatterPlotView
     192      this.sizeGroupBox.Controls.Add(this.heightLabel);
     193      this.sizeGroupBox.Controls.Add(this.widthLabel);
     194      this.sizeGroupBox.Controls.Add(this.heightTrackBar);
     195      this.sizeGroupBox.Controls.Add(this.widthTrackBar);
     196      this.sizeGroupBox.Location = new System.Drawing.Point(4, 379);
     197      this.sizeGroupBox.Name = "sizeGroupBox";
     198      this.sizeGroupBox.Size = new System.Drawing.Size(113, 124);
     199      this.sizeGroupBox.TabIndex = 5;
     200      this.sizeGroupBox.TabStop = false;
     201      this.sizeGroupBox.Text = "Chart Size";
     202      //
     203      // heightLabel
     204      //
     205      this.heightLabel.AutoSize = true;
     206      this.heightLabel.Location = new System.Drawing.Point(6, 64);
     207      this.heightLabel.Name = "heightLabel";
     208      this.heightLabel.Size = new System.Drawing.Size(41, 13);
     209      this.heightLabel.TabIndex = 2;
     210      this.heightLabel.Text = "Height:";
     211      //
     212      // widthLabel
     213      //
     214      this.widthLabel.AutoSize = true;
     215      this.widthLabel.Location = new System.Drawing.Point(6, 16);
     216      this.widthLabel.Name = "widthLabel";
     217      this.widthLabel.Size = new System.Drawing.Size(38, 13);
     218      this.widthLabel.TabIndex = 1;
     219      this.widthLabel.Text = "Width:";
     220      //
     221      // heightTrackBar
     222      //
     223      this.heightTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     224            | System.Windows.Forms.AnchorStyles.Right)));
     225      this.heightTrackBar.LargeChange = 50;
     226      this.heightTrackBar.Location = new System.Drawing.Point(6, 83);
     227      this.heightTrackBar.Maximum = 100;
     228      this.heightTrackBar.Name = "heightTrackBar";
     229      this.heightTrackBar.Size = new System.Drawing.Size(101, 45);
     230      this.heightTrackBar.SmallChange = 10;
     231      this.heightTrackBar.TabIndex = 0;
     232      this.heightTrackBar.TickFrequency = 10;
     233      this.heightTrackBar.Value = 20;
     234      this.heightTrackBar.ValueChanged += new System.EventHandler(this.heightTrackBar_ValueChanged);
     235      //
     236      // widthTrackBar
     237      //
     238      this.widthTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     239            | System.Windows.Forms.AnchorStyles.Right)));
     240      this.widthTrackBar.LargeChange = 50;
     241      this.widthTrackBar.Location = new System.Drawing.Point(6, 32);
     242      this.widthTrackBar.Maximum = 100;
     243      this.widthTrackBar.Name = "widthTrackBar";
     244      this.widthTrackBar.Size = new System.Drawing.Size(101, 45);
     245      this.widthTrackBar.SmallChange = 10;
     246      this.widthTrackBar.TabIndex = 0;
     247      this.widthTrackBar.TickFrequency = 10;
     248      this.widthTrackBar.Value = 20;
     249      this.widthTrackBar.ValueChanged += new System.EventHandler(this.widthTrackBar_ValueChanged);
     250      //
     251      // ScatterPlotMultiView
    68252      //
    69253      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    70254      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    71       this.Controls.Add(this.tableLayoutPanel);
    72       this.Name = "MultiScatterPlotView";
    73       this.Size = new System.Drawing.Size(863, 517);
     255      this.Name = "ScatterPlotMultiView";
     256      this.Size = new System.Drawing.Size(863, 520);
     257      this.splitContainer.Panel1.ResumeLayout(false);
     258      this.splitContainer.Panel2.ResumeLayout(false);
     259      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
     260      this.splitContainer.ResumeLayout(false);
     261      this.frameTableLayoutPanel.ResumeLayout(false);
     262      this.columnHeaderScrollPanel.ResumeLayout(false);
     263      this.columnHeaderScrollPanel.PerformLayout();
     264      this.rowHeaderScrollPanel.ResumeLayout(false);
     265      this.rowHeaderScrollPanel.PerformLayout();
     266      this.bodyScrollPanel.ResumeLayout(false);
     267      this.bodyScrollPanel.PerformLayout();
     268      this.sizeGroupBox.ResumeLayout(false);
     269      this.sizeGroupBox.PerformLayout();
     270      ((System.ComponentModel.ISupportInitialize)(this.heightTrackBar)).EndInit();
     271      ((System.ComponentModel.ISupportInitialize)(this.widthTrackBar)).EndInit();
    74272      this.ResumeLayout(false);
    75273
     
    78276    #endregion
    79277
    80     private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
    81 
     278    private System.Windows.Forms.TableLayoutPanel frameTableLayoutPanel;
     279    private System.Windows.Forms.TableLayoutPanel columnHeaderTableLayoutPanel;
     280    private System.Windows.Forms.TableLayoutPanel rowHeaderTableLayoutPanel;
     281    private System.Windows.Forms.TableLayoutPanel bodyTableLayoutPanel;
     282    private System.Windows.Forms.Panel columnHeaderScrollPanel;
     283    private System.Windows.Forms.Panel rowHeaderScrollPanel;
     284    private System.Windows.Forms.Panel bodyScrollPanel;
     285    private System.Windows.Forms.GroupBox sizeGroupBox;
     286    private System.Windows.Forms.TrackBar widthTrackBar;
     287    private System.Windows.Forms.TrackBar heightTrackBar;
     288    private System.Windows.Forms.Label heightLabel;
     289    private System.Windows.Forms.Label widthLabel;
    82290  }
    83291}
  • stable/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs

    r14075 r14963  
    55using System.Windows.Forms;
    66using HeuristicLab.Analysis;
     7using HeuristicLab.Collections;
    78using HeuristicLab.Common;
    89using HeuristicLab.Core.Views;
     10using HeuristicLab.Data;
    911using HeuristicLab.MainForm;
     12using HeuristicLab.MainForm.WindowsForms;
    1013
    1114namespace HeuristicLab.DataPreprocessing.Views {
    1215  [View("Scatter Plot Multi View")]
    1316  [Content(typeof(ScatterPlotContent), false)]
    14   public partial class ScatterPlotMultiView : ItemView {
    15 
    16     private const int HEADER_WIDTH = 50;
    17     private const int HEADER_HEIGHT = 50;
    18     private const int MAX_AUTO_SIZE_ELEMENTS = 6;
    19     private const int FIXED_CHART_WIDTH = 250;
    20     private const int FIXED_CHART_HEIGHT = 150;
     17  public partial class ScatterPlotMultiView : PreprocessingCheckedVariablesView {
     18    private readonly IDictionary<string, Label> columnHeaderCache;
     19    private readonly IDictionary<string, Label> rowHeaderCache;
     20    private readonly IDictionary<Tuple<string/*col*/, string/*row*/>, ItemView> bodyCache;
    2121
    2222    public ScatterPlotMultiView() {
    2323      InitializeComponent();
     24
     25      #region Initialize Scrollbars
     26      columnHeaderScrollPanel.HorizontalScroll.Enabled = true;
     27      columnHeaderScrollPanel.VerticalScroll.Enabled = false;
     28      columnHeaderScrollPanel.HorizontalScroll.Visible = false;
     29      columnHeaderScrollPanel.VerticalScroll.Visible = false;
     30
     31      rowHeaderScrollPanel.HorizontalScroll.Enabled = false;
     32      rowHeaderScrollPanel.VerticalScroll.Enabled = true;
     33      rowHeaderScrollPanel.HorizontalScroll.Visible = false;
     34      rowHeaderScrollPanel.VerticalScroll.Visible = false;
     35
     36      bodyScrollPanel.HorizontalScroll.Enabled = true;
     37      bodyScrollPanel.VerticalScroll.Enabled = true;
     38      bodyScrollPanel.HorizontalScroll.Visible = true;
     39      bodyScrollPanel.VerticalScroll.Visible = true;
     40      bodyScrollPanel.AutoScroll = true;
     41      #endregion
     42
     43      columnHeaderCache = new Dictionary<string, Label>();
     44      rowHeaderCache = new Dictionary<string, Label>();
     45      bodyCache = new Dictionary<Tuple<string, string>, ItemView>();
     46
     47      bodyScrollPanel.MouseWheel += bodyScrollPanel_MouseWheel;
    2448    }
    2549
     
    3256      base.OnContentChanged();
    3357      if (Content != null) {
    34         GenerateMultiLayout();
    35       }
    36     }
    37 
    38     //Add header elements to the table layout panel
    39     private void addHeaderToTableLayoutPanels() {
    40 
    41       List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList();
    42 
    43       for (int i = 1; i < variables.Count + 1; i++) {
    44         // Use buttons for header elements
    45         Button xButton = new Button();
    46         xButton.Enabled = false;
    47         xButton.BackColor = Color.Gainsboro;
    48         xButton.Text = variables[i - 1];
    49         xButton.Dock = DockStyle.Fill;
    50         tableLayoutPanel.Controls.Add(xButton, 0, i);
    51         Button yButton = new Button();
    52         yButton.Enabled = false;
    53         yButton.BackColor = Color.Gainsboro;
    54         yButton.Text = variables[i - 1];
    55         yButton.Dock = DockStyle.Fill;
    56         tableLayoutPanel.Controls.Add(yButton, i, 0);
    57       }
    58     }
    59 
    60     private void GenerateMultiLayout() {
    61       List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList();
    62 
    63       tableLayoutPanel.Controls.Clear();
    64       //Clear out the existing row and column styles
    65       tableLayoutPanel.ColumnStyles.Clear();
    66       tableLayoutPanel.RowStyles.Clear();
    67 
    68       //Set row and column count
    69       tableLayoutPanel.ColumnCount = variables.Count + 1;
    70       tableLayoutPanel.RowCount = variables.Count + 1;
    71 
    72       tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, HEADER_WIDTH));
    73       tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, HEADER_HEIGHT));
    74       // set column and row layout
    75       for (int x = 0; x < variables.Count; x++) {
    76         // auto size
    77         if (variables.Count <= MAX_AUTO_SIZE_ELEMENTS) {
    78           tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - HEADER_WIDTH) / variables.Count));
    79           tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, (tableLayoutPanel.Height - HEADER_HEIGHT) / variables.Count));
    80         }
    81         // fixed size
    82         else {
    83           tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, FIXED_CHART_WIDTH));
    84           tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, FIXED_CHART_HEIGHT));
    85         }
    86       }
    87 
    88       addHeaderToTableLayoutPanels();
    89       addChartsToTableLayoutPanel();
    90 
    91     }
    92 
    93     private void addChartsToTableLayoutPanel() {
    94 
    95       List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList();
    96 
    97       //set scatter plots and histograms
    98       for (int x = 1; x < variables.Count + 1; x++) {
    99 
    100         for (int y = 1; y < variables.Count + 1; y++) {
    101           // use historgram if x and y variable are equal
    102           if (x == y) {
    103             PreprocessingDataTable dataTable = new PreprocessingDataTable();
    104             DataRow dataRow = Content.CreateDataRow(variables[x - 1], DataRowVisualProperties.DataRowChartType.Histogram);
    105             dataTable.Rows.Add(dataRow);
    106             PreprocessingDataTableView pcv = new PreprocessingDataTableView();
    107             pcv.ChartDoubleClick += HistogramDoubleClick;
    108             pcv.Content = dataTable;
    109             tableLayoutPanel.Controls.Add(pcv, y, x);
     58        GenerateCharts();
     59      }
     60    }
     61
     62    protected override void CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> checkedItems) {
     63      base.CheckedItemsChanged(sender, checkedItems);
     64      foreach (var variable in checkedItems.Items.Select(i => i.Value.Value)) {
     65        if (IsVariableChecked(variable))
     66          AddChartToTable(variable);
     67        else
     68          RemoveChartFromTable(variable);
     69      }
     70    }
     71
     72    #region Add and remove charts
     73    private void AddChartToTable(string variable) {
     74      frameTableLayoutPanel.SuspendLayout();
     75
     76      // find index to insert
     77      var variables = checkedItemList.Content.Select(v => v.Value).ToList();
     78      int idx = variables              // all variables
     79        .TakeWhile(t => t != variable) // ... until the variable that was checked
     80        .Count(IsVariableChecked);     // ... how many checked variables
     81
     82      // add column header
     83      var colH = columnHeaderTableLayoutPanel;
     84      AddColumnHelper(colH, idx, _ => GetColumnHeader(variable));
     85
     86      // add row header
     87      var rowH = rowHeaderTableLayoutPanel;
     88      AddRowHelper(rowH, idx, _ => GetRowHeader(variable));
     89
     90      // add body
     91      var body = bodyTableLayoutPanel;
     92      var vars = GetCheckedVariables();
     93      var varsMinus = vars.Except(new[] { variable }).ToList();
     94      AddColumnHelper(body, idx, r => GetBody(variable, varsMinus[r])); // exclude "variable" because the row for it does not exist yet
     95      AddRowHelper(body, idx, c => GetBody(vars[c], variable));
     96
     97      frameTableLayoutPanel.ResumeLayout(true);
     98    }
     99    private void AddColumnHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) {
     100      // add column
     101      tlp.ColumnCount++;
     102      tlp.ColumnStyles.Insert(idx, new ColumnStyle(SizeType.Absolute, GetColumnWidth()));
     103      // shift right
     104      for (int c = tlp.ColumnCount; c >  idx - 1; c--) {
     105        for (int r = 0; r < tlp.RowCount; r++) {
     106          var control = tlp.GetControlFromPosition(c, r);
     107          if (control != null) {
     108            tlp.SetColumn(control, c + 1);
    110109          }
    111           //scatter plot
    112           else {
    113             ScatterPlot scatterPlot = Content.CreateScatterPlot(variables[x - 1], variables[y - 1]);
    114             PreprocessingScatterPlotView pspv = new PreprocessingScatterPlotView();
    115             pspv.ChartDoubleClick += ScatterPlotDoubleClick;
    116             pspv.Content = scatterPlot;
    117             pspv.Dock = DockStyle.Fill;
    118             tableLayoutPanel.Controls.Add(pspv, x, y);
     110        }
     111      }
     112      // add controls
     113      for (int r = 0; r < tlp.RowCount; r++) {
     114        if (tlp.GetControlFromPosition(idx, r) == null)
     115          tlp.Controls.Add(creatorFunc(r), idx, r);
     116      }
     117
     118    }
     119    private void AddRowHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) {
     120      // add row
     121      tlp.RowCount++;
     122      tlp.RowStyles.Insert(idx, new RowStyle(SizeType.Absolute, GetRowHeight()));
     123      // shift right
     124      for (int r = tlp.RowCount; r > idx - 1; r--) {
     125        for (int c = 0; c < tlp.ColumnCount; c++) {
     126          var control = tlp.GetControlFromPosition(c, r);
     127          if (control != null) {
     128            tlp.SetRow(control, r + 1);
    119129          }
    120130        }
    121131      }
    122     }
    123 
     132      // add controls
     133      for (int c = 0; c < tlp.ColumnCount; c++)
     134        if (tlp.GetControlFromPosition(c, idx) == null)
     135          tlp.Controls.Add(creatorFunc(c), c, idx);
     136    }
     137
     138    private void RemoveChartFromTable(string variable) {
     139      frameTableLayoutPanel.SuspendLayout();
     140
     141      // remove column header
     142      var colH = columnHeaderTableLayoutPanel;
     143      int colIdx = colH.GetColumn(colH.Controls[variable]);
     144      RemoveColumnHelper(colH, colIdx);
     145
     146      // remove row header
     147      var rowH = rowHeaderTableLayoutPanel;
     148      int rowIdx = rowH.GetRow(rowH.Controls[variable]);
     149      RemoveRowHelper(rowH, rowIdx);
     150
     151      // remove from body
     152      var body = bodyTableLayoutPanel;
     153      RemoveColumnHelper(body, colIdx);
     154      RemoveRowHelper(body, rowIdx);
     155
     156      frameTableLayoutPanel.ResumeLayout(true);
     157    }
     158    private void RemoveColumnHelper(TableLayoutPanel tlp, int idx) {
     159      // remove controls
     160      for (int r = 0; r < tlp.RowCount; r++)
     161        tlp.Controls.Remove(tlp.GetControlFromPosition(idx, r));
     162      // shift left
     163      for (int c = idx + 1; c < tlp.ColumnCount; c++) {
     164        for (int r = 0; r < tlp.RowCount; r++) {
     165          var control = tlp.GetControlFromPosition(c, r);
     166          if (control != null) {
     167            tlp.SetColumn(control, c - 1);
     168          }
     169        }
     170      }
     171      // delete column
     172      tlp.ColumnStyles.RemoveAt(tlp.ColumnCount - 1);
     173      tlp.ColumnCount--;
     174    }
     175    private void RemoveRowHelper(TableLayoutPanel tlp, int idx) {
     176      // remove controls
     177      for (int c = 0; c < tlp.ColumnCount; c++)
     178        tlp.Controls.Remove(tlp.GetControlFromPosition(c, idx));
     179      // shift left
     180      for (int r = idx + 1; r < tlp.RowCount; r++) {
     181        for (int c = 0; c < tlp.ColumnCount; c++) {
     182          var control = tlp.GetControlFromPosition(c, r);
     183          if (control != null) {
     184            tlp.SetRow(control, r - 1);
     185          }
     186        }
     187      }
     188      // delete rows
     189      tlp.RowStyles.RemoveAt(tlp.RowCount - 1);
     190      tlp.RowCount--;
     191    }
     192    #endregion
     193
     194    #region Add/Remove/Update Variable
     195    protected override void AddVariable(string name) {
     196      base.AddVariable(name);
     197      if (IsVariableChecked(name))
     198        AddChartToTable(name);
     199    }
     200    protected override void RemoveVariable(string name) {
     201      base.RemoveVariable(name);
     202
     203      // clear caches
     204      columnHeaderCache.Remove(name);
     205      rowHeaderCache.Remove(name);
     206      var keys = bodyCache.Keys.Where(t => t.Item1 == name || t.Item2 == name).ToList();
     207      foreach (var key in keys)
     208        bodyCache.Remove(key);
     209
     210      if (IsVariableChecked(name)) {
     211        RemoveChartFromTable(name);
     212      }
     213    }
     214    protected override void UpdateVariable(string name) {
     215      base.UpdateVariable(name);
     216      RemoveVariable(name);
     217      AddVariable(name);
     218    }
     219    protected override void ResetAllVariables() {
     220      GenerateCharts();
     221    }
     222    #endregion
     223
     224    #region Creating Headers and Body
     225    private Label GetColumnHeader(string variable) {
     226      if (!columnHeaderCache.ContainsKey(variable)) {
     227        columnHeaderCache.Add(variable, new Label() {
     228          Text = variable,
     229          TextAlign = ContentAlignment.MiddleCenter,
     230          Name = variable,
     231          Height = columnHeaderTableLayoutPanel.Height,
     232          Dock = DockStyle.Fill,
     233          Margin = new Padding(3)
     234        });
     235      }
     236      return columnHeaderCache[variable];
     237    }
     238    private Label GetRowHeader(string variable) {
     239      if (!rowHeaderCache.ContainsKey(variable)) {
     240        rowHeaderCache.Add(variable, new Label() {
     241          Text = variable,
     242          TextAlign = ContentAlignment.MiddleCenter,
     243          Name = variable,
     244          Width = rowHeaderTableLayoutPanel.Width,
     245          Dock = DockStyle.Fill,
     246          Margin = new Padding(3)
     247        });
     248      }
     249      return rowHeaderCache[variable];
     250    }
     251    private ItemView GetBody(string colVariable, string rowVariable) {
     252      var key = Tuple.Create(colVariable, rowVariable);
     253      if (!bodyCache.ContainsKey(key)) {
     254        if (rowVariable == colVariable) { // use historgram if x and y variable are equal
     255          PreprocessingDataTable dataTable = new PreprocessingDataTable();
     256          DataRow dataRow = Content.CreateDataRow(rowVariable, DataRowVisualProperties.DataRowChartType.Histogram);
     257          dataTable.Rows.Add(dataRow);
     258          PreprocessingDataTableView pcv = new PreprocessingDataTableView {
     259            Name = key.ToString(),
     260            Content = dataTable,
     261            Dock = DockStyle.Fill,
     262            ShowLegend = false,
     263            XAxisFormat = "G3"
     264          };
     265          pcv.ChartDoubleClick += HistogramDoubleClick;
     266          bodyCache.Add(key, pcv);
     267        } else { //scatter plot
     268          ScatterPlot scatterPlot = Content.CreateScatterPlot(colVariable, rowVariable);
     269          PreprocessingScatterPlotView pspv = new PreprocessingScatterPlotView {
     270            Name = key.ToString(),
     271            Content = scatterPlot,
     272            Dock = DockStyle.Fill,
     273            ShowLegend = false,
     274            XAxisFormat = "G3"
     275          };
     276          pspv.ChartDoubleClick += ScatterPlotDoubleClick;
     277          bodyCache.Add(key, pspv);
     278        }
     279      }
     280      return bodyCache[key];
     281    }
     282    #endregion
     283
     284    #region Generate Charts
     285    private void GenerateCharts() {
     286      var variables = GetCheckedVariables();
     287
     288      // Clear old layouts and cache
     289      foreach (var tableLayoutPanel in new[] { columnHeaderTableLayoutPanel, rowHeaderTableLayoutPanel, bodyTableLayoutPanel }) {
     290        tableLayoutPanel.Controls.Clear();
     291        tableLayoutPanel.ColumnStyles.Clear();
     292        tableLayoutPanel.RowStyles.Clear();
     293      }
     294      columnHeaderCache.Clear();
     295      rowHeaderCache.Clear();
     296      bodyCache.Clear();
     297
     298      // Set row and column count
     299      columnHeaderTableLayoutPanel.ColumnCount = variables.Count;
     300      rowHeaderTableLayoutPanel.RowCount = variables.Count;
     301      bodyTableLayoutPanel.ColumnCount = variables.Count;
     302      bodyTableLayoutPanel.RowCount = variables.Count;
     303
     304      // Set column and row layout
     305      for (int i = 0; i < variables.Count; i++) {
     306        columnHeaderTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, GetColumnWidth()));
     307        rowHeaderTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, GetRowHeight()));
     308        bodyTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, GetColumnWidth()));
     309        bodyTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, GetRowHeight()));
     310      }
     311
     312      frameTableLayoutPanel.SuspendLayout();
     313      AddHeaderToTableLayoutPanels();
     314      AddChartsToTableLayoutPanel();
     315      UpdateHeaderMargin();
     316      frameTableLayoutPanel.ResumeLayout(true);
     317    }
     318
     319    private void AddHeaderToTableLayoutPanels() {
     320      int i = 0;
     321      foreach (var variable in GetCheckedVariables()) {
     322        columnHeaderTableLayoutPanel.Controls.Add(GetColumnHeader(variable), i, 0);
     323        rowHeaderTableLayoutPanel.Controls.Add(GetRowHeader(variable), 0, i);
     324        i++;
     325      }
     326    }
     327    private void AddChartsToTableLayoutPanel() {
     328      int c = 0;
     329      foreach (var colVar in GetCheckedVariables()) {
     330        if (!IsVariableChecked(colVar)) continue;
     331        int r = 0;
     332        foreach (var rowVar in GetCheckedVariables()) {
     333          if (!IsVariableChecked(rowVar)) continue;
     334          bodyTableLayoutPanel.Controls.Add(GetBody(colVar, rowVar), c, r);
     335          r++;
     336        }
     337        c++;
     338      }
     339    }
     340
     341    #endregion
     342
     343    #region DoubleClick Events
    124344    //Open scatter plot in new tab with new content when double clicked
    125345    private void ScatterPlotDoubleClick(object sender, EventArgs e) {
     
    127347      ScatterPlotContent scatterContent = new ScatterPlotContent(Content, new Cloner());  // create new content
    128348      ScatterPlot scatterPlot = pspv.Content;
    129       setVariablesInContentFromScatterPlot(scatterContent, scatterPlot);
    130 
    131       MainFormManager.MainForm.ShowContent(scatterContent, typeof(ScatterPlotSingleView));  // open in new tab
    132     }
    133 
    134     //Extract variable names from scatter plot and set them in content
    135     private void setVariablesInContentFromScatterPlot(ScatterPlotContent scatterContent, ScatterPlot scatterPlot) {
    136 
    137       // only one data row should be in scatter plot
     349
     350      //Extract variable names from scatter plot and set them in content
    138351      if (scatterPlot.Rows.Count == 1) {
    139352        string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[] { " - " }, StringSplitOptions.None); // extract variable names from string
     
    141354        scatterContent.SelectedYVariable = variables[1];
    142355      }
    143     }
    144 
    145     //Set variable item list from with variable from data table
    146     private void setVariableItemListFromDataTable(HistogramContent histoContent, PreprocessingDataTable dataTable) {
    147 
    148       // only one data row should be in data table
    149       if (dataTable.Rows.Count == 1) {
    150         string variableName = dataTable.Rows.ElementAt(0).Name;
    151 
    152         // set only variable name checked
    153         foreach (var checkedItem in histoContent.VariableItemList) {
    154           if (checkedItem.Value == variableName)
    155             histoContent.VariableItemList.SetItemCheckedState(checkedItem, true);
    156           else
    157             histoContent.VariableItemList.SetItemCheckedState(checkedItem, false);
    158 
    159         }
    160       }
     356
     357      MainFormManager.MainForm.ShowContent(scatterContent, typeof(ScatterPlotSingleView));  // open in new tab
    161358    }
    162359
     
    167364      histoContent.VariableItemList = Content.CreateVariableItemList();
    168365      PreprocessingDataTable dataTable = pcv.Content;
    169       setVariableItemListFromDataTable(histoContent, dataTable);
    170 
     366
     367      //Set variable item list from with variable from data table
     368      if (dataTable.Rows.Count == 1) { // only one data row should be in data table
     369        string variableName = dataTable.Rows.ElementAt(0).Name;
     370
     371        // set only variable name checked
     372        foreach (var checkedItem in histoContent.VariableItemList) {
     373          histoContent.VariableItemList.SetItemCheckedState(checkedItem, checkedItem.Value == variableName);
     374        }
     375      }
    171376      MainFormManager.MainForm.ShowContent(histoContent, typeof(HistogramView));  // open in new tab
    172377    }
    173 
    174 
     378    #endregion
     379
     380    #region Scrolling
     381    private void bodyScrollPanel_Scroll(object sender, ScrollEventArgs e) {
     382      SyncScroll();
     383
     384      UpdateHeaderMargin();
     385    }
     386    private void bodyScrollPanel_MouseWheel(object sender, MouseEventArgs e) {
     387      // Scrolling with the mouse wheel is not captured in the Scoll event
     388      SyncScroll();
     389    }
     390    private void SyncScroll() {
     391      frameTableLayoutPanel.SuspendRepaint();
     392
     393      columnHeaderScrollPanel.HorizontalScroll.Minimum = bodyScrollPanel.HorizontalScroll.Minimum;
     394      columnHeaderScrollPanel.HorizontalScroll.Maximum = bodyScrollPanel.HorizontalScroll.Maximum;
     395      rowHeaderScrollPanel.VerticalScroll.Minimum = bodyScrollPanel.VerticalScroll.Minimum;
     396      rowHeaderScrollPanel.VerticalScroll.Maximum = bodyScrollPanel.VerticalScroll.Maximum;
     397
     398      columnHeaderScrollPanel.HorizontalScroll.Value = Math.Max(bodyScrollPanel.HorizontalScroll.Value, 1);
     399      rowHeaderScrollPanel.VerticalScroll.Value = Math.Max(bodyScrollPanel.VerticalScroll.Value, 1);
     400      // minimum 1 is nececary  because of two factors:
     401      // - setting the Value-property of Horizontal/VerticalScroll updates the internal state but the Value-property stays 0
     402      // - setting the same number of the Value-property has no effect
     403      // since the Value-property is always 0, setting it to 0 would have no effect; so it is set to 1 instead
     404
     405      frameTableLayoutPanel.ResumeRepaint(true);
     406    }
     407    // add a margin to the header table layouts if the scollbar is visible to account for the width/height of the scrollbar
     408    private void UpdateHeaderMargin() {
     409      columnHeaderScrollPanel.Margin = new Padding(0, 0, bodyScrollPanel.VerticalScroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0, 0);
     410      rowHeaderScrollPanel.Margin = new Padding(0, 0, 0, bodyScrollPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0);
     411    }
     412    #endregion
     413
     414    #region Sizing of Charts
     415    private int GetColumnWidth() { return (int)(bodyScrollPanel.Width * ((float)widthTrackBar.Value / 100)); }
     416    private int GetRowHeight() { return (int)(bodyScrollPanel.Height * ((float)heightTrackBar.Value / 100)); }
     417    private void widthTrackBar_ValueChanged(object sender, EventArgs e) {
     418      frameTableLayoutPanel.SuspendRepaint();
     419      for (int i = 0; i < columnHeaderTableLayoutPanel.ColumnCount; i++) {
     420        columnHeaderTableLayoutPanel.ColumnStyles[i].Width = GetColumnWidth();
     421        bodyTableLayoutPanel.ColumnStyles[i].Width = GetColumnWidth();
     422      }
     423      frameTableLayoutPanel.ResumeRepaint(true);
     424    }
     425    private void heightTrackBar_ValueChanged(object sender, EventArgs e) {
     426      frameTableLayoutPanel.SuspendRepaint();
     427
     428      for (int i = 0; i < rowHeaderTableLayoutPanel.RowCount; i++) {
     429        rowHeaderTableLayoutPanel.RowStyles[i].Height = GetRowHeight();
     430        bodyTableLayoutPanel.RowStyles[i].Height = GetRowHeight();
     431      }
     432      frameTableLayoutPanel.ResumeRepaint(true);
     433    }
     434    #endregion
    175435  }
    176 
    177 
    178436}
  • stable/HeuristicLab.DataPreprocessing/3.4

  • stable/HeuristicLab.DataPreprocessing/3.4/Content/PreprocessingChartContent.cs

    r14186 r14963  
    2323using System.Collections.Generic;
    2424using System.Drawing;
    25 using System.Linq;
    2625using HeuristicLab.Analysis;
    2726using HeuristicLab.Common;
     
    126125
    127126
    128     public ICheckedItemList<StringValue> CreateVariableItemList(IEnumerable<string> checkedItems = null) {
     127    public ICheckedItemList<StringValue> CreateVariableItemList(IList<string> checkedItems = null) {
     128      if (checkedItems == null) checkedItems = new string[0];
    129129      ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>();
    130130      foreach (string name in PreprocessingData.GetDoubleVariableNames()) {
    131131        var n = new StringValue(name);
    132         itemList.Add(n, (checkedItems == null) ? true : checkedItems.Contains(name));
     132        itemList.Add(n, checkedItems.Contains(name));
    133133      }
    134134      return new ReadOnlyCheckedItemList<StringValue>(itemList);
  • stable/HeuristicLab.DataPreprocessing/3.4/Data/FilteredPreprocessingData.cs

    r14186 r14963  
    4747      get { return ActiveData.VariableNames; }
    4848    }
     49
     50    public IList<string> InputVariables { get { return ActiveData.InputVariables; } }
     51    public string TargetVariable { get { return ActiveData.TargetVariable; } } // optional
    4952
    5053    public IDictionary<int, IList<int>> Selection {
  • stable/HeuristicLab.DataPreprocessing/3.4/Data/IPreprocessingData.cs

    r14186 r14963  
    6565    bool VariableHasType<T>(int columnIndex);
    6666
     67    IList<string> InputVariables { get; }
     68    string TargetVariable { get; } // optional
     69
    6770    int Columns { get; }
    6871    int Rows { get; }
  • stable/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs

    r14960 r14963  
    5959    }
    6060
     61    public IList<string> InputVariables { get; private set; }
     62    public string TargetVariable { get; private set; } // optional
     63
    6164    public int Columns {
    6265      get { return variableNames.Count; }
     
    8285      TrainingPartition = (IntRange)original.TrainingPartition.Clone(cloner);
    8386      TestPartition = (IntRange)original.TestPartition.Clone(cloner);
    84       transformations = new List<ITransformation>();
     87      transformations = new List<ITransformation>(original.transformations.Select(cloner.Clone));
     88
     89      InputVariables = new List<string>(original.InputVariables);
     90      TargetVariable = original.TargetVariable;
    8591
    8692      RegisterEventHandler();
     
    102108      Dataset dataset = (Dataset)problemData.Dataset;
    103109      variableNames = new List<string>(problemData.Dataset.VariableNames);
     110      InputVariables = new List<string>(problemData.AllowedInputVariables);
     111      TargetVariable = (problemData is IRegressionProblemData) ? ((IRegressionProblemData)problemData).TargetVariable
     112        : (problemData is IClassificationProblemData) ? ((IClassificationProblemData)problemData).TargetVariable
     113        : null;
    104114
    105115      int columnIndex = 0;
Note: See TracChangeset for help on using the changeset viewer.