Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10552


Ignore:
Timestamp:
03/05/14 17:27:27 (11 years ago)
Author:
aesterer
Message:

Revised line chart and added histogram

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
Files:
9 edited

Legend:

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

    r10550 r10552  
    247247    </ProjectReference>
    248248  </ItemGroup>
    249   <ItemGroup>
    250     <EmbeddedResource Include="Views\DataPreprocessingView.resx">
    251       <DependentUpon>DataPreprocessingView.cs</DependentUpon>
    252     </EmbeddedResource>
    253   </ItemGroup>
    254249  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    255250  <PropertyGroup>
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/HistogramLogic.cs

    r10539 r10552  
    2121
    2222
     23using System;
     24using System.Collections.Generic;
     25using HeuristicLab.Analysis;
     26
    2327namespace HeuristicLab.DataPreprocessing {
    2428  public class HistogramLogic : IHistogramLogic {
     29        private IPreprocessingData preprocessingData;
     30    private DataTable dataTable;
     31
     32    public HistogramLogic(IPreprocessingData preprocessingData) {
     33      this.preprocessingData = preprocessingData;
     34      dataTable = new DataTable("Histogram");
     35      FillDataTable();
     36      preprocessingData.Changed += PreprocessingData_Changed;
     37    }
     38
     39    private void FillDataTable() {
     40      IEnumerable<string> variableNames = preprocessingData.VariableNames;
     41
     42      foreach (string variableName in variableNames) {
     43        IList<double> values = preprocessingData.GetValues<double>(variableName);
     44        DataRow row = new DataRow(variableName, "", values);
     45        row.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
     46        dataTable.Rows.Add(row);
     47      }
     48
     49    }
     50
     51    public IEnumerable<object> GetVariableNames() {
     52      List<string> doubleVariableNames = new List<string>();
     53
     54      //only return variable names from type double
     55      foreach (string variableName in preprocessingData.VariableNames) {
     56        if (preprocessingData.IsType<double>(preprocessingData.GetColumnIndex(variableName)))
     57          doubleVariableNames.Add(variableName);
     58      }
     59
     60      return doubleVariableNames;
     61    }
     62
     63    public DataTable GetDataTable() {
     64      return dataTable;
     65    }
     66
     67    public void RemoveVariable(string name) {
     68      dataTable.Rows.Remove(name);
     69    }
     70
     71    public void AddVariable(string name) {
     72      IList<double> values = preprocessingData.GetValues<double>(name);
     73      DataRow row = new DataRow(name, "", values);
     74      row.VisualProperties.ChartType = DataRowVisualProperties.DataRowChartType.Histogram;
     75      dataTable.Rows.Add(row);
     76    }
     77
     78    public bool VariableIsDisplayed(string name) {
     79
     80      foreach (var item in dataTable.Rows) {
     81        if (item.Name == name)
     82          return true;
     83      }
     84      return false;
     85    }
     86
     87    void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) {
     88      var variableName = preprocessingData.GetVariableName(e.Column);
     89      switch (e.Type) {
     90        case DataPreprocessingChangedEventType.DeleteColumn:
     91          dataTable.Rows.Remove(variableName);
     92          break;
     93        case DataPreprocessingChangedEventType.AddColumn:
     94          dataTable.Rows.Add(new DataRow(variableName, String.Empty, preprocessingData.GetValues<double>(e.Column)));
     95          break;
     96        case DataPreprocessingChangedEventType.ChangeColumn:
     97        case DataPreprocessingChangedEventType.ChangeItem:
     98          dataTable.Rows.Remove(variableName);
     99          dataTable.Rows.Add(new DataRow(variableName, String.Empty, preprocessingData.GetValues<double>(e.Column)));
     100          break;
     101        case DataPreprocessingChangedEventType.DeleteRow:
     102        case DataPreprocessingChangedEventType.AddRow:
     103          dataTable.Rows.Clear();
     104          FillDataTable();
     105          break;
     106      }
     107    }
    25108  }
    26109}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/LineChartLogic.cs

    r10544 r10552  
    4848
    4949    public IEnumerable<object> GetVariableNames() {
    50       return preprocessingData.VariableNames;
     50      List<string> doubleVariableNames = new List<string>();
     51
     52      //only return variable names from type double
     53      foreach (string variableName in preprocessingData.VariableNames) {
     54        if (preprocessingData.IsType<double>(preprocessingData.GetColumnIndex(variableName)))
     55          doubleVariableNames.Add(variableName);
     56      }
     57
     58      return doubleVariableNames;
    5159    }
    5260
     
    5462      return dataTable;
    5563    }
    56 
    57 
    58     #region ILineChartLogic Members
    5964
    6065    public void RemoveVariable(string name) {
     
    6772      dataTable.Rows.Add(row);
    6873    }
    69 
    70     #endregion
    7174
    7275    public bool VariableIsDisplayed(string name) {
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IHistogramLogic.cs

    r10539 r10552  
    2121
    2222
     23using System.Collections.Generic;
     24using HeuristicLab.Analysis;
     25
    2326namespace HeuristicLab.DataPreprocessing {
    2427  public interface IHistogramLogic {
     28    void RemoveVariable(string name);
     29
     30    void AddVariable(string name);
     31
     32    IEnumerable<object> GetVariableNames();
     33
     34    DataTable GetDataTable();
     35
     36    bool VariableIsDisplayed(string name);
    2537  }
    2638}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/DataPreprocessingView.cs

    r10550 r10552  
    7373      tranformationContent = new TransformationContent(new TransformationLogic(data, searchLogic, statisticsLogic));
    7474      lineChartContent = new LineChartContent(new LineChartLogic(data));
    75       histogramContent = new HistogramContent(new HistogramLogic());
     75      histogramContent = new HistogramContent(new HistogramLogic(data));
    7676
    7777      //create view items
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/HistogramView.Designer.cs

    r10303 r10552  
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       components = new System.ComponentModel.Container();
     26      this.groupBoxAttributs = new System.Windows.Forms.GroupBox();
     27      this.variablesListBox = new System.Windows.Forms.CheckedListBox();
     28      this.groupBoxOptions = new System.Windows.Forms.GroupBox();
     29      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     30      this.groupBoxAttributs.SuspendLayout();
     31      this.SuspendLayout();
     32      //
     33      // groupBoxAttributs
     34      //
     35      this.groupBoxAttributs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     36            | System.Windows.Forms.AnchorStyles.Left)));
     37      this.groupBoxAttributs.Controls.Add(this.variablesListBox);
     38      this.groupBoxAttributs.Location = new System.Drawing.Point(3, 4);
     39      this.groupBoxAttributs.Name = "groupBoxAttributs";
     40      this.groupBoxAttributs.Size = new System.Drawing.Size(153, 252);
     41      this.groupBoxAttributs.TabIndex = 3;
     42      this.groupBoxAttributs.TabStop = false;
     43      this.groupBoxAttributs.Text = "Attributes";
     44      //
     45      // variablesListBox
     46      //
     47      this.variablesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     48            | System.Windows.Forms.AnchorStyles.Left)
     49            | System.Windows.Forms.AnchorStyles.Right)));
     50      this.variablesListBox.FormattingEnabled = true;
     51      this.variablesListBox.Location = new System.Drawing.Point(6, 19);
     52      this.variablesListBox.Name = "variablesListBox";
     53      this.variablesListBox.Size = new System.Drawing.Size(141, 229);
     54      this.variablesListBox.TabIndex = 1;
     55      this.variablesListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.variablesListBox_ItemCheck);
     56      //
     57      // groupBoxOptions
     58      //
     59      this.groupBoxOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     60      this.groupBoxOptions.Location = new System.Drawing.Point(4, 262);
     61      this.groupBoxOptions.Name = "groupBoxOptions";
     62      this.groupBoxOptions.Size = new System.Drawing.Size(152, 138);
     63      this.groupBoxOptions.TabIndex = 4;
     64      this.groupBoxOptions.TabStop = false;
     65      this.groupBoxOptions.Text = "Options";
     66      //
     67      // viewHost
     68      //
     69      this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     70            | System.Windows.Forms.AnchorStyles.Left)
     71            | System.Windows.Forms.AnchorStyles.Right)));
     72      this.viewHost.Caption = "View";
     73      this.viewHost.Content = null;
     74      this.viewHost.Enabled = false;
     75      this.viewHost.Location = new System.Drawing.Point(163, 4);
     76      this.viewHost.Name = "viewHost";
     77      this.viewHost.ReadOnly = false;
     78      this.viewHost.Size = new System.Drawing.Size(524, 396);
     79      this.viewHost.TabIndex = 5;
     80      this.viewHost.ViewsLabelVisible = true;
     81      this.viewHost.ViewType = null;
     82      //
     83      // HistogramView
     84      //
     85      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    2786      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     87      this.Controls.Add(this.viewHost);
     88      this.Controls.Add(this.groupBoxOptions);
     89      this.Controls.Add(this.groupBoxAttributs);
     90      this.Name = "HistogramView";
     91      this.Size = new System.Drawing.Size(690, 403);
     92      this.groupBoxAttributs.ResumeLayout(false);
     93      this.ResumeLayout(false);
     94
    2895    }
    2996
    3097    #endregion
     98
     99    private System.Windows.Forms.GroupBox groupBoxAttributs;
     100    private System.Windows.Forms.CheckedListBox variablesListBox;
     101    private System.Windows.Forms.GroupBox groupBoxOptions;
     102    private MainForm.WindowsForms.ViewHost viewHost;
    31103  }
    32104}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/HistogramView.cs

    r10303 r10552  
    2929    protected override void OnContentChanged() {
    3030      base.OnContentChanged();
     31      if (Content != null) {
     32        InitDataTable();
     33        InitVariablesListBox();
     34      }
     35    }
     36
     37    private void InitVariablesListBox() {
     38      IHistogramLogic logic = Content.HistogramLogic;
     39
     40      foreach (var variableName in logic.GetVariableNames()) {
     41        variablesListBox.Items.Add(variableName, true);
     42      }
     43    }
     44
     45    private void InitDataTable() {
     46      IHistogramLogic logic = Content.HistogramLogic;
     47      viewHost.Content = logic.GetDataTable();
     48    }
     49
     50    private void variablesListBox_ItemCheck(object sender, ItemCheckEventArgs e) {
     51      string item = variablesListBox.Items[e.Index] as string;
     52
     53      if (e.NewValue == CheckState.Checked && !Content.HistogramLogic.VariableIsDisplayed(item))
     54        Content.HistogramLogic.AddVariable(item);
     55      else if (e.NewValue == CheckState.Unchecked && Content.HistogramLogic.VariableIsDisplayed(item))
     56        Content.HistogramLogic.RemoveVariable(item);
    3157    }
    3258  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/LineChartView.Designer.cs

    r10539 r10552  
    4747      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4848      this.variablesListBox = new System.Windows.Forms.CheckedListBox();
     49      this.groupBoxAttributs = new System.Windows.Forms.GroupBox();
     50      this.groupBoxOptions = new System.Windows.Forms.GroupBox();
     51      this.groupBoxAttributs.SuspendLayout();
    4952      this.SuspendLayout();
    5053      //
    5154      // viewHost
    5255      //
    53       this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    54             | System.Windows.Forms.AnchorStyles.Left)
     56      this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     57            | System.Windows.Forms.AnchorStyles.Left) 
    5558            | System.Windows.Forms.AnchorStyles.Right)));
    5659      this.viewHost.Caption = "View";
    5760      this.viewHost.Content = null;
    5861      this.viewHost.Enabled = false;
    59       this.viewHost.Location = new System.Drawing.Point(155, 4);
     62      this.viewHost.Location = new System.Drawing.Point(162, 4);
    6063      this.viewHost.Name = "viewHost";
    6164      this.viewHost.ReadOnly = false;
    62       this.viewHost.Size = new System.Drawing.Size(922, 559);
     65      this.viewHost.Size = new System.Drawing.Size(489, 396);
    6366      this.viewHost.TabIndex = 0;
    6467      this.viewHost.ViewsLabelVisible = true;
     
    6770      // variablesListBox
    6871      //
    69       this.variablesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    70             | System.Windows.Forms.AnchorStyles.Left)));
     72      this.variablesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     73            | System.Windows.Forms.AnchorStyles.Left)
     74            | System.Windows.Forms.AnchorStyles.Right)));
    7175      this.variablesListBox.FormattingEnabled = true;
    72       this.variablesListBox.Location = new System.Drawing.Point(3, 4);
     76      this.variablesListBox.Location = new System.Drawing.Point(6, 19);
    7377      this.variablesListBox.Name = "variablesListBox";
    74       this.variablesListBox.Size = new System.Drawing.Size(146, 559);
     78      this.variablesListBox.Size = new System.Drawing.Size(141, 229);
    7579      this.variablesListBox.TabIndex = 1;
    7680      this.variablesListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.variablesListBox_ItemCheck);
     81      //
     82      // groupBoxAttributs
     83      //
     84      this.groupBoxAttributs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     85            | System.Windows.Forms.AnchorStyles.Left)));
     86      this.groupBoxAttributs.Controls.Add(this.variablesListBox);
     87      this.groupBoxAttributs.Location = new System.Drawing.Point(3, 4);
     88      this.groupBoxAttributs.Name = "groupBoxAttributs";
     89      this.groupBoxAttributs.Size = new System.Drawing.Size(153, 252);
     90      this.groupBoxAttributs.TabIndex = 2;
     91      this.groupBoxAttributs.TabStop = false;
     92      this.groupBoxAttributs.Text = "Attributes";
     93      //
     94      // groupBoxOptions
     95      //
     96      this.groupBoxOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     97      this.groupBoxOptions.Location = new System.Drawing.Point(4, 262);
     98      this.groupBoxOptions.Name = "groupBoxOptions";
     99      this.groupBoxOptions.Size = new System.Drawing.Size(152, 138);
     100      this.groupBoxOptions.TabIndex = 3;
     101      this.groupBoxOptions.TabStop = false;
     102      this.groupBoxOptions.Text = "Options";
    77103      //
    78104      // LineChartView
     
    80106      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    81107      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    82       this.Controls.Add(this.variablesListBox);
     108      this.Controls.Add(this.groupBoxOptions);
     109      this.Controls.Add(this.groupBoxAttributs);
    83110      this.Controls.Add(this.viewHost);
    84111      this.Name = "LineChartView";
    85       this.Size = new System.Drawing.Size(1080, 582);
     112      this.Size = new System.Drawing.Size(654, 403);
     113      this.groupBoxAttributs.ResumeLayout(false);
    86114      this.ResumeLayout(false);
    87115
     
    92120    private MainForm.WindowsForms.ViewHost viewHost;
    93121    private System.Windows.Forms.CheckedListBox variablesListBox;
     122    private System.Windows.Forms.GroupBox groupBoxAttributs;
     123    private System.Windows.Forms.GroupBox groupBoxOptions;
    94124  }
    95125}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/PreprocessingDataTableView.cs

    r10546 r10552  
    2828      InitializeComponent();
    2929
    30       this.Controls.Remove(nameLabel);
    31       this.Controls.Remove(nameTextBox);
    32       this.Controls.Remove(infoLabel);
    3330    }
    3431
Note: See TracChangeset for help on using the changeset viewer.