Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/11/14 15:06:24 (10 years ago)
Author:
rstoll
Message:
  • removed ChartLogic and

moved logic accordingly to PreprocessingChartContent, ScatterPlotContent
modified views etc. to use IFilteredPreprocessingData instead of ChartLogic

  • reordered code
Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4
Files:
2 deleted
8 edited

Legend:

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

    r10962 r10992  
    9494    <Compile Include="Implementations\HistogramContent.cs" />
    9595    <Compile Include="Implementations\LineChartContent.cs" />
    96     <Compile Include="Implementations\ChartLogic.cs" />
    9796    <Compile Include="Implementations\StatisticsContent.cs" />
    9897    <Compile Include="Implementations\TransformationContent.cs" />
    9998    <Compile Include="Interfaces\IFilterLogic.cs" />
    100     <Compile Include="Interfaces\IChartLogic.cs" />
    10199    <Compile Include="Interfaces\IManipulationLogic.cs" />
    102100    <Compile Include="Interfaces\ITransformationLogic.cs" />
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilteredPreprocessingData.cs

    r10978 r10992  
    1313    private ITransactionalPreprocessingData filteredData;
    1414
    15      public IDictionary<int, IList<int>> Selection {
     15    public IDictionary<int, IList<int>> Selection {
    1616      get { return originalData.Selection; }
    1717      set { originalData.Selection = value; }
     
    228228
    229229    #endregion
     230
     231    #region IPreprocessingData Members
     232
     233
     234    public IEnumerable<string> GetDoubleVariableNames() {
     235      return originalData.GetDoubleVariableNames();
     236    }
     237
     238    #endregion
    230239  }
    231240}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/HistogramContent.cs

    r10914 r10992  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Drawing;
     24using System.Linq;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Core;
     27using HeuristicLab.DataPreprocessing.Interfaces;
    2528
    2629namespace HeuristicLab.DataPreprocessing {
     
    2831  public class HistogramContent : PreprocessingChartContent {
    2932
     33    public static new Image StaticItemImage {
     34      get { return HeuristicLab.Common.Resources.VSImageLibrary.Statistics; }
     35    }
     36    private const int MAX_DISTINCT_VALUES_FOR_CLASSIFCATION = 20;
     37
    3038    private int classifierVariableIndex = 0;
    31 
    32     public HistogramContent(IChartLogic chartlogic)
    33       : base(chartlogic) {
    34       AllInOneMode = false;
    35     }
    36 
    37     public HistogramContent(HistogramContent content, Cloner cloner)
    38       : base(content, cloner) {
    39     }
    4039
    4140    public int ClassifierVariableIndex {
     
    4544
    4645
    47     public static new Image StaticItemImage {
    48       get { return HeuristicLab.Common.Resources.VSImageLibrary.Statistics; }
     46    public HistogramContent(IFilteredPreprocessingData preprocessingData)
     47      : base(preprocessingData) {
     48      AllInOneMode = false;
    4949    }
    5050
     51    public HistogramContent(HistogramContent content, Cloner cloner)
     52      : base(content, cloner) {
     53    }
    5154    public override IDeepCloneable Clone(Cloner cloner) {
    5255      return new HistogramContent(this, cloner);
    5356    }
     57
     58    public IEnumerable<string> GetVariableNamesForHistogramClassification() {
     59      List<string> doubleVariableNames = new List<string>();
     60
     61      //only return variable names from type double
     62      for (int i = 0; i < PreprocessingData.Columns; ++i) {
     63        if (PreprocessingData.IsType<double>(i)) {
     64          double distinctValueCount = PreprocessingData.GetValues<double>(i).GroupBy(x => x).Count();
     65          bool distinctValuesOk = distinctValueCount <= MAX_DISTINCT_VALUES_FOR_CLASSIFCATION;
     66          if (distinctValuesOk)
     67            doubleVariableNames.Add(PreprocessingData.GetVariableName(i));
     68        }
     69      }
     70      return doubleVariableNames;
     71    }
     72
    5473  }
    5574}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/LineChartContent.cs

    r10771 r10992  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.DataPreprocessing.Interfaces;
    2526
    2627namespace HeuristicLab.DataPreprocessing {
     
    2930  public class LineChartContent : PreprocessingChartContent {
    3031
    31     public LineChartContent(IChartLogic chartlogic)
    32       : base(chartlogic) {
     32    public static new Image StaticItemImage {
     33      get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }
     34    }
     35
     36    public LineChartContent(IFilteredPreprocessingData preprocessingData)
     37      : base(preprocessingData) {
    3338    }
    3439
    3540    public LineChartContent(LineChartContent content, Cloner cloner)
    3641      : base(content, cloner) {
    37 
    3842    }
    39 
    40     public static new Image StaticItemImage {
    41       get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }
    42     }
    43 
    4443    public override IDeepCloneable Clone(Cloner cloner) {
    4544      return new LineChartContent(this, cloner);
    4645    }
    47 
    4846  }
    4947}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingChartContent.cs

    r10967 r10992  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
    2224using System.Drawing;
     25using HeuristicLab.Analysis;
    2326using HeuristicLab.Common;
    2427using HeuristicLab.Core;
    2528using HeuristicLab.Data;
    26 using System;
    27 using System.Collections.Generic;
     29using HeuristicLab.DataPreprocessing.Interfaces;
    2830
    2931namespace HeuristicLab.DataPreprocessing {
    3032  [Item("PreprocessingChart", "Represents a preprocessing chart.")]
    3133  public class PreprocessingChartContent : Item, IViewChartShortcut {
     34    public static new Image StaticItemImage {
     35      get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; }
     36    }
    3237
    3338    private bool allInOneMode = true;
     39    public bool AllInOneMode {
     40      get { return this.allInOneMode; }
     41      set { this.allInOneMode = value; }
     42    }
    3443
    3544    private ICheckedItemList<StringValue> variableItemList = null;
     45    public ICheckedItemList<StringValue> VariableItemList {
     46      get { return this.variableItemList; }
     47      set { this.variableItemList = value; }
     48    }
    3649
     50    public IFilteredPreprocessingData PreprocessingData { get; private set; }
    3751
    38     private readonly IChartLogic chartLogic;
    39 
    40 
    41     public PreprocessingChartContent(IChartLogic chartLogic) {
    42       this.chartLogic = chartLogic;
     52    public PreprocessingChartContent(IFilteredPreprocessingData preprocessingData) {
     53      PreprocessingData = preprocessingData;
    4354    }
    4455
    4556    public PreprocessingChartContent(PreprocessingChartContent content, Cloner cloner)
    4657      : base(content, cloner) {
    47         this.allInOneMode = content.allInOneMode;
    48         this.chartLogic = content.chartLogic;
    49         this.variableItemList = cloner.Clone<ICheckedItemList<StringValue>>(variableItemList);
     58      this.allInOneMode = content.allInOneMode;
     59      this.PreprocessingData = cloner.Clone<IFilteredPreprocessingData>(PreprocessingData);
     60      this.variableItemList = cloner.Clone<ICheckedItemList<StringValue>>(variableItemList);
    5061    }
    51 
    52     public IChartLogic ChartLogic {
    53       get {
    54         return chartLogic;
    55       }
    56     }
    57 
    58     public static new Image StaticItemImage {
    59       get { return HeuristicLab.Common.Resources.VSImageLibrary.PieChart; }
    60     }
    61 
    6262    public override IDeepCloneable Clone(Cloner cloner) {
    6363      return new PreprocessingChartContent(this, cloner);
    6464    }
    6565
    66     public event DataPreprocessingChangedEventHandler Changed {
    67       add { chartLogic.Changed += value; }
    68       remove { chartLogic.Changed -= value; }
     66
     67    public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
     68      IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName));
     69      DataRow row = new DataRow(variableName, "", values);
     70      row.VisualProperties.ChartType = chartType;
     71      return row;
    6972    }
    7073
    71     public bool AllInOneMode
    72     {
    73       get { return this.allInOneMode; }
    74       set { this.allInOneMode = value; }
     74    public List<DataRow> CreateAllDataRows(DataRowVisualProperties.DataRowChartType chartType) {
     75      List<DataRow> dataRows = new List<DataRow>();
     76      foreach (var name in PreprocessingData.GetDoubleVariableNames())
     77        dataRows.Add(CreateDataRow(name, chartType));
     78      return dataRows;
    7579    }
    7680
    77     public ICheckedItemList<StringValue> VariableItemList
    78     {
    79       get { return this.variableItemList; }
    80       set { this.variableItemList = value; }
     81    public DataRow CreateSelectedDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
     82
     83      IDictionary<int, IList<int>> selection = PreprocessingData.Selection;
     84      int variableIndex = PreprocessingData.GetColumnIndex(variableName);
     85
     86      if (selection.Keys.Contains(variableIndex)) {
     87        List<int> selectedIndices = new List<int>(selection[variableIndex]);
     88        //need selection with more than 1 value
     89        if (selectedIndices.Count < 2)
     90          return null;
     91
     92        selectedIndices.Sort();
     93        int start = selectedIndices[0];
     94        int end = selectedIndices[selectedIndices.Count - 1];
     95
     96        DataRow rowSelect = CreateDataRowRange(variableName, start, end, chartType);
     97        return rowSelect;
     98      } else
     99        return null;
    81100    }
     101
     102    public DataRow CreateDataRowRange(string variableName, int start, int end, DataRowVisualProperties.DataRowChartType chartType) {
     103      IList<double> values = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableName));
     104      IList<double> valuesRange = new List<double>();
     105      for (int i = 0; i < values.Count; i++) {
     106        if (i >= start && i <= end)
     107          valuesRange.Add(values[i]);
     108        else
     109          valuesRange.Add(Double.NaN);
     110      }
     111
     112      DataRow row = new DataRow(variableName, "", valuesRange);
     113      row.VisualProperties.ChartType = chartType;
     114      return row;
     115    }
     116
     117    public List<DataRow> CreateAllSelectedDataRows(DataRowVisualProperties.DataRowChartType chartType) {
     118      List<DataRow> dataRows = new List<DataRow>();
     119      foreach (var name in PreprocessingData.GetDoubleVariableNames()) {
     120        DataRow row = CreateSelectedDataRow(name, chartType);
     121        if (row != null)
     122          dataRows.Add(row);
     123      }
     124      return dataRows;
     125    }
     126
     127
     128    public ICheckedItemList<StringValue> CreateVariableItemList() {
     129      ICheckedItemList<StringValue> itemList = new CheckedItemList<StringValue>();
     130      foreach (string name in PreprocessingData.GetDoubleVariableNames()) {
     131        itemList.Add(new StringValue(name), true);
     132      }
     133      return new ReadOnlyCheckedItemList<StringValue>(itemList);
     134    }
     135
     136    public event DataPreprocessingChangedEventHandler Changed {
     137      add { PreprocessingData.Changed += value; }
     138      remove { PreprocessingData.Changed -= value; }
     139    }
     140
    82141  }
    83142}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingData.cs

    r10991 r10992  
    5555    }
    5656
     57    public IEnumerable<string> GetDoubleVariableNames() {
     58      var doubleVariableNames = new List<string>();
     59      for (int i = 0; i < Columns; ++i) {
     60        if (IsType<double>(i)) {
     61          doubleVariableNames.Add(variableNames[i]);
     62        }
     63      }
     64      return doubleVariableNames;
     65    }
     66
    5767    public int Columns {
    5868      get { return variableNames.Count; }
     
    6777      get { return selection; }
    6878      set {
    69           selection = value;
    70           OnSelectionChanged();
    71         }
    72       }   
     79        selection = value;
     80        OnSelectionChanged();
     81      }
     82    }
    7383
    7484    protected PreprocessingData(PreprocessingData original, Cloner cloner)
     
    161171
    162172    public event DataPreprocessingChangedEventHandler Changed;
    163     protected virtual void OnChanged(DataPreprocessingChangedEventType type, int column, int row)
    164     {
     173    protected virtual void OnChanged(DataPreprocessingChangedEventType type, int column, int row) {
    165174      var listeners = Changed;
    166175      if (listeners != null) listeners(this, new DataPreprocessingChangedEventArgs(type, column, row));
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/ScatterPlotContent.cs

    r10987 r10992  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.DataPreprocessing.Interfaces;
    2728
    2829namespace HeuristicLab.DataPreprocessing {
    2930
    3031  [Item("ScatterPlot", "Represents a scatter plot.")]
    31   public class ScatterPlotContent : Item, IViewChartShortcut {
     32  public class ScatterPlotContent : PreprocessingChartContent {
    3233    public static new Image StaticItemImage {
    3334      get { return HeuristicLab.Common.Resources.VSImageLibrary.Performance; }
     
    3738    public string SelectedYVariable { get; set; }
    3839
    39     public IPreprocessingContext Context {
    40       get;
    41       private set;
    42     }
    43     public ITransactionalPreprocessingData PreprocessingData {
    44       get { return Context.Data; }
    45     }
    46 
    47     public ScatterPlotContent(IPreprocessingContext context)
    48       : base() {
    49       this.Context = context;
     40    public ScatterPlotContent(IFilteredPreprocessingData preprocessingData)
     41      : base(preprocessingData) {
    5042    }
    5143
    5244    public ScatterPlotContent(ScatterPlotContent content, Cloner cloner)
    5345      : base(content, cloner) {
    54       this.Context = content.Context;
    5546      this.SelectedXVariable = content.SelectedXVariable;
    5647      this.SelectedYVariable = content.SelectedYVariable;
     
    6051    }
    6152
    62     public DataRow CreateDataRow(string variableName, DataRowVisualProperties.DataRowChartType chartType) {
    63       int columnIndex = PreprocessingData.GetColumnIndex(variableName);
    64       IList<double> values = PreprocessingData.GetValues<double>(columnIndex);
    65       DataRow row = new DataRow(variableName, "", values);
    66       row.VisualProperties.ChartType = chartType;
    67       return row;
    68     }
    69 
    70     public IEnumerable<string> GetVariableNames() {
    71       List<string> doubleVariableNames = new List<string>();
    72 
    73       //only return variable names from type double
    74       foreach (string variableName in PreprocessingData.VariableNames) {
    75         if (PreprocessingData.IsType<double>(PreprocessingData.GetColumnIndex(variableName)))
    76           doubleVariableNames.Add(variableName);
    77       }
    78 
    79       return doubleVariableNames;
    80     }
    81 
    8253    public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY) {
    8354      ScatterPlot scatterPlot = new ScatterPlot();
    8455
    85       int xColumnIndex = PreprocessingData.GetColumnIndex(variableNameX);
    86       int yColumnIndex = PreprocessingData.GetColumnIndex(variableNameY);
    87 
    88       IList<double> xValues = PreprocessingData.GetValues<double>(xColumnIndex);
    89       IList<double> yValues = PreprocessingData.GetValues<double>(yColumnIndex);
     56      IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX));
     57      IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY));
    9058
    9159      List<Point2D<double>> points = new List<Point2D<double>>();
     
    10068      return scatterPlot;
    10169    }
    102 
    10370  }
    10471}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/IPreprocessingData.cs

    r10978 r10992  
    5555
    5656    IEnumerable<string> VariableNames { get; }
     57    IEnumerable<string> GetDoubleVariableNames();
    5758    string GetVariableName(int columnIndex);
    5859    int GetColumnIndex(string variableName);
Note: See TracChangeset for help on using the changeset viewer.