Changeset 14381


Ignore:
Timestamp:
11/09/16 16:20:23 (4 years ago)
Author:
pfleck
Message:

#2698

  • Refactored CheckedVariablesView out of the ChartView to allow reuse of the checked variables list.
    • The new list visualizes the non-input/target variables in gray.
    • Added context menu to quickly (un)check all variables or only the inputs+target variables.
  • In the Multi-Scatterplot
    • New structure and layout of the single charts to support fixed header rows and columns (for the variable names). Instead, removed the legend of each plot for better usage of plot area.
    • Adapted the new CheckedVariablesView (but hidden until (un)checking is implemented).
Location:
trunk/sources
Files:
2 added
8 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj

    r14125 r14381  
    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">
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingCheckedVariablesView.Designer.cs

    r14380 r14381  
    2121
    2222namespace HeuristicLab.DataPreprocessing.Views {
    23   partial class PreprocessingChartView {
     23  partial class PreprocessingCheckedVariablesView {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
    48       this.dataTableView = new HeuristicLab.DataPreprocessing.Views.PreprocessingDataTableView();
     47      this.components = new System.ComponentModel.Container();
    4948      this.splitContainer = new System.Windows.Forms.SplitContainer();
    5049      this.checkedItemList = new HeuristicLab.DataPreprocessing.Views.PreprocessingCheckedItemListView();
    51       this.tableLayoutPanel.SuspendLayout();
     50      this.variablesListcontextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
     51      this.checkInputsTargetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     52      this.checkOnlyInputsTargetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     53      this.checkAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     54      this.uncheckAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5255      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    5356      this.splitContainer.Panel1.SuspendLayout();
    54       this.splitContainer.Panel2.SuspendLayout();
    5557      this.splitContainer.SuspendLayout();
     58      this.variablesListcontextMenuStrip.SuspendLayout();
    5659      this.SuspendLayout();
    57       //
    58       // tableLayoutPanel
    59       //
    60       this.tableLayoutPanel.ColumnCount = 1;
    61       this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
    62       this.tableLayoutPanel.Controls.Add(this.dataTableView, 0, 0);
    63       this.tableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
    64       this.tableLayoutPanel.Location = new System.Drawing.Point(0, 0);
    65       this.tableLayoutPanel.Name = "tableLayoutPanel";
    66       this.tableLayoutPanel.RowCount = 1;
    67       this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
    68       this.tableLayoutPanel.Size = new System.Drawing.Size(559, 403);
    69       this.tableLayoutPanel.TabIndex = 6;
    70       this.tableLayoutPanel.Layout += new System.Windows.Forms.LayoutEventHandler(this.tableLayoutPanel_Layout);
    71       //
    72       // dataTableView
    73       //
    74       this.dataTableView.AutoScroll = true;
    75       this.dataTableView.Caption = "DataTable View";
    76       this.dataTableView.Classification = null;
    77       this.dataTableView.Content = null;
    78       this.dataTableView.Dock = System.Windows.Forms.DockStyle.Fill;
    79       this.dataTableView.IsDetailedChartViewEnabled = false;
    80       this.dataTableView.Location = new System.Drawing.Point(3, 3);
    81       this.dataTableView.Name = "dataTableView";
    82       this.dataTableView.ReadOnly = false;
    83       this.dataTableView.Size = new System.Drawing.Size(553, 397);
    84       this.dataTableView.TabIndex = 0;
    8560      //
    8661      // splitContainer
     
    9368      //
    9469      this.splitContainer.Panel1.Controls.Add(this.checkedItemList);
    95       //
    96       // splitContainer.Panel2
    97       //
    98       this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel);
    9970      this.splitContainer.Size = new System.Drawing.Size(654, 403);
    10071      this.splitContainer.SplitterDistance = 91;
     
    10374      // checkedItemList
    10475      //
    105       this.checkedItemList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    106             | System.Windows.Forms.AnchorStyles.Left) 
     76      this.checkedItemList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     77            | System.Windows.Forms.AnchorStyles.Left)
    10778            | System.Windows.Forms.AnchorStyles.Right)));
    10879      this.checkedItemList.Caption = "View";
    10980      this.checkedItemList.Content = null;
     81      this.checkedItemList.ContextMenuStrip = this.variablesListcontextMenuStrip;
    11082      this.checkedItemList.Location = new System.Drawing.Point(4, 4);
    11183      this.checkedItemList.Name = "checkedItemList";
     
    11486      this.checkedItemList.TabIndex = 4;
    11587      //
    116       // PreprocessingChartView
     88      // variablesListcontextMenuStrip
     89      //
     90      this.variablesListcontextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
     91            this.checkInputsTargetToolStripMenuItem,
     92            this.checkOnlyInputsTargetToolStripMenuItem,
     93            this.checkAllToolStripMenuItem,
     94            this.uncheckAllToolStripMenuItem});
     95      this.variablesListcontextMenuStrip.Name = "variablesListcontextMenuStrip";
     96      this.variablesListcontextMenuStrip.Size = new System.Drawing.Size(211, 92);
     97      this.variablesListcontextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.variablesListcontextMenuStrip_Opening);
     98      //
     99      // checkInputsTargetToolStripMenuItem
     100      //
     101      this.checkInputsTargetToolStripMenuItem.Name = "checkInputsTargetToolStripMenuItem";
     102      this.checkInputsTargetToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
     103      this.checkInputsTargetToolStripMenuItem.Text = "Check Inputs+Target";
     104      this.checkInputsTargetToolStripMenuItem.Click += new System.EventHandler(this.checkInputsTargetToolStripMenuItem_Click);
     105      //
     106      // checkOnlyInputsTargetToolStripMenuItem
     107      //
     108      this.checkOnlyInputsTargetToolStripMenuItem.Name = "checkOnlyInputsTargetToolStripMenuItem";
     109      this.checkOnlyInputsTargetToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
     110      this.checkOnlyInputsTargetToolStripMenuItem.Text = "Check only Inputs+Target";
     111      this.checkOnlyInputsTargetToolStripMenuItem.Click += new System.EventHandler(this.checkOnlyInputsTargetToolStripMenuItem_Click);
     112      //
     113      // checkAllToolStripMenuItem
     114      //
     115      this.checkAllToolStripMenuItem.Name = "checkAllToolStripMenuItem";
     116      this.checkAllToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
     117      this.checkAllToolStripMenuItem.Text = "Check All";
     118      this.checkAllToolStripMenuItem.Click += new System.EventHandler(this.checkAllToolStripMenuItem_Click);
     119      //
     120      // uncheckAllToolStripMenuItem
     121      //
     122      this.uncheckAllToolStripMenuItem.Name = "uncheckAllToolStripMenuItem";
     123      this.uncheckAllToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
     124      this.uncheckAllToolStripMenuItem.Text = "Uncheck All";
     125      this.uncheckAllToolStripMenuItem.Click += new System.EventHandler(this.uncheckAllToolStripMenuItem_Click);
     126      //
     127      // PreprocessingCheckedVariablesView
    117128      //
    118129      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    119130      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    120131      this.Controls.Add(this.splitContainer);
    121       this.Name = "PreprocessingChartView";
     132      this.Name = "PreprocessingCheckedVariablesView";
    122133      this.Size = new System.Drawing.Size(654, 403);
    123       this.tableLayoutPanel.ResumeLayout(false);
    124134      this.splitContainer.Panel1.ResumeLayout(false);
    125       this.splitContainer.Panel2.ResumeLayout(false);
    126135      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    127136      this.splitContainer.ResumeLayout(false);
     137      this.variablesListcontextMenuStrip.ResumeLayout(false);
    128138      this.ResumeLayout(false);
    129139
     
    132142    #endregion
    133143
    134     private PreprocessingCheckedItemListView checkedItemList;
    135     private DataPreprocessing.Views.PreprocessingDataTableView dataTableView;
    136     private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
     144    protected PreprocessingCheckedItemListView checkedItemList;
    137145    protected System.Windows.Forms.SplitContainer splitContainer;
     146    private System.Windows.Forms.ContextMenuStrip variablesListcontextMenuStrip;
     147    private System.Windows.Forms.ToolStripMenuItem checkInputsTargetToolStripMenuItem;
     148    private System.Windows.Forms.ToolStripMenuItem checkAllToolStripMenuItem;
     149    private System.Windows.Forms.ToolStripMenuItem uncheckAllToolStripMenuItem;
     150    private System.Windows.Forms.ToolStripMenuItem checkOnlyInputsTargetToolStripMenuItem;
    138151  }
    139152}
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingCheckedVariablesView.cs

    r14380 r14381  
    2121
    2222using System;
    23 using System.Collections.Generic;
     23using System.Drawing;
    2424using System.Linq;
    2525using System.Windows.Forms;
    26 using HeuristicLab.Analysis;
    2726using HeuristicLab.Collections;
    2827using HeuristicLab.Core.Views;
     
    3130
    3231namespace HeuristicLab.DataPreprocessing.Views {
    33   [View("Preprocessing Chart View")]
     32  [View("Preprocessing Checked Variables View")]
    3433  [Content(typeof(PreprocessingChartContent), false)]
    35   public partial class PreprocessingChartView : ItemView {
    36 
    37     private PreprocessingDataTable dataTable;
    38     private List<PreprocessingDataTable> dataTablePerVariable;
    39     private List<DataRow> dataRows;
    40     private List<DataRow> selectedDataRows;
    41 
    42     protected DataRowVisualProperties.DataRowChartType chartType;
    43     protected string chartTitle;
    44 
    45     private const string DEFAULT_CHART_TITLE = "Chart";
    46     private const int FIXED_CHART_SIZE = 300;
    47     private const int MAX_TABLE_AUTO_SIZE_ROWS = 3;
    48 
    49     public IEnumerable<double> Classification { get; set; }
    50     public bool IsDetailedChartViewEnabled { get; set; }
    51 
    52     public PreprocessingChartView() {
    53       InitializeComponent();
    54       chartType = DataRowVisualProperties.DataRowChartType.Line;
    55       chartTitle = DEFAULT_CHART_TITLE;
    56     }
    57 
    58     //Variable selection changed
    59     //Add or remove data row
    60     private void CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> checkedItems) {
    61       tableLayoutPanel.SuspendLayout();
    62       foreach (IndexedItem<StringValue> item in checkedItems.Items) {
    63         string variableName = item.Value.Value;
    64 
    65         // not checked -> remove
    66         if (!VariableIsChecked(variableName)) {
    67           dataTableView.SetRowEnabled(variableName, false);
    68           dataTable.SelectedRows.Remove(variableName);
    69           dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName)));
    70         } else {
    71           DataRow row = GetDataRow(variableName);
    72           DataRow selectedRow = GetSelectedDataRow(variableName);
    73           dataTableView.SetRowEnabled(variableName, true);
    74 
    75           PreprocessingDataTable pdt = new PreprocessingDataTable(variableName);
    76           pdt.Rows.Add(row);
    77           // dataTablePerVariable does not contain unchecked variables => reduce insert position by number of unchecked variables to correct the index
    78           int uncheckedUntilVariable = checkedItemList.Content.TakeWhile(x => x.Value != variableName).Count(x => !checkedItemList.Content.ItemChecked(x));
    79           dataTablePerVariable.Insert(item.Index - uncheckedUntilVariable, pdt);
    80 
    81           //update selection
    82           if (selectedRow != null) {
    83             dataTable.SelectedRows.Add(selectedRow);
    84             pdt.SelectedRows.Add(selectedRow);
    85           }
    86         }
    87       }
    88 
    89       // update chart if not in all in one mode
    90       if (Content != null && !Content.AllInOneMode)
    91         GenerateChart();
    92       tableLayoutPanel.ResumeLayout(true);
    93     }
    94 
    95     private bool VariableIsChecked(string name) {
    96       return Content.VariableItemList.CheckedItems.Any(x => x.Value.Value == name);
    97     }
    98 
    99     protected override void RegisterContentEvents() {
    100       base.RegisterContentEvents();
    101       Content.PreprocessingData.Changed += PreprocessingData_Changed;
    102       Content.PreprocessingData.SelectionChanged += PreprocessingData_SelctionChanged;
    103 
    104     }
    105 
    106     protected override void DeregisterContentEvents() {
    107       base.DeregisterContentEvents();
    108       Content.PreprocessingData.Changed -= PreprocessingData_Changed;
    109       Content.PreprocessingData.SelectionChanged -= PreprocessingData_SelctionChanged;
    110     }
     34  public /*abstract*/ partial class PreprocessingCheckedVariablesView : ItemView {
    11135
    11236    public new PreprocessingChartContent Content {
     
    11539    }
    11640
    117     private void InitData() {
     41    protected PreprocessingCheckedVariablesView() {
     42      InitializeComponent();
     43    }
     44
     45    protected bool VariableIsChecked(string name) {
     46      return Content.VariableItemList.CheckedItems.Any(x => x.Value.Value == name);
     47    }
     48
     49
     50    protected override void OnContentChanged() {
     51      base.OnContentChanged();
     52      if (Content == null) return;
     53
    11854      if (Content.VariableItemList == null) {
    11955        Content.VariableItemList = Content.CreateVariableItemList();
     
    12258        Content.VariableItemList = Content.CreateVariableItemList(checkedNames);
    12359      }
     60      Content.VariableItemList.CheckedItemsChanged += CheckedItemsChanged;
     61
    12462      checkedItemList.Content = Content.VariableItemList;
    125 
    126       //Create data tables and data rows
    127       dataRows = Content.CreateAllDataRows(chartType);
    128       dataTable = new PreprocessingDataTable(chartTitle);
    129       dataTablePerVariable = new List<PreprocessingDataTable>();
    130 
    131       //add data rows to data tables according to checked item list
    132       foreach (var checkedItem in Content.VariableItemList.CheckedItems) {
    133         string variableName = Content.VariableItemList[checkedItem.Index].Value;
    134         PreprocessingDataTable d = new PreprocessingDataTable(variableName);
    135         DataRow row = GetDataRow(variableName);
    136 
    137         if (row != null) {
    138           //add row to data table
    139           dataTable.Rows.Add(row);
    140 
    141           //add row to data table per variable
    142           d.Rows.Add(row);
    143           dataTablePerVariable.Add(d);
    144         }
     63      var target = Content.PreprocessingData.TargetVariable;
     64      var inputAndTarget = Content.PreprocessingData.InputVariables.Union(target != null ? new[] { target } : new string[] { });
     65      foreach (var col in Content.PreprocessingData.GetDoubleVariableNames().Except(inputAndTarget)) {
     66        var listViewItem = checkedItemList.ItemsListView.FindItemWithText(col);
     67        listViewItem.ForeColor = Color.LightGray;
    14568      }
    146 
    147       UpdateSelection();
     69    }
     70    protected override void RegisterContentEvents() {
     71      base.RegisterContentEvents();
     72      Content.PreprocessingData.Changed += PreprocessingData_Changed;
     73      Content.PreprocessingData.SelectionChanged += PreprocessingData_SelctionChanged;
     74    }
     75    protected override void DeregisterContentEvents() {
     76      Content.PreprocessingData.Changed -= PreprocessingData_Changed;
     77      Content.PreprocessingData.SelectionChanged -= PreprocessingData_SelctionChanged;
     78      base.DeregisterContentEvents();
    14879    }
    14980
    150     private void UpdateSelection() {
    151 
    152       //update data table selection
    153       selectedDataRows = Content.CreateAllSelectedDataRows(chartType);
    154       dataTable.SelectedRows.Clear();
    155       foreach (var selectedRow in selectedDataRows) {
    156         if (VariableIsChecked(selectedRow.Name))
    157           dataTable.SelectedRows.Add(selectedRow);
    158       }
    159 
    160       //update data table per variable selection
    161       foreach (PreprocessingDataTable d in dataTablePerVariable) {
    162         d.SelectedRows.Clear();
    163         DataRow row = selectedDataRows.Find(x => x.Name == d.Name);
    164         if (row != null)
    165           d.SelectedRows.Add(row);
    166       }
    167 
     81    protected virtual void CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> checkedItems) {
    16882    }
    16983
    170     private DataRow GetSelectedDataRow(string variableName) {
    171       foreach (DataRow row in selectedDataRows) {
    172         if (row.Name == variableName)
    173           return row;
    174       }
    175       return null;
    176     }
    177 
    178     private DataRow GetDataRow(string variableName) {
    179       foreach (DataRow row in dataRows) {
    180         if (row.Name == variableName)
    181           return row;
    182       }
    183       return null;
    184     }
    185 
    186     protected override void OnContentChanged() {
    187       base.OnContentChanged();
    188       if (Content != null) {
    189         InitData();
    190         Content.VariableItemList.CheckedItemsChanged += CheckedItemsChanged;
    191         GenerateChart();
    192       }
    193     }
    194 
    195     // TODO : handle also other changed events
    196     void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) {
     84    private void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) {
    19785      switch (e.Type) {
    19886        case DataPreprocessingChangedEventType.DeleteColumn:
     
    20492        case DataPreprocessingChangedEventType.ChangeColumn:
    20593        case DataPreprocessingChangedEventType.ChangeItem:
    206           UpdateDataForVariable(Content.PreprocessingData.GetVariableName(e.Column));
     94          UpdateVariable(Content.PreprocessingData.GetVariableName(e.Column));
    20795          break;
    208         case DataPreprocessingChangedEventType.DeleteRow:
    209         case DataPreprocessingChangedEventType.AddRow:
    210         case DataPreprocessingChangedEventType.Any:
    21196        default:
    212           //TODO: test with transform
    213           InitData();
    214           GenerateChart();
     97          ResetAllVariables();
    21598          break;
    21699      }
    217100    }
    218101
    219     private void PreprocessingData_SelctionChanged(object sender, EventArgs e) {
    220       UpdateSelection();
     102    protected virtual void AddVariable(string name) {
     103      Content.VariableItemList.Add(new StringValue(name));
     104      if (!Content.PreprocessingData.InputVariables.Contains(name) && Content.PreprocessingData.TargetVariable != name) {
     105        var listViewItem = checkedItemList.ItemsListView.FindItemWithText(name);
     106        listViewItem.ForeColor = Color.LightGray;
     107      }
     108    }
     109    protected virtual void RemoveVariable(string name) {
     110      var stringValue = Content.VariableItemList.SingleOrDefault(n => n.Value == name);
     111      if (stringValue != null)
     112        Content.VariableItemList.Remove(stringValue);
     113    }
     114    protected virtual void UpdateVariable(string name) {
     115    }
     116    protected virtual void ResetAllVariables() {
    221117    }
    222118
    223     private void UpdateDataForVariable(string variableName) {
    224       DataRow newRow = Content.CreateDataRow(variableName, chartType);
    225       dataTable.Rows.Remove(variableName);
    226       dataTable.Rows.Add(newRow);
    227       DataTable dt = dataTablePerVariable.Find(x => x.Rows.Find(y => y.Name == variableName) != null);
    228       if (dt != null) {
    229         dt.Rows.Remove(variableName);
    230         dt.Rows.Add(newRow);
    231       }
     119    protected virtual void PreprocessingData_SelctionChanged(object sender, EventArgs e) {
    232120    }
    233121
    234     // add variable to data table and item list
    235     private void AddVariable(string name) {
    236       DataRow row = Content.CreateDataRow(name, chartType);
    237       dataTable.Rows.Add(row);
    238       PreprocessingDataTable d = new PreprocessingDataTable(name);
    239       d.Rows.Add(row);
    240       dataTablePerVariable.Add(d);
    241       Content.VariableItemList.Add(new StringValue(name));
    242       if (!Content.AllInOneMode)
    243         GenerateChart();
     122    #region ContextMenu Events
     123    private void variablesListcontextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e) {
     124      var data = Content.PreprocessingData;
     125      checkInputsTargetToolStripMenuItem.Text = "Check Inputs" + (data.TargetVariable != null ? "+Target" : "");
     126      checkOnlyInputsTargetToolStripMenuItem.Text = "Check only Inputs" + (data.TargetVariable != null ? "+Target" : "");
    244127    }
    245 
    246     // remove variable from data table and item list
    247     private void RemoveVariable(string name) {
    248       dataTable.Rows.Remove(name);
    249       dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == name)));
    250 
    251       StringValue stringValue = FindVariableItemList(name);
    252       if (stringValue != null)
    253         Content.VariableItemList.Remove(stringValue);
    254       if (!Content.AllInOneMode)
    255         GenerateChart();
    256     }
    257 
    258     private StringValue FindVariableItemList(string name) {
    259       foreach (StringValue stringValue in Content.VariableItemList) {
    260         if (stringValue.Value == name)
    261           return stringValue;
    262       }
    263       return null;
    264     }
    265 
    266     protected void GenerateChart() {
    267       ClearTableLayout();
    268       if (Content.AllInOneMode) {
    269         GenerateSingleChartLayout();
    270       } else
    271         GenerateMultiChartLayout();
    272     }
    273 
    274     private void ClearTableLayout() {
    275       //Clear out the existing controls
    276       tableLayoutPanel.Controls.Clear();
    277 
    278       //Clear out the existing row and column styles
    279       tableLayoutPanel.ColumnStyles.Clear();
    280       tableLayoutPanel.RowStyles.Clear();
    281       tableLayoutPanel.AutoScroll = false;
    282       tableLayoutPanel.AutoScroll = true;
    283     }
    284 
    285     private void GenerateSingleChartLayout() {
    286       tableLayoutPanel.ColumnCount = 1;
    287       tableLayoutPanel.RowCount = 1;
    288       tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
    289       tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
    290       tableLayoutPanel.Controls.Add(dataTableView, 0, 0);
    291       dataTableView.Content = dataTable;
    292     }
    293 
    294     private int GetNrOfMultiChartColumns(int itemCount) {
    295       int columns = 0;
    296       if (itemCount <= 2)
    297         columns = 1;
    298       else if (itemCount <= 6)
    299         columns = 2;
    300       else
    301         columns = 3;
    302       return columns;
    303     }
    304 
    305     private int GetNrOfMultiChartRows(int itemCount, int columns) {
    306       int rows = 0;
    307       if (columns == 3)
    308         rows = (itemCount + 2) / columns;
    309       else if (columns == 2)
    310         rows = (itemCount + 1) / columns;
    311       else
    312         rows = itemCount / columns;
    313       return rows;
    314     }
    315 
    316 
    317     private void GenerateMultiChartLayout() {
    318       int checkedItemsCnt = 0;
    319       foreach (var item in Content.VariableItemList.CheckedItems)
    320         checkedItemsCnt++;
    321 
    322       // set columns and rows based on number of items
    323       int columns = GetNrOfMultiChartColumns(checkedItemsCnt);
    324       int rows = GetNrOfMultiChartRows(checkedItemsCnt, columns);
    325 
    326       tableLayoutPanel.ColumnCount = columns;
    327       tableLayoutPanel.RowCount = rows;
    328 
    329       List<PreprocessingDataTable>.Enumerator enumerator = dataTablePerVariable.GetEnumerator();
    330       for (int x = 0; x < columns; x++) {
    331 
    332         if (rows <= MAX_TABLE_AUTO_SIZE_ROWS)
    333           tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns));
    334         else
    335           //scrollbar is shown if there are more than 3 rows -> remove scroll bar width from total width
    336           tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - System.Windows.Forms.SystemInformation.VerticalScrollBarWidth) / columns));
    337         for (int y = 0; y < rows; y++) {
    338           //Add a row only when creating the first column
    339           if (x == 0) {
    340             // fixed chart size when there are more than 3 tables
    341             if (rows > MAX_TABLE_AUTO_SIZE_ROWS)
    342               tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, FIXED_CHART_SIZE));
    343             else
    344               tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / rows));
    345           }
    346 
    347           enumerator.MoveNext();
    348           PreprocessingDataTable d = enumerator.Current;
    349           AddDataTableToTableLayout(d, x, y);
    350 
     128    private void checkInputsTargetToolStripMenuItem_Click(object sender, EventArgs e) {
     129      foreach (var name in checkedItemList.Content) {
     130        var isInputTarget = Content.PreprocessingData.InputVariables.Contains(name.Value) || Content.PreprocessingData.TargetVariable == name.Value;
     131        if (isInputTarget) {
     132          checkedItemList.Content.SetItemCheckedState(name, true);
    351133        }
    352134      }
    353135    }
    354 
    355     private void AddDataTableToTableLayout(PreprocessingDataTable dataTable, int x, int y) {
    356       PreprocessingDataTableView dataView = new PreprocessingDataTableView();
    357       dataView.Classification = Classification;
    358       dataView.IsDetailedChartViewEnabled = IsDetailedChartViewEnabled;
    359 
    360       if (dataTable == null) {
    361         // dummy panel for empty field
    362         Panel p = new Panel();
    363         p.Dock = DockStyle.Fill;
    364         tableLayoutPanel.Controls.Add(p, y, x);
    365       } else {
    366         dataView.Content = dataTable;
    367         dataView.Dock = DockStyle.Fill;
    368         tableLayoutPanel.Controls.Add(dataView, y, x);
     136    private void checkOnlyInputsTargetToolStripMenuItem_Click(object sender, EventArgs e) {
     137      foreach (var name in checkedItemList.Content) {
     138        var isInputTarget = Content.PreprocessingData.InputVariables.Contains(name.Value) || Content.PreprocessingData.TargetVariable == name.Value;
     139        checkedItemList.Content.SetItemCheckedState(name, isInputTarget);
    369140      }
    370141    }
    371 
    372     //Remove horizontal scroll bar if visible
    373     private void tableLayoutPanel_Layout(object sender, LayoutEventArgs e) {
    374       if (tableLayoutPanel.HorizontalScroll.Visible) {
    375         // Add padding on the right in order to accomodate the vertical scrollbar
    376         int vWidth = SystemInformation.VerticalScrollBarWidth;
    377         tableLayoutPanel.Padding = new Padding(0, 0, vWidth, 0);
    378       } else {
    379         // Reset padding
    380         tableLayoutPanel.Padding = new Padding(0);
     142    private void checkAllToolStripMenuItem_Click(object sender, EventArgs e) {
     143      foreach (var name in checkedItemList.Content) {
     144        checkedItemList.Content.SetItemCheckedState(name, true);
    381145      }
    382146    }
    383 
     147    private void uncheckAllToolStripMenuItem_Click(object sender, EventArgs e) {
     148      foreach (var name in checkedItemList.Content) {
     149        checkedItemList.Content.SetItemCheckedState(name, false);
     150      }
     151    }
     152    #endregion
    384153  }
    385154}
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingDataTableView.cs

    r14270 r14381  
    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
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingScatterPlotView.cs

    r14185 r14381  
    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
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.Designer.cs

    r14185 r14381  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     47      this.frameTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     48      this.columnHeaderTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     49      this.rowHeaderTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     50      this.bodyTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     51      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
     52      this.splitContainer.Panel1.SuspendLayout();
     53      this.splitContainer.Panel2.SuspendLayout();
     54      this.splitContainer.SuspendLayout();
     55      this.frameTableLayoutPanel.SuspendLayout();
    4856      this.SuspendLayout();
    4957      //
    50       // tableLayoutPanel
     58      // splitContainer
    5159      //
    52       this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    53             | System.Windows.Forms.AnchorStyles.Left)
    54             | 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;
    6660      //
    67       // MultiScatterPlotView
     61      // splitContainer.Panel2
     62      //
     63      this.splitContainer.Panel2.Controls.Add(this.frameTableLayoutPanel);
     64      //
     65      // frameTableLayoutPanel
     66      //
     67      this.frameTableLayoutPanel.ColumnCount = 2;
     68      this.frameTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 40F));
     69      this.frameTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
     70      this.frameTableLayoutPanel.Controls.Add(this.columnHeaderTableLayoutPanel, 1, 0);
     71      this.frameTableLayoutPanel.Controls.Add(this.rowHeaderTableLayoutPanel, 0, 1);
     72      this.frameTableLayoutPanel.Controls.Add(this.bodyTableLayoutPanel, 1, 1);
     73      this.frameTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
     74      this.frameTableLayoutPanel.Location = new System.Drawing.Point(0, 0);
     75      this.frameTableLayoutPanel.Name = "frameTableLayoutPanel";
     76      this.frameTableLayoutPanel.RowCount = 2;
     77      this.frameTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
     78      this.frameTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
     79      this.frameTableLayoutPanel.Size = new System.Drawing.Size(739, 517);
     80      this.frameTableLayoutPanel.TabIndex = 0;
     81      //
     82      // columnHeaderTableLayoutPanel
     83      //
     84      this.columnHeaderTableLayoutPanel.ColumnCount = 2;
     85      this.columnHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     86      this.columnHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     87      this.columnHeaderTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
     88      this.columnHeaderTableLayoutPanel.Location = new System.Drawing.Point(43, 3);
     89      this.columnHeaderTableLayoutPanel.Name = "columnHeaderTableLayoutPanel";
     90      this.columnHeaderTableLayoutPanel.RowCount = 1;
     91      this.columnHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     92      this.columnHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     93      this.columnHeaderTableLayoutPanel.Size = new System.Drawing.Size(693, 34);
     94      this.columnHeaderTableLayoutPanel.TabIndex = 1;
     95      //
     96      // rowHeaderTableLayoutPanel
     97      //
     98      this.rowHeaderTableLayoutPanel.ColumnCount = 1;
     99      this.rowHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     100      this.rowHeaderTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     101      this.rowHeaderTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
     102      this.rowHeaderTableLayoutPanel.Location = new System.Drawing.Point(3, 43);
     103      this.rowHeaderTableLayoutPanel.Name = "rowHeaderTableLayoutPanel";
     104      this.rowHeaderTableLayoutPanel.RowCount = 2;
     105      this.rowHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     106      this.rowHeaderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     107      this.rowHeaderTableLayoutPanel.Size = new System.Drawing.Size(34, 471);
     108      this.rowHeaderTableLayoutPanel.TabIndex = 2;
     109      //
     110      // bodyTableLayoutPanel
     111      //
     112      this.bodyTableLayoutPanel.ColumnCount = 2;
     113      this.bodyTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     114      this.bodyTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
     115      this.bodyTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
     116      this.bodyTableLayoutPanel.Location = new System.Drawing.Point(43, 43);
     117      this.bodyTableLayoutPanel.Name = "bodyTableLayoutPanel";
     118      this.bodyTableLayoutPanel.RowCount = 2;
     119      this.bodyTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     120      this.bodyTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
     121      this.bodyTableLayoutPanel.Size = new System.Drawing.Size(693, 471);
     122      this.bodyTableLayoutPanel.TabIndex = 0;
     123      this.bodyTableLayoutPanel.Scroll += new System.Windows.Forms.ScrollEventHandler(this.bodyTableLayoutPanel_Scroll);
     124      //
     125      // ScatterPlotMultiView
    68126      //
    69127      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    70128      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    71       this.Controls.Add(this.tableLayoutPanel);
    72       this.Name = "MultiScatterPlotView";
     129      this.Name = "ScatterPlotMultiView";
    73130      this.Size = new System.Drawing.Size(863, 517);
     131      this.splitContainer.Panel1.ResumeLayout(false);
     132      this.splitContainer.Panel2.ResumeLayout(false);
     133      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
     134      this.splitContainer.ResumeLayout(false);
     135      this.frameTableLayoutPanel.ResumeLayout(false);
    74136      this.ResumeLayout(false);
    75137
     
    78140    #endregion
    79141
    80     private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
    81 
     142    private System.Windows.Forms.TableLayoutPanel frameTableLayoutPanel;
     143    private System.Windows.Forms.TableLayoutPanel columnHeaderTableLayoutPanel;
     144    private System.Windows.Forms.TableLayoutPanel rowHeaderTableLayoutPanel;
     145    private System.Windows.Forms.TableLayoutPanel bodyTableLayoutPanel;
    82146  }
    83147}
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs

    r13502 r14381  
    55using System.Windows.Forms;
    66using HeuristicLab.Analysis;
     7using HeuristicLab.Collections;
    78using HeuristicLab.Common;
    8 using HeuristicLab.Core.Views;
     9using HeuristicLab.Data;
    910using HeuristicLab.MainForm;
     11using HeuristicLab.MainForm.WindowsForms;
    1012
    1113namespace HeuristicLab.DataPreprocessing.Views {
    1214  [View("Scatter Plot Multi View")]
    1315  [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;
     16  public partial class ScatterPlotMultiView : PreprocessingCheckedVariablesView {
    1817    private const int MAX_AUTO_SIZE_ELEMENTS = 6;
    1918    private const int FIXED_CHART_WIDTH = 250;
     
    2221    public ScatterPlotMultiView() {
    2322      InitializeComponent();
     23
     24      columnHeaderTableLayoutPanel.HorizontalScroll.Enabled = true;
     25      columnHeaderTableLayoutPanel.VerticalScroll.Enabled = false;
     26      columnHeaderTableLayoutPanel.HorizontalScroll.Visible = false;
     27      columnHeaderTableLayoutPanel.VerticalScroll.Visible = false;
     28
     29      rowHeaderTableLayoutPanel.HorizontalScroll.Enabled = false;
     30      rowHeaderTableLayoutPanel.VerticalScroll.Enabled = true;
     31      rowHeaderTableLayoutPanel.HorizontalScroll.Visible = false;
     32      rowHeaderTableLayoutPanel.VerticalScroll.Visible = false;
     33
     34      bodyTableLayoutPanel.HorizontalScroll.Enabled = true;
     35      bodyTableLayoutPanel.VerticalScroll.Enabled = true;
     36      bodyTableLayoutPanel.HorizontalScroll.Visible = true;
     37      bodyTableLayoutPanel.VerticalScroll.Visible = true;
     38      bodyTableLayoutPanel.AutoScroll = true;
     39
     40      bodyTableLayoutPanel.MouseWheel += bodyTableLayoutPanel_MouseWheel;
     41
     42      splitContainer.Panel1Collapsed = true; // ToDo: remove after correctly handling unchecks
    2443    }
    2544
     
    3251      base.OnContentChanged();
    3352      if (Content != null) {
    34         GenerateMultiLayout();
    35       }
    36     }
    37 
    38     //Add header elements to the table layout panel
    39     private void addHeaderToTableLayoutPanels() {
    40 
     53        GenerateCharts();
     54      }
     55    }
     56
     57    protected override void CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<StringValue>> checkedItems) {
     58      base.CheckedItemsChanged(sender, checkedItems);
     59
     60    }
     61
     62    #region Add/Remove/Update Variable, Reset
     63    protected override void AddVariable(string name) {
     64      base.AddVariable(name);
     65    }
     66    protected override void RemoveVariable(string name) {
     67      base.RemoveVariable(name);
     68
     69    }
     70    protected override void UpdateVariable(string name) {
     71      base.UpdateVariable(name);
     72
     73    }
     74    protected override void ResetAllVariables() {
     75      GenerateCharts();
     76    }
     77    #endregion
     78
     79    #region Generate Charts
     80    private void GenerateCharts() {
    4181      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() {
     82      var contentTableLayoutPanels = new[] { columnHeaderTableLayoutPanel, rowHeaderTableLayoutPanel, bodyTableLayoutPanel };
     83
     84      // Clear table layouts
     85      foreach (var tlp in contentTableLayoutPanels) {
     86        tlp.Controls.Clear();
     87        //Clear out the existing row and column styles
     88        tlp.ColumnStyles.Clear();
     89        tlp.RowStyles.Clear();
     90      }
     91
     92      // Set row and column count
     93      columnHeaderTableLayoutPanel.ColumnCount = variables.Count + 1;
     94      rowHeaderTableLayoutPanel.RowCount = variables.Count + 1;
     95      bodyTableLayoutPanel.ColumnCount = variables.Count;
     96      bodyTableLayoutPanel.RowCount = variables.Count;
     97
     98      // Set column and row layout
     99      int width = variables.Count <= MAX_AUTO_SIZE_ELEMENTS ? bodyTableLayoutPanel.Width / variables.Count : FIXED_CHART_WIDTH;
     100      int height = variables.Count <= MAX_AUTO_SIZE_ELEMENTS ? bodyTableLayoutPanel.Height / variables.Count : FIXED_CHART_HEIGHT;
     101      for (int i = 0; i < variables.Count; i++) {
     102        columnHeaderTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, width));
     103        rowHeaderTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, height));
     104        bodyTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, width));
     105        bodyTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, height));
     106      }
     107
     108      //frameTableLayoutPanel.SuspendLayout();
     109      AddHeaderToTableLayoutPanels();
     110      AddChartsToTableLayoutPanel();
     111      //frameTableLayoutPanel.ResumeLayout(true);
     112    }
     113
     114    private void AddHeaderToTableLayoutPanels() {
    61115      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
     116      int width = variables.Count <= MAX_AUTO_SIZE_ELEMENTS ? bodyTableLayoutPanel.Width / variables.Count : FIXED_CHART_WIDTH;
     117      int height = variables.Count <= MAX_AUTO_SIZE_ELEMENTS ? bodyTableLayoutPanel.Height / variables.Count : FIXED_CHART_HEIGHT;
     118      for (int i = 0; i < variables.Count; i++) {
     119        columnHeaderTableLayoutPanel.Controls.Add(new Label() {
     120          Text = variables[i],
     121          TextAlign = ContentAlignment.MiddleCenter,
     122          Width = width,
     123          Height = columnHeaderTableLayoutPanel.Height,
     124          Dock = DockStyle.Fill,
     125          Margin = new Padding(3)
     126        }, i, 0);
     127        rowHeaderTableLayoutPanel.Controls.Add(new Label() {
     128          Text = variables[i],
     129          TextAlign = ContentAlignment.MiddleCenter,
     130          Width = rowHeaderTableLayoutPanel.Width,
     131          Height = height,
     132          Dock = DockStyle.Fill,
     133          Margin = new Padding(3)
     134        }, 0, i);
     135      }
     136
     137      // Add empty labels with fixed size to correct scollbar width/height in headers
     138      columnHeaderTableLayoutPanel.Controls.Add(new Panel() {
     139        Width = bodyTableLayoutPanel.VerticalScroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0,
     140        Height = columnHeaderTableLayoutPanel.Height,
     141        Dock = DockStyle.Fill,
     142        //BackColor = Color.DarkRed
     143      }, variables.Count, 0);
     144      rowHeaderTableLayoutPanel.Controls.Add(new Panel() {
     145        Width = rowHeaderTableLayoutPanel.Width,
     146        Height = bodyTableLayoutPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0,
     147        Dock = DockStyle.Fill,
     148        //BackColor = Color.DarkRed
     149      }, 0, variables.Count);
     150    }
     151    private void AddChartsToTableLayoutPanel() {
     152      List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList();
     153
     154      //set scatter plots and histograms
    75155      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) {
     156        for (int y = 0; y < variables.Count; y++) {
     157          if (x == y) { // use historgram if x and y variable are equal
    103158            PreprocessingDataTable dataTable = new PreprocessingDataTable();
    104             DataRow dataRow = Content.CreateDataRow(variables[x - 1], DataRowVisualProperties.DataRowChartType.Histogram);
     159            DataRow dataRow = Content.CreateDataRow(variables[x], DataRowVisualProperties.DataRowChartType.Histogram);
    105160            dataTable.Rows.Add(dataRow);
    106             PreprocessingDataTableView pcv = new PreprocessingDataTableView();
     161            PreprocessingDataTableView pcv = new PreprocessingDataTableView {
     162              Content = dataTable,
     163              Dock = DockStyle.Fill,
     164              ShowLegend = false,
     165              XAxisFormat = "G3"
     166            };
    107167            pcv.ChartDoubleClick += HistogramDoubleClick;
    108             pcv.Content = dataTable;
    109             tableLayoutPanel.Controls.Add(pcv, y, x);
    110           }
    111           //scatter plot
    112           else {
    113             ScatterPlot scatterPlot = Content.CreateScatterPlot(variables[x - 1], variables[y - 1]);
    114             PreprocessingScatterPlotView pspv = new PreprocessingScatterPlotView();
     168            bodyTableLayoutPanel.Controls.Add(pcv, y, x);
     169          } else { //scatter plot
     170            ScatterPlot scatterPlot = Content.CreateScatterPlot(variables[x], variables[y]);
     171            PreprocessingScatterPlotView pspv = new PreprocessingScatterPlotView {
     172              Content = scatterPlot,
     173              Dock = DockStyle.Fill,
     174              ShowLegend = false,
     175              XAxisFormat = "G3"
     176            };
    115177            pspv.ChartDoubleClick += ScatterPlotDoubleClick;
    116             pspv.Content = scatterPlot;
    117             pspv.Dock = DockStyle.Fill;
    118             tableLayoutPanel.Controls.Add(pspv, x, y);
     178            bodyTableLayoutPanel.Controls.Add(pspv, x, y);
    119179          }
    120180        }
     
    122182    }
    123183
     184    #endregion
     185
     186    #region DoubleClick Events
    124187    //Open scatter plot in new tab with new content when double clicked
    125188    private void ScatterPlotDoubleClick(object sender, EventArgs e) {
     
    127190      ScatterPlotContent scatterContent = new ScatterPlotContent(Content, new Cloner());  // create new content
    128191      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
     192
     193      //Extract variable names from scatter plot and set them in content
    138194      if (scatterPlot.Rows.Count == 1) {
    139195        string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[] { " - " }, StringSplitOptions.None); // extract variable names from string
     
    141197        scatterContent.SelectedYVariable = variables[1];
    142198      }
    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       }
     199
     200      MainFormManager.MainForm.ShowContent(scatterContent, typeof(ScatterPlotSingleView));  // open in new tab
    161201    }
    162202
     
    167207      histoContent.VariableItemList = Content.CreateVariableItemList();
    168208      PreprocessingDataTable dataTable = pcv.Content;
    169       setVariableItemListFromDataTable(histoContent, dataTable);
    170 
     209
     210      //Set variable item list from with variable from data table
     211      if (dataTable.Rows.Count == 1) { // only one data row should be in data table
     212        string variableName = dataTable.Rows.ElementAt(0).Name;
     213
     214        // set only variable name checked
     215        foreach (var checkedItem in histoContent.VariableItemList) {
     216          histoContent.VariableItemList.SetItemCheckedState(checkedItem, checkedItem.Value == variableName);
     217        }
     218      }
    171219      MainFormManager.MainForm.ShowContent(histoContent, typeof(HistogramView));  // open in new tab
    172220    }
    173 
    174 
     221    #endregion
     222
     223    private void bodyTableLayoutPanel_Scroll(object sender, ScrollEventArgs e) {
     224      SyncScroll();
     225
     226      // update "padding labels" after scrollbars are added or removed
     227      var columHeaderPadding = columnHeaderTableLayoutPanel.Controls[columnHeaderTableLayoutPanel.Controls.Count - 1];
     228      var rowHeaderPadding = rowHeaderTableLayoutPanel.Controls[rowHeaderTableLayoutPanel.ColumnCount - 1];
     229      columHeaderPadding.Width = bodyTableLayoutPanel.VerticalScroll.Visible ? SystemInformation.VerticalScrollBarWidth : 0;
     230      rowHeaderPadding.Height = bodyTableLayoutPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0;
     231    }
     232    private void bodyTableLayoutPanel_MouseWheel(object sender, MouseEventArgs e) {
     233      // Scrolling with the mouse wheel is not captured in the Scoll event
     234      SyncScroll();
     235    }
     236    private void SyncScroll() {
     237      //Debug.WriteLine("H: {0} <- {1}", columnHeaderTableLayoutPanel.HorizontalScroll.Value, bodyTableLayoutPanel.HorizontalScroll.Value);
     238      //Debug.WriteLine("V: {0} <- {1}", rowHeaderTableLayoutPanel.VerticalScroll.Value, bodyTableLayoutPanel.VerticalScroll.Value);
     239
     240      frameTableLayoutPanel.SuspendRepaint();
     241
     242      columnHeaderTableLayoutPanel.HorizontalScroll.Minimum = bodyTableLayoutPanel.HorizontalScroll.Minimum;
     243      columnHeaderTableLayoutPanel.HorizontalScroll.Maximum = bodyTableLayoutPanel.HorizontalScroll.Maximum;
     244      rowHeaderTableLayoutPanel.VerticalScroll.Minimum = bodyTableLayoutPanel.VerticalScroll.Minimum;
     245      rowHeaderTableLayoutPanel.VerticalScroll.Maximum = bodyTableLayoutPanel.VerticalScroll.Maximum;
     246
     247      columnHeaderTableLayoutPanel.HorizontalScroll.Value = Math.Max(bodyTableLayoutPanel.HorizontalScroll.Value, 1);
     248      rowHeaderTableLayoutPanel.VerticalScroll.Value = Math.Max(bodyTableLayoutPanel.VerticalScroll.Value, 1);
     249      // minimum 1 is nececary  because of two factors:
     250      // - setting the Value-property of Horizontal/VerticalScroll updates the internal state but the Value-property stays 0
     251      // - setting the same number of the Value-property has no effect
     252      // since the Value-property is always 0, setting it to 0 would have no effect; so it is set to 1 instead
     253
     254      frameTableLayoutPanel.ResumeRepaint(true);
     255    }
    175256  }
    176 
    177 
    178257}
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Data/FilteredPreprocessingData.cs

    r14185 r14381  
    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 {
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Data/IPreprocessingData.cs

    r14185 r14381  
    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; }
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Data/PreprocessingData.cs

    r14185 r14381  
    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.