Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10804


Ignore:
Timestamp:
05/07/14 10:49:15 (10 years ago)
Author:
rstoll
Message:
  • SelectionEvent added
Location:
branches/DataPreprocessing
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs

    r10785 r10804  
    8282      _highlightedCellsBackground = new Dictionary<int, IList<int>>();
    8383      currentCell = null;
     84      DataGridView.SelectionChanged += DataGridView_SelectionChanged;
     85    }
     86
     87    void DataGridView_SelectionChanged(object sender, EventArgs e) {
     88      Content.DataGridLogic.SetSelection(GetSelectedCells());
    8489    }
    8590
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingChartView.cs

    r10803 r10804  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Drawing;
    2524using System.Windows.Forms;
    2625using HeuristicLab.Analysis;
     
    6463        if (VariableIsDisplayed(variableName)) {
    6564          dataTable.Rows.Remove(variableName);
    66           dataTablePerVariable.Remove(dataTablePerVariable.Find( x => (x.Name == variableName)));
     65          dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName)));
    6766        } else {
    6867          DataRow row = GetDataRow(variableName);
     
    9190      base.RegisterContentEvents();
    9291      Content.ChartLogic.Changed += PreprocessingData_Changed;
    93      
     92
    9493    }
    9594
     
    112111      dataTable = new PreprocessingDataTable(chartTitle);
    113112      dataTable.Rows.AddRange(dataRows);
    114      
     113
    115114
    116115      // init data table per variable
    117116      dataTablePerVariable = new List<PreprocessingDataTable>();
    118       foreach(var checkedItem in variableItemList.CheckedItems) {
     117      foreach (var checkedItem in variableItemList.CheckedItems) {
    119118        string variableName = variableItemList[checkedItem.Index].Value;
    120119        PreprocessingDataTable d = new PreprocessingDataTable(variableName);
     
    123122        //rowSelect.Name = variableName + "(Selected)";
    124123        //rowSelect.VisualProperties.Color = Color.Green;
    125        
     124
    126125        d.Rows.Add(row);
    127126        //d.SelectedRows.Add(rowSelect);
    128        
     127
    129128        dataTablePerVariable.Add(d);
    130129
     
    144143      if (Content != null) {
    145144        logic = Content.ChartLogic;
    146         InitData();       
     145        InitData();
    147146        variableItemList.CheckedItemsChanged += CheckedItemsChanged;
    148         GenerateChart();               
     147        GenerateChart();
    149148      }
    150149    }
     
    167166        case DataPreprocessingChangedEventType.Any:
    168167          InitData();
    169           GenerateChart();         
     168          GenerateChart();
    170169          break;
    171170      }
     
    217216    protected void GenerateChart() {
    218217
    219       ClearTableLayout(); 
     218      ClearTableLayout();
    220219
    221220      if (allInOneMode) {
     
    234233      tableLayoutPanel.AutoScroll = false;
    235234      tableLayoutPanel.AutoScroll = true;
    236     }   
     235    }
    237236
    238237    private void GenerateSingleChartLayout() {
     
    247246    private void GenerateMultiChartLayout() {
    248247      int checkedItemsCnt = 0;
    249       foreach(var item in variableItemList.CheckedItems)
     248      foreach (var item in variableItemList.CheckedItems)
    250249        checkedItemsCnt++;
    251250
     
    262261
    263262      if (columns == 3)
    264         rows = (checkedItemsCnt+2) / columns;
    265       else if(columns == 2)
     263        rows = (checkedItemsCnt + 2) / columns;
     264      else if (columns == 2)
    266265        rows = (checkedItemsCnt + 1) / columns;
    267266      else
     
    274273      List<PreprocessingDataTable>.Enumerator enumerator = dataTablePerVariable.GetEnumerator();
    275274      for (int x = 0; x < columns; x++) {
    276        
    277         if(rows <= 3)
     275
     276        if (rows <= 3)
    278277          tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns));
    279278        else
     
    298297            p.Dock = DockStyle.Fill;
    299298            tableLayoutPanel.Controls.Add(p, y, x);
    300           }
    301           else {
     299          } else {
    302300            dataView.Content = d;
    303301            dataView.Dock = DockStyle.Fill;
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/PreprocessingDataTableView.cs

    r10803 r10804  
    2020#endregion
    2121
    22 using HeuristicLab.Collections;
    23 using HeuristicLab.Core.Views;
    24 using HeuristicLab.MainForm;
    2522using System;
    2623using System.Collections.Generic;
     
    2926using System.Windows.Forms;
    3027using System.Windows.Forms.DataVisualization.Charting;
     28using HeuristicLab.Collections;
     29using HeuristicLab.Core.Views;
    3130using HeuristicLab.DataPreprocessing.Implementations;
     31using HeuristicLab.MainForm;
    3232
    3333namespace HeuristicLab.Analysis.Views {
     
    172172      else series.Color = Color.Empty;
    173173      series.IsVisibleInLegend = row.VisualProperties.IsVisibleInLegend;
    174      
     174
    175175      switch (row.VisualProperties.ChartType) {
    176176        case DataRowVisualProperties.DataRowChartType.Line:
     
    535535
    536536    // get minimum ignores nan values
    537     private double GetMinimum(IEnumerable<double> values)
    538     {
     537    private double GetMinimum(IEnumerable<double> values) {
    539538      double min = Double.MaxValue;
    540539
    541540      foreach (double value in values) {
    542541        if (!Double.IsNaN(value) && value < min)
    543           min = value;     
     542          min = value;
    544543      }
    545544      return min;
  • 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  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IDataGridLogic.cs

    r10622 r10804  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324
     
    3839
    3940    void DeleteRow(List<int> rows);
     41
     42    void SetSelection(IDictionary<int, IList<int>> selection);
     43    IDictionary<int, IList<int>> GetSelection();
     44    void ClearSelection();
     45
     46    event EventHandler SelectionChanged;
    4047  }
    4148}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IPreprocessingData.cs

    r10772 r10804  
    6464
    6565    Dataset ExportToDataset();
     66
     67    void SetSelection(IDictionary<int, IList<int>> selection);
     68    IDictionary<int, IList<int>> GetSelection();
     69    void ClearSelection();
     70
     71    event EventHandler SelectionChanged;
    6672  }
    6773}
Note: See TracChangeset for help on using the changeset viewer.