Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10717 for branches


Ignore:
Timestamp:
04/02/14 16:01:01 (11 years ago)
Author:
aesterer
Message:

Added chart per variable feature to preprocessing chart view

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3
Files:
5 edited

Legend:

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

    r10709 r10717  
    4343      <HintPath>..\..\bin\HeuristicLab.Collections-3.3.dll</HintPath>
    4444    </Reference>
     45    <Reference Include="HeuristicLab.Problems.ExternalEvaluation-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     46      <SpecificVersion>False</SpecificVersion>
     47      <HintPath>..\..\bin\HeuristicLab.Problems.ExternalEvaluation-3.3.dll</HintPath>
     48    </Reference>
    4549    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    4650      <SpecificVersion>False</SpecificVersion>
     
    229233      <Project>{DF87C13E-A889-46FF-8153-66DCAA8C5674}</Project>
    230234      <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name>
     235    </ProjectReference>
     236    <ProjectReference Include="..\..\HeuristicLab.Problems.ExternalEvaluation.Views\3.3\HeuristicLab.Problems.ExternalEvaluation.Views-3.3.csproj">
     237      <Project>{3081630C-9521-47D7-8075-1777C12F212C}</Project>
     238      <Name>HeuristicLab.Problems.ExternalEvaluation.Views-3.3</Name>
    231239    </ProjectReference>
    232240    <ProjectReference Include="..\..\HeuristicLab.Visualization.ChartControlsExtensions\3.3\HeuristicLab.Visualization.ChartControlsExtensions-3.3.csproj">
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/LineChartView.Designer.cs

    r10658 r10717  
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       components = new System.ComponentModel.Container();
     26      this.groupBox1 = new System.Windows.Forms.GroupBox();
     27      this.checkBox1 = new System.Windows.Forms.CheckBox();
     28      this.groupBox1.SuspendLayout();
     29      this.SuspendLayout();
     30      //
     31      // groupBox1
     32      //
     33      this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     34      this.groupBox1.Controls.Add(this.checkBox1);
     35      this.groupBox1.Location = new System.Drawing.Point(4, 262);
     36      this.groupBox1.Name = "groupBox1";
     37      this.groupBox1.Size = new System.Drawing.Size(151, 134);
     38      this.groupBox1.TabIndex = 7;
     39      this.groupBox1.TabStop = false;
     40      this.groupBox1.Text = "Options";
     41      //
     42      // checkBox1
     43      //
     44      this.checkBox1.AutoSize = true;
     45      this.checkBox1.Location = new System.Drawing.Point(7, 20);
     46      this.checkBox1.Name = "checkBox1";
     47      this.checkBox1.Size = new System.Drawing.Size(66, 17);
     48      this.checkBox1.TabIndex = 0;
     49      this.checkBox1.Text = "AllInOne";
     50      this.checkBox1.UseVisualStyleBackColor = true;
     51      this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
     52      //
     53      // LineChartView
     54      //
     55      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    2756      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     57      this.Controls.Add(this.groupBox1);
     58      this.Name = "LineChartView";
     59      this.Controls.SetChildIndex(this.groupBox1, 0);
     60      this.groupBox1.ResumeLayout(false);
     61      this.groupBox1.PerformLayout();
     62      this.ResumeLayout(false);
     63
    2864    }
    2965
    3066    #endregion
     67
     68    private System.Windows.Forms.GroupBox groupBox1;
     69    private System.Windows.Forms.CheckBox checkBox1;
    3170  }
    3271}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/LineChartView.cs

    r10712 r10717  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
    2324using HeuristicLab.Analysis;
     
    4243      set { base.Content = value; }
    4344    }
     45
     46    private void checkBox1_CheckedChanged(object sender, EventArgs e) {
     47      if (allInOneMode == false)
     48        allInOneMode = true;
     49      else
     50        allInOneMode = false;
     51      GenerateChart();
     52    }
    4453  }
    4554}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingChartView.Designer.cs

    r10658 r10717  
    4646    /// </summary>
    4747    private void InitializeComponent() {
     48      this.dataTableView = new HeuristicLab.Analysis.Views.DataTableView();
     49      this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
    4850      this.checkedItemList = new HeuristicLab.DataPreprocessing.Views.PreprocessingCheckedItemListView();
    49       this.chartPanel = new System.Windows.Forms.Panel();
    50       this.dataTableView = new HeuristicLab.Analysis.Views.DataTableView();
    51       this.chartPanel.SuspendLayout();
     51      this.tableLayoutPanel.SuspendLayout();
    5252      this.SuspendLayout();
     53      //
     54      // dataTableView
     55      //
     56      this.dataTableView.Caption = "DataTable View";
     57      this.dataTableView.Content = null;
     58      this.dataTableView.Dock = System.Windows.Forms.DockStyle.Fill;
     59      this.dataTableView.Location = new System.Drawing.Point(3, 3);
     60      this.dataTableView.Name = "dataTableView";
     61      this.dataTableView.ReadOnly = false;
     62      this.dataTableView.Size = new System.Drawing.Size(486, 390);
     63      this.dataTableView.TabIndex = 0;
     64      //
     65      // tableLayoutPanel
     66      //
     67      this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     68            | System.Windows.Forms.AnchorStyles.Left)
     69            | System.Windows.Forms.AnchorStyles.Right)));
     70      this.tableLayoutPanel.AutoScroll = true;
     71      this.tableLayoutPanel.ColumnCount = 1;
     72      this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
     73      this.tableLayoutPanel.Controls.Add(this.dataTableView, 0, 0);
     74      this.tableLayoutPanel.Location = new System.Drawing.Point(162, 4);
     75      this.tableLayoutPanel.Name = "tableLayoutPanel";
     76      this.tableLayoutPanel.RowCount = 1;
     77      this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
     78      this.tableLayoutPanel.Size = new System.Drawing.Size(492, 396);
     79      this.tableLayoutPanel.TabIndex = 6;
     80      this.tableLayoutPanel.Layout += new System.Windows.Forms.LayoutEventHandler(this.tableLayoutPanel_Layout);
    5381      //
    5482      // checkedItemList
     
    6492      this.checkedItemList.TabIndex = 4;
    6593      //
    66       // chartPanel
    67       //
    68       this.chartPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    69             | System.Windows.Forms.AnchorStyles.Left)
    70             | System.Windows.Forms.AnchorStyles.Right)));
    71       this.chartPanel.Controls.Add(this.dataTableView);
    72       this.chartPanel.Location = new System.Drawing.Point(163, 4);
    73       this.chartPanel.Name = "chartPanel";
    74       this.chartPanel.Size = new System.Drawing.Size(488, 396);
    75       this.chartPanel.TabIndex = 5;
    76       //
    77       // dataTableView
    78       //
    79       this.dataTableView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    80             | System.Windows.Forms.AnchorStyles.Left)
    81             | System.Windows.Forms.AnchorStyles.Right)));
    82       this.dataTableView.Caption = "DataTable View";
    83       this.dataTableView.Content = null;
    84       this.dataTableView.Location = new System.Drawing.Point(3, 3);
    85       this.dataTableView.Name = "dataTableView";
    86       this.dataTableView.ReadOnly = false;
    87       this.dataTableView.Size = new System.Drawing.Size(482, 390);
    88       this.dataTableView.TabIndex = 0;
    89       //
    90       // LineChartView
     94      // PreprocessingChartView
    9195      //
    9296      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    9397      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    94       this.Controls.Add(this.chartPanel);
     98      this.Controls.Add(this.tableLayoutPanel);
    9599      this.Controls.Add(this.checkedItemList);
    96       this.Name = "LineChartView";
     100      this.Name = "PreprocessingChartView";
    97101      this.Size = new System.Drawing.Size(654, 403);
    98       this.chartPanel.ResumeLayout(false);
     102      this.tableLayoutPanel.ResumeLayout(false);
    99103      this.ResumeLayout(false);
    100104
     
    104108
    105109    private PreprocessingCheckedItemListView checkedItemList;
    106     private System.Windows.Forms.Panel chartPanel;
    107110    private Analysis.Views.DataTableView dataTableView;
     111    private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
    108112  }
    109113}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingChartView.cs

    r10712 r10717  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.Drawing;
    2225using System.Windows.Forms;
    2326using HeuristicLab.Analysis;
     27using HeuristicLab.Analysis.Views;
    2428using HeuristicLab.Collections;
    2529using HeuristicLab.Core;
     
    3640    private IChartLogic logic;
    3741    private DataTable dataTable;
     42    private List<DataTable> dataTablePerVariable;
    3843    private ICheckedItemList<StringValue> variableItemList;
     44    private List<DataRow> dataRows;
     45
    3946    protected DataRowVisualProperties.DataRowChartType chartType;
    4047    protected string chartTitle;
     48    protected bool allInOneMode = true;
    4149
    4250    private const string DEFAULT_CHART_TITLE = "Chart";
     
    5462        if (VariableIsDisplayed(variableName)) {
    5563          dataTable.Rows.Remove(variableName);
     64          dataTablePerVariable.Remove(dataTablePerVariable.Find( x => (x.Name == variableName)));
    5665        } else {
    57           dataTable.Rows.Add(logic.CreateDataRow(variableName, chartType));
     66          DataRow row = GetDataRow(variableName);
     67          //row.VisualProperties.Color = GetRandomColor();
     68          dataTable.Rows.Add(row);
     69          DataTable d = new DataTable(variableName);
     70          d.Rows.Add(row);
     71          dataTablePerVariable.Add(d);
    5872        }
    5973      }
    60     }
    61 
    62     public bool VariableIsDisplayed(string name) {
     74
     75      if (!allInOneMode)
     76        GenerateChart();
     77
     78    }
     79
     80    private Color GetRandomColor() {
     81      Random randomGen = new Random();
     82      KnownColor[] names = (KnownColor[])Enum.GetValues(typeof(KnownColor));
     83      KnownColor randomColorName = names[randomGen.Next(names.Length)];
     84      Color randomColor = Color.FromKnownColor(randomColorName);
     85      return randomColor;
     86    }
     87
     88    private bool VariableIsDisplayed(string name) {
    6389
    6490      foreach (var item in dataTable.Rows) {
     
    6995    }
    7096
    71     private void InitDataTable() {
    72       dataTable = logic.CreateDataTable(chartTitle, chartType);
    73       dataTableView.Content = dataTable;
    74     }
    75 
    76     private void InitVariablesListBox() {
    77       variableItemList = logic.CreateVariableItemList();
    78       checkedItemList.Content = variableItemList;
    79     }
    80 
    8197    protected override void RegisterContentEvents() {
    8298      base.RegisterContentEvents();
     
    96112      get { return (PreprocessingChartContent)base.Content; }
    97113      set { base.Content = value; }
     114    }
     115
     116    private void InitData() {
     117      variableItemList = logic.CreateVariableItemList();
     118      dataRows = logic.CreateAllDataRows(chartType);
     119
     120      // init data table
     121      dataTable = new DataTable(chartTitle);
     122      dataTable.Rows.AddRange(dataRows);
     123
     124      // init data table per variable
     125      dataTablePerVariable = new List<DataTable>();
     126      foreach(var checkedItem in variableItemList.CheckedItems)  {
     127        string variableName = variableItemList[checkedItem.Index].Value;
     128        DataTable d = new DataTable(variableName);
     129        DataRow row = GetDataRow(variableName);
     130        //row.VisualProperties.Color = GetRandomColor();
     131        d.Rows.Add(row);
     132        dataTablePerVariable.Add(d);
     133      }
     134
     135    }
     136
     137    private DataRow GetDataRow(string variableName) {
     138      foreach (DataRow row in dataRows) {
     139        if (row.Name == variableName)
     140          return row;
     141      }
     142      return null;
    98143    }
    99144
     
    102147      if (Content != null) {
    103148        logic = Content.ChartLogic;
    104         InitDataTable();
    105         InitVariablesListBox();
     149        InitData();
     150        checkedItemList.Content = variableItemList;
     151        GenerateChart();
    106152        variableItemList.CheckedItemsChanged += CheckedItemsChanged;
    107153        logic.Changed += PreprocessingData_Changed;
     
    109155    }
    110156
    111     //TODO: refactor: possible code duplication with HistogramLogic
     157    // TODO : handle also other changed events
    112158    void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) {
    113159      switch (e.Type) {
    114160        case DataPreprocessingChangedEventType.DeleteColumn:
    115           RemoveVariable(logic.GetVariableNameByIndex(e.Column));
     161          //RemoveVariable(logic.GetVariableNameByIndex(e.Column));
    116162          break;
    117163        case DataPreprocessingChangedEventType.AddColumn:
    118           AddVariable(logic.GetVariableNameByIndex(e.Column));
     164          //AddVariable(logic.GetVariableNameByIndex(e.Column));
    119165          break;
    120166        case DataPreprocessingChangedEventType.ChangeColumn:
    121167        case DataPreprocessingChangedEventType.ChangeItem:
    122           dataTable.Rows.Remove(logic.GetVariableNameByIndex(e.Column));
    123           dataTable.Rows.Add(logic.CreateDataRow(logic.GetVariableNameByIndex(e.Column), chartType));
     168          //UpdateDataForVariable(logic.GetVariableNameByIndex(e.Column));
     169
    124170          break;
    125171        case DataPreprocessingChangedEventType.DeleteRow:
    126172        case DataPreprocessingChangedEventType.AddRow:
    127           InitDataTable();
    128173          break;
    129174      }
     175    }
     176
     177    private void UpdateDataForVariable(string variableName) {
     178      DataRow newRow = logic.CreateDataRow(variableName, chartType);
     179      dataTable.Rows.Remove(variableName);
     180      dataTable.Rows.Add(newRow);
     181      DataTable dt = dataTablePerVariable.Find(x => (x.Rows.ItemName == variableName));
     182      dt.Rows.Remove(variableName);
     183      dt.Rows.Add(newRow);
    130184    }
    131185
     
    154208    }
    155209
     210    protected void GenerateChart() {
     211
     212      //Clear out the existing controls
     213      tableLayoutPanel.Controls.Clear();
     214
     215      //Clear out the existing row and column styles
     216      tableLayoutPanel.ColumnStyles.Clear();
     217      tableLayoutPanel.RowStyles.Clear();
     218      tableLayoutPanel.AutoScroll = false;
     219      tableLayoutPanel.AutoScroll = true;   
     220
     221      if (allInOneMode) {
     222        GenerateSingleChartLayout();
     223      } else
     224        GenerateMultiChartLayout();
     225    }
     226
     227    private void GenerateSingleChartLayout() {
     228      tableLayoutPanel.ColumnCount = 1;
     229      tableLayoutPanel.RowCount = 1;
     230      tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
     231      tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
     232      tableLayoutPanel.Controls.Add(dataTableView, 0, 0);
     233      dataTableView.Content = dataTable;
     234    }
     235
     236    private void GenerateMultiChartLayout() {
     237      int checkedItemsCnt = 0;
     238      foreach(var item in variableItemList.CheckedItems)
     239        checkedItemsCnt++;
     240
     241      int rows = 0;
     242      int columns = 0;
     243
     244      // set columns and rows based on number of items
     245      if (checkedItemsCnt <= 2)
     246        columns = 1;
     247      else if (checkedItemsCnt <= 6)
     248        columns = 2;
     249      else
     250        columns = 3;
     251
     252      if (columns == 3)
     253        rows = (checkedItemsCnt+2) / columns;
     254      else if(columns == 2)
     255        rows = (checkedItemsCnt + 1) / columns;
     256      else
     257        rows = checkedItemsCnt / columns;
     258
     259      //Now we will generate the table, setting up the row and column counts first
     260      tableLayoutPanel.ColumnCount = columns;
     261      tableLayoutPanel.RowCount = rows;
     262
     263      List<DataTable>.Enumerator enumerator = dataTablePerVariable.GetEnumerator();
     264      for (int x = 0; x < columns; x++) {
     265       
     266        if(rows <= 3)
     267          tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns));
     268        else
     269          //scrollbar is shown if there are more than 3 rows -> remove scroll bar width from total width
     270          tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - System.Windows.Forms.SystemInformation.VerticalScrollBarWidth) / columns));
     271        for (int y = 0; y < rows; y++) {
     272          //Add a row only when creating the first column
     273          if (x == 0) {
     274            // fixed chart size when there are more than 3 tables
     275            if (rows > 3)
     276              tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 300));
     277            else
     278              tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100 / rows));
     279          }
     280
     281          DataTableView dataView = new DataTableView();
     282          enumerator.MoveNext();
     283          DataTable d = enumerator.Current;
     284          if (d == null) {
     285            // dummy panel for empty field
     286            Panel p = new Panel();
     287            p.Dock = DockStyle.Fill;
     288            tableLayoutPanel.Controls.Add(p, y, x);
     289          }
     290          else {
     291            dataView.Content = d;
     292            dataView.Dock = DockStyle.Fill;
     293            tableLayoutPanel.Controls.Add(dataView, y, x);
     294          }
     295        }
     296      }
     297    }
     298
     299    //Remove horizontal scroll bar if visible
     300    private void tableLayoutPanel_Layout(object sender, LayoutEventArgs e) {
     301      if (tableLayoutPanel.HorizontalScroll.Visible) {
     302        // Add padding on the right in order to accomodate the vertical scrollbar
     303        int vWidth = SystemInformation.VerticalScrollBarWidth;
     304        tableLayoutPanel.Padding = new Padding(0, 0, vWidth, 0);
     305      } else {
     306        // Reset padding
     307        tableLayoutPanel.Padding = new Padding(0);
     308      }
     309    }
     310
     311    private void radioButton1_CheckedChanged(object sender, EventArgs e) {
     312      if (allInOneMode == false)
     313        allInOneMode = true;
     314      else
     315        allInOneMode = false;
     316      GenerateChart();
     317    }
     318
     319
     320
    156321  }
    157322}
Note: See TracChangeset for help on using the changeset viewer.