Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/14 10:49:15 (11 years ago)
Author:
rstoll
Message:
  • SelectionEvent added
Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations
Files:
3 edited

Legend:

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

    r10662 r10804  
    143143      return columnIndices.All(x => preprocessingData.IsType<string>(x));
    144144    }
     145
     146
     147
     148    public void SetSelection(IDictionary<int, IList<int>> selection) {
     149      preprocessingData.SetSelection(selection);
     150    }
     151
     152    public IDictionary<int, IList<int>> GetSelection() {
     153      return preprocessingData.GetSelection();
     154    }
     155    public void ClearSelection() {
     156      preprocessingData.ClearSelection();
     157    }
     158
     159    public event EventHandler SelectionChanged {
     160      add { preprocessingData.SelectionChanged += value; }
     161      remove { preprocessingData.SelectionChanged -= value; }
     162    }
     163
    145164  }
    146165}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilteredPreprocessingData.cs

    r10783 r10804  
    44using HeuristicLab.Core;
    55using HeuristicLab.Data;
     6using HeuristicLab.DataPreprocessing.Interfaces;
    67using HeuristicLab.Problems.DataAnalysis;
    78using HeuristicLab.Problems.DataAnalysis.Transformations;
    8 using HeuristicLab.DataPreprocessing.Interfaces;
    99
    10 namespace HeuristicLab.DataPreprocessing.Implementations
    11 {
    12   public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData
    13   {
     10namespace HeuristicLab.DataPreprocessing.Implementations {
     11  public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData {
    1412    protected ITransactionalPreprocessingData originalData;
    1513    protected ITransactionalPreprocessingData filteredData;
     
    1715    protected FilteredPreprocessingData(FilteredPreprocessingData original, Cloner cloner)
    1816      : base(original, cloner) {
    19         originalData = (ITransactionalPreprocessingData)original.originalData;
    20         filteredData = (ITransactionalPreprocessingData)original.filteredData;
     17      originalData = (ITransactionalPreprocessingData)original.originalData;
     18      filteredData = (ITransactionalPreprocessingData)original.filteredData;
    2119    }
    2220
    2321    public FilteredPreprocessingData(ITransactionalPreprocessingData preporcessingData)
    2422      : base() {
    25         originalData = preporcessingData;
    26         filteredData = null;
     23      originalData = preporcessingData;
     24      filteredData = null;
    2725    }
    2826
    29      public override IDeepCloneable Clone(Cloner cloner)
    30      {
    31        return new FilteredPreprocessingData(this, cloner);
    32      }
     27    public override IDeepCloneable Clone(Cloner cloner) {
     28      return new FilteredPreprocessingData(this, cloner);
     29    }
    3330
    34      public T GetCell<T>(int columnIndex, int rowIndex)
    35      {
    36        return ActiveData.GetCell<T>(columnIndex, rowIndex);
    37      }
     31    public T GetCell<T>(int columnIndex, int rowIndex) {
     32      return ActiveData.GetCell<T>(columnIndex, rowIndex);
     33    }
    3834
    39      public void SetCell<T>(int columnIndex, int rowIndex, T value)
    40      {
    41        ReadOnlyOnFilterData.SetCell<T>(columnIndex, rowIndex, value);
    42      }
     35    public void SetCell<T>(int columnIndex, int rowIndex, T value) {
     36      ReadOnlyOnFilterData.SetCell<T>(columnIndex, rowIndex, value);
     37    }
    4338
    44      public string GetCellAsString(int columnIndex, int rowIndex)
    45      {
    46        return ActiveData.GetCellAsString(columnIndex, rowIndex);
    47      }
     39    public string GetCellAsString(int columnIndex, int rowIndex) {
     40      return ActiveData.GetCellAsString(columnIndex, rowIndex);
     41    }
    4842
    49      public IList<T> GetValues<T>(string variableName)
    50      {
    51        return ActiveData.GetValues<T>(variableName);
    52      }
     43    public IList<T> GetValues<T>(string variableName) {
     44      return ActiveData.GetValues<T>(variableName);
     45    }
    5346
    54      public IList<T> GetValues<T>(int columnIndex)
    55      {
    56        return ActiveData.GetValues<T>(columnIndex);
    57      }
     47    public IList<T> GetValues<T>(int columnIndex) {
     48      return ActiveData.GetValues<T>(columnIndex);
     49    }
    5850
    59      public void SetValues<T>(int columnIndex, IList<T> values)
    60      {
    61        ReadOnlyOnFilterData.SetValues<T>(columnIndex, values);
    62      }
     51    public void SetValues<T>(int columnIndex, IList<T> values) {
     52      ReadOnlyOnFilterData.SetValues<T>(columnIndex, values);
     53    }
    6354
    64      public void InsertRow(int rowIndex)
    65      {
    66        ReadOnlyOnFilterData.InsertRow(rowIndex);
    67      }
     55    public void InsertRow(int rowIndex) {
     56      ReadOnlyOnFilterData.InsertRow(rowIndex);
     57    }
    6858
    69      public void DeleteRow(int rowIndex)
    70      {
    71        ReadOnlyOnFilterData.DeleteRow(rowIndex);
    72      }
     59    public void DeleteRow(int rowIndex) {
     60      ReadOnlyOnFilterData.DeleteRow(rowIndex);
     61    }
    7362
    74      public void InsertColumn<T>(string variableName, int columnIndex)
    75      {
    76        ReadOnlyOnFilterData.InsertColumn<T>(variableName, columnIndex);
    77      }
     63    public void InsertColumn<T>(string variableName, int columnIndex) {
     64      ReadOnlyOnFilterData.InsertColumn<T>(variableName, columnIndex);
     65    }
    7866
    79      public void DeleteColumn(int columnIndex)
    80      {
    81        ReadOnlyOnFilterData.DeleteColumn(columnIndex);
    82      }
     67    public void DeleteColumn(int columnIndex) {
     68      ReadOnlyOnFilterData.DeleteColumn(columnIndex);
     69    }
    8370
    84      public IntRange TrainingPartition
    85      {
    86        get { return originalData.TrainingPartition; }
    87      }
     71    public IntRange TrainingPartition {
     72      get { return originalData.TrainingPartition; }
     73    }
    8874
    89      public IntRange TestPartition
    90      {
    91        get { return originalData.TestPartition; }
    92      }
     75    public IntRange TestPartition {
     76      get { return originalData.TestPartition; }
     77    }
    9378
    94      public IList<ITransformation> Transformations
    95      {
    96        get { return originalData.Transformations; }
    97      }
     79    public IList<ITransformation> Transformations {
     80      get { return originalData.Transformations; }
     81    }
    9882
    99      public IEnumerable<string> VariableNames
    100      {
    101        get { return ActiveData.VariableNames; }
    102      }
     83    public IEnumerable<string> VariableNames {
     84      get { return ActiveData.VariableNames; }
     85    }
    10386
    104      public string GetVariableName(int columnIndex)
    105      {
    106        return ActiveData.GetVariableName(columnIndex);
    107      }
     87    public string GetVariableName(int columnIndex) {
     88      return ActiveData.GetVariableName(columnIndex);
     89    }
    10890
    109      public int GetColumnIndex(string variableName)
    110      {
    111        return ActiveData.GetColumnIndex(variableName);
    112      }
     91    public int GetColumnIndex(string variableName) {
     92      return ActiveData.GetColumnIndex(variableName);
     93    }
    11394
    114      public bool IsType<T>(int columnIndex)
    115      {
    116        return originalData.IsType<T>(columnIndex);
    117      }
     95    public bool IsType<T>(int columnIndex) {
     96      return originalData.IsType<T>(columnIndex);
     97    }
    11898
    119      public int Columns
    120      {
    121        get { return ActiveData.Columns; }
    122      }
     99    public int Columns {
     100      get { return ActiveData.Columns; }
     101    }
    123102
    124      public int Rows
    125      {
    126        get { return ActiveData.Rows; }
    127      }
     103    public int Rows {
     104      get { return ActiveData.Rows; }
     105    }
    128106
    129      public Dataset ExportToDataset()
    130      {
    131        return originalData.ExportToDataset();
    132      }
     107    public Dataset ExportToDataset() {
     108      return originalData.ExportToDataset();
     109    }
    133110
    134      public void SetFilter(bool[] rowFilters) {
     111    public void SetFilter(bool[] rowFilters) {
    135112
    136        filteredData = (ITransactionalPreprocessingData)originalData.Clone();
     113      filteredData = (ITransactionalPreprocessingData)originalData.Clone();
    137114
    138        for (int row = (rowFilters.Length - 1); row >= 0; --row)
    139        {
    140          if (rowFilters[row])
    141          {
    142            filteredData.DeleteRow(row);
    143          }
    144        }
    145      }
     115      for (int row = (rowFilters.Length - 1); row >= 0; --row) {
     116        if (rowFilters[row]) {
     117          filteredData.DeleteRow(row);
     118        }
     119      }
     120    }
    146121
    147      public void PersistFilter() {
    148        originalData = (ITransactionalPreprocessingData)filteredData.Clone();
    149        ResetFilter();
    150      }
     122    public void PersistFilter() {
     123      originalData = (ITransactionalPreprocessingData)filteredData.Clone();
     124      ResetFilter();
     125    }
    151126
    152      public void ResetFilter() {
    153        filteredData = null;
    154      }
     127    public void ResetFilter() {
     128      filteredData = null;
     129    }
    155130
    156      public ITransactionalPreprocessingData ActiveData
    157      {
    158        get { return IsFiltered ? filteredData : originalData; }
    159      }
     131    public ITransactionalPreprocessingData ActiveData {
     132      get { return IsFiltered ? filteredData : originalData; }
     133    }
    160134
    161      public ITransactionalPreprocessingData ReadOnlyOnFilterData
    162      {
    163        get {
    164          if (IsFiltered)
    165             throw new InvalidOperationException();
    166          
    167          return originalData;
    168        }
    169      }
     135    public ITransactionalPreprocessingData ReadOnlyOnFilterData {
     136      get {
     137        if (IsFiltered)
     138          throw new InvalidOperationException();
    170139
    171      public bool IsFiltered {
    172        get { return filteredData != null; }
    173      }
     140        return originalData;
     141      }
     142    }
    174143
    175      public event DataPreprocessingChangedEventHandler Changed;
     144    public bool IsFiltered {
     145      get { return filteredData != null; }
     146    }
    176147
    177      public bool IsUndoAvailable
    178      {
    179        get { return IsFiltered ? false : originalData.IsUndoAvailable; }
    180      }
     148    public event DataPreprocessingChangedEventHandler Changed;
    181149
    182      public void Undo()
    183      {
    184        ReadOnlyOnFilterData.Undo();
    185      }
     150    public bool IsUndoAvailable {
     151      get { return IsFiltered ? false : originalData.IsUndoAvailable; }
     152    }
    186153
    187      public void InTransaction(Action action, DataPreprocessingChangedEventType type = DataPreprocessingChangedEventType.Any)
    188      {
    189        ReadOnlyOnFilterData.InTransaction(action, type);
    190      }
     154    public void Undo() {
     155      ReadOnlyOnFilterData.Undo();
     156    }
    191157
    192      public void BeginTransaction(DataPreprocessingChangedEventType type)
    193      {
    194        ReadOnlyOnFilterData.BeginTransaction(type);
    195      }
     158    public void InTransaction(Action action, DataPreprocessingChangedEventType type = DataPreprocessingChangedEventType.Any) {
     159      ReadOnlyOnFilterData.InTransaction(action, type);
     160    }
    196161
    197      public void EndTransaction()
    198      {
    199        originalData.EndTransaction();
    200      }
     162    public void BeginTransaction(DataPreprocessingChangedEventType type) {
     163      ReadOnlyOnFilterData.BeginTransaction(type);
     164    }
     165
     166    public void EndTransaction() {
     167      originalData.EndTransaction();
     168    }
     169
     170    #region IPreprocessingData Members
     171
     172
     173    public void SetSelection(IDictionary<int, IList<int>> selection) {
     174      originalData.SetSelection(selection);
     175    }
     176
     177    public IDictionary<int, IList<int>> GetSelection() {
     178      return originalData.GetSelection();
     179    }
     180
     181    public void ClearSelection() {
     182      originalData.ClearSelection();
     183    }
     184
     185    public event EventHandler SelectionChanged;
     186
     187    #endregion
    201188  }
    202189}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingData.cs

    r10786 r10804  
    4343    protected IList<ITransformation> transformations;
    4444
     45    protected IDictionary<int, IList<int>> currentSelection;
     46
    4547    protected PreprocessingData(PreprocessingData original, Cloner cloner)
    4648      : base(original, cloner) {
     
    5557
    5658      transformations = new List<ITransformation>();
     59      currentSelection = new Dictionary<int, IList<int>>();
    5760
    5861      variableNames = new List<string>(problemData.Dataset.VariableNames);
     
    205208    }
    206209
     210    public void SetSelection(IDictionary<int, IList<int>> selection) {
     211      currentSelection = selection;
     212      if (SelectionChanged != null) {
     213        SelectionChanged(this, new EventArgs());
     214      }
     215    }
     216
     217    public IDictionary<int, IList<int>> GetSelection() {
     218      return currentSelection;
     219    }
     220
     221    public void ClearSelection() {
     222      currentSelection = new Dictionary<int, IList<int>>();
     223    }
     224
     225    public event EventHandler SelectionChanged;
     226
    207227    #endregion
    208228  }
Note: See TracChangeset for help on using the changeset viewer.