Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/14 14:24:40 (11 years ago)
Author:
aesterer
Message:

Refactored LineChartLogic and added CheckedItemListView to LineChartView

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/LineChartLogic.cs

    r10586 r10628  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Analysis;
     25using HeuristicLab.Core;
     26using HeuristicLab.Data;
    2527
    2628namespace HeuristicLab.DataPreprocessing {
    2729  public class LineChartLogic : ILineChartLogic {
     30 
    2831    private ITransactionalPreprocessingData preprocessingData;
    29     private DataTable dataTable;
    3032
    3133    public LineChartLogic(ITransactionalPreprocessingData preprocessingData) {
    3234      this.preprocessingData = preprocessingData;
    33       dataTable = new DataTable("LineChart");
    34       FillDataTable();
    35       preprocessingData.Changed += PreprocessingData_Changed;
    3635    }
    3736
    38     private void FillDataTable() {
    39       IEnumerable<string> variableNames = preprocessingData.VariableNames;
     37    public DataTable CreateDataTable(String title) {
     38      DataTable dataTable = new DataTable(title);
     39      IEnumerable<string> variableNames = GetVariableNames();
    4040
    4141      foreach (string variableName in variableNames) {
    42         IList<double> values = preprocessingData.GetValues<double>(variableName);
    43         DataRow row = new DataRow(variableName, "", values);
     42        DataRow row = CreateDataRow(variableName);
    4443        dataTable.Rows.Add(row);
    4544      }
    46 
     45      return dataTable;
    4746    }
    4847
    49     public IEnumerable<object> GetVariableNames() {
     48    public DataRow CreateDataRow(string variableName) {
     49      IList<double> values = preprocessingData.GetValues<double>(variableName);
     50      DataRow row = new DataRow(variableName, "", values);
     51      return row;
     52    }
     53
     54    private IEnumerable<string> GetVariableNames() {
    5055      List<string> doubleVariableNames = new List<string>();
    5156
     
    5964    }
    6065
    61     public DataTable GetDataTable() {
    62       return dataTable;
    63     }
    64 
    65     public void RemoveVariable(string name) {
    66       dataTable.Rows.Remove(name);
    67     }
    68 
    69     public void AddVariable(string name) {
    70       IList<double> values = preprocessingData.GetValues<double>(name);
    71       DataRow row = new DataRow(name, "", values);
    72       dataTable.Rows.Add(row);
    73     }
    74 
    75     public bool VariableIsDisplayed(string name) {
    76 
    77       foreach (var item in dataTable.Rows) {
    78         if (item.Name == name)
    79           return true;
     66    public ICheckedItemList<StringValue> CreateVariableItemList() {
     67      ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>();
     68      foreach (string name in GetVariableNames()) {
     69        itemList.Add(new StringValue(name), true);
    8070      }
    81       return false;
    82     }
    83 
    84     //TODO: refactor: possible code duplication with HistogramLogic
    85     void PreprocessingData_Changed(object sender, DataPreprocessingChangedEventArgs e) {
    86       switch (e.Type) {
    87         case DataPreprocessingChangedEventType.DeleteColumn:
    88           dataTable.Rows.Remove(preprocessingData.GetVariableName(e.Column));
    89           break;
    90         case DataPreprocessingChangedEventType.AddColumn:
    91           dataTable.Rows.Add(new DataRow(preprocessingData.GetVariableName(e.Column), String.Empty, preprocessingData.GetValues<double>(e.Column)));
    92           break;
    93         case DataPreprocessingChangedEventType.ChangeColumn:
    94         case DataPreprocessingChangedEventType.ChangeItem:
    95           dataTable.Rows.Remove(preprocessingData.GetVariableName(e.Column));
    96           dataTable.Rows.Add(new DataRow(preprocessingData.GetVariableName(e.Column), String.Empty, preprocessingData.GetValues<double>(e.Column)));
    97           break;
    98         case DataPreprocessingChangedEventType.DeleteRow:
    99         case DataPreprocessingChangedEventType.AddRow:
    100           dataTable.Rows.Clear();
    101           FillDataTable();
    102           break;
    103       }
     71      return new ReadOnlyCheckedItemList<StringValue>(itemList);
    10472    }
    10573
     
    10876      remove { preprocessingData.Changed -= value; }
    10977    }
     78
     79    public string GetVariableNameByIndex(int index) {
     80      return preprocessingData.GetVariableName(index);
     81    }
     82
    11083  }
    11184}
Note: See TracChangeset for help on using the changeset viewer.