Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10999


Ignore:
Timestamp:
06/11/14 15:28:12 (10 years ago)
Author:
rstoll
Message:
  • Reordered Code
Location:
branches/DataPreprocessing
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs

    r10992 r10999  
    4646    private const string DEFAULT_CHART_TITLE = "Chart";
    4747    private const int FIXED_CHART_SIZE = 300;
    48     private const int MAX_TABLE_ROWS = 3;
     48    private const int MAX_TABLE_AUTO_SIZE_ROWS = 3;
    4949
    5050    public IEnumerable<double> Classification { get; set; }
     
    326326      for (int x = 0; x < columns; x++) {
    327327
    328         if (rows <= MAX_TABLE_ROWS)
     328        if (rows <= MAX_TABLE_AUTO_SIZE_ROWS)
    329329          tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns));
    330330        else
     
    335335          if (x == 0) {
    336336            // fixed chart size when there are more than 3 tables
    337             if (rows > MAX_TABLE_ROWS)
     337            if (rows > MAX_TABLE_AUTO_SIZE_ROWS)
    338338              tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, FIXED_CHART_SIZE));
    339339            else
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataCompletenessChartContent.cs

    r10967 r10999  
    1 using HeuristicLab.Common;
     1using System.Drawing;
     2using HeuristicLab.Common;
    23using HeuristicLab.Core;
    3 using System;
    4 using System.Collections.Generic;
    5 using System.Drawing;
    6 using System.Linq;
    7 using System.Text;
    84
    9 namespace HeuristicLab.DataPreprocessing
    10 {
     5namespace HeuristicLab.DataPreprocessing {
    116  [Item("DataCompletenessChart", "Represents a datacompleteness chart.")]
    12   public class DataCompletenessChartContent : Item, IViewChartShortcut
    13   {
    14     private readonly DataGridLogic dataGridLogic;
    15     private readonly SearchLogic searchLogic;
     7  public class DataCompletenessChartContent : Item, IViewChartShortcut {
    168
    17     public DataCompletenessChartContent(DataGridLogic dataGridLogic, SearchLogic searchLogic)
    18     {
    19       this.dataGridLogic = dataGridLogic;
    20       this.searchLogic = searchLogic;
     9    public static new Image StaticItemImage {
     10      get { return HeuristicLab.Common.Resources.VSImageLibrary.EditBrightnessContrast; }
     11    }
     12
     13    public IDataGridLogic DataGridLogic { get; private set; }
     14    public ISearchLogic SearchLogic { get; private set; }
     15
     16    public DataCompletenessChartContent(DataGridLogic dataGridLogic, SearchLogic searchLogic) {
     17      DataGridLogic = dataGridLogic;
     18      SearchLogic = searchLogic;
    2119    }
    2220
    2321    public DataCompletenessChartContent(DataCompletenessChartContent content, Cloner cloner)
    24       : base(content, cloner)
    25     {
    26       this.dataGridLogic = content.dataGridLogic;
    27       this.searchLogic = content.searchLogic;
     22      : base(content, cloner) {
     23      DataGridLogic = content.DataGridLogic;
     24      SearchLogic = content.SearchLogic;
    2825    }
    2926
    30     public IDataGridLogic DataGridLogic
    31     {
    32       get
    33       {
    34         return dataGridLogic;
    35       }
    36     }
    37 
    38     public ISearchLogic SearchLogic
    39     {
    40       get
    41       {
    42         return searchLogic;
    43       }
    44     }
    45 
    46     public static new Image StaticItemImage
    47     {
    48       get { return HeuristicLab.Common.Resources.VSImageLibrary.EditBrightnessContrast; }
    49     }
    50 
    51     public override IDeepCloneable Clone(Cloner cloner)
    52     {
     27    public override IDeepCloneable Clone(Cloner cloner) {
    5328      return new DataCompletenessChartContent(this, cloner);
    5429    }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataGridContent.cs

    r10977 r10999  
    3131  public class DataGridContent : Item, IViewShortcut, IDataGridContent {
    3232
     33    public static new Image StaticItemImage {
     34      get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; }
     35    }
     36
    3337    public IManipulationLogic ManipulationLogic { get; private set; }
    3438    public IDataGridLogic DataGridLogic { get; private set; }
    3539    public IFilterLogic FilterLogic { get; private set; }
    36 
    37     public static new Image StaticItemImage {
    38       get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; }
    39     }
    4040
    4141    public int Rows {
     
    9898
    9999    }
    100 
    101100    public override IDeepCloneable Clone(Cloner cloner) {
    102101      return new DataGridContent(this, cloner);
     
    115114      remove { DataGridLogic.Changed -= value; }
    116115    }
    117 
    118116
    119117
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataGridLogic.cs

    r10978 r10999  
    2929  public class DataGridLogic : IDataGridLogic {
    3030
    31     private ITransactionalPreprocessingData preprocessingData;
     31    private ITransactionalPreprocessingData PreprocessingData { get; private set; }
    3232    private IEnumerable<string> rowNames;
    33 
    34     public DataGridLogic(ITransactionalPreprocessingData preprocessingData) {
    35       this.preprocessingData = preprocessingData;
    36       createRowNames();
    37     }
    38 
    39     private void createRowNames() {
    40       rowNames = Enumerable.Range(1, Rows).Select(n => n.ToString());
    41     }
    4233
    4334    public int Rows {
    4435      get {
    45         return preprocessingData.Rows;
     36        return PreprocessingData.Rows;
    4637      }
    4738    }
     
    4940    public int Columns {
    5041      get {
    51         return preprocessingData.Columns;
     42        return PreprocessingData.Columns;
    5243      }
    5344    }
     
    5546    public IEnumerable<string> ColumnNames {
    5647      get {
    57         return preprocessingData.VariableNames;
     48        return PreprocessingData.VariableNames;
    5849      }
    5950    }
     
    6556    }
    6657
     58    public DataGridLogic(ITransactionalPreprocessingData preprocessingData) {
     59      PreprocessingData = preprocessingData;
     60      createRowNames();
     61    }
     62
     63    private void createRowNames() {
     64      rowNames = Enumerable.Range(1, Rows).Select(n => n.ToString());
     65    }
     66
     67
     68
    6769    public bool Validate(string value, out string errorMessage, int columnIndex) {
    68       if (columnIndex < 0 || columnIndex > preprocessingData.VariableNames.Count()) {
     70      if (columnIndex < 0 || columnIndex > PreprocessingData.VariableNames.Count()) {
    6971        throw new ArgumentOutOfRangeException("column index is out of range");
    7072      }
     
    7274      bool valid = false;
    7375      errorMessage = string.Empty;
    74       if (preprocessingData.IsType<double>(columnIndex)) {
     76      if (PreprocessingData.IsType<double>(columnIndex)) {
    7577        double val;
    7678        valid = double.TryParse(value, out val);
     
    7880          errorMessage = "Invalid Value (Valid Value Format: \"" + FormatPatterns.GetDoubleFormatPattern() + "\")";
    7981        }
    80       } else if (preprocessingData.IsType<string>(columnIndex)) {
     82      } else if (PreprocessingData.IsType<string>(columnIndex)) {
    8183        valid = value != null;
    8284        if (!valid) {
    8385          errorMessage = "Invalid Value (string must not be null)";
    8486        }
    85       } else if (preprocessingData.IsType<DateTime>(columnIndex)) {
     87      } else if (PreprocessingData.IsType<DateTime>(columnIndex)) {
    8688        DateTime date;
    8789        valid = DateTime.TryParse(value, out date);
     
    9799
    98100    public string GetValue(int columnIndex, int rowIndex) {
    99       return preprocessingData.GetCellAsString(columnIndex, rowIndex);
     101      return PreprocessingData.GetCellAsString(columnIndex, rowIndex);
    100102    }
    101103
    102104    public bool SetValue(string value, int columnIndex, int rowIndex) {
    103105      bool valid = false;
    104       if (preprocessingData.IsType<double>(columnIndex)) {
     106      if (PreprocessingData.IsType<double>(columnIndex)) {
    105107        double val;
    106108        valid = double.TryParse(value, out val);
    107109        SetValueIfValid(columnIndex, rowIndex, valid, val);
    108       } else if (preprocessingData.IsType<string>(columnIndex)) {
     110      } else if (PreprocessingData.IsType<string>(columnIndex)) {
    109111        valid = value != null;
    110112        SetValueIfValid(columnIndex, rowIndex, valid, value);
    111       } else if (preprocessingData.IsType<DateTime>(columnIndex)) {
     113      } else if (PreprocessingData.IsType<DateTime>(columnIndex)) {
    112114        DateTime date;
    113115        valid = DateTime.TryParse(value, out date);
     
    121123    private void SetValueIfValid<T>(int columnIndex, int rowIndex, bool valid, T value) {
    122124      if (valid) {
    123         preprocessingData.SetCell<T>(columnIndex, rowIndex, value);
     125        PreprocessingData.SetCell<T>(columnIndex, rowIndex, value);
    124126      }
    125127    }
    126128
    127129    public void DeleteRow(List<int> rows) {
    128       preprocessingData.InTransaction(() => {
     130      PreprocessingData.InTransaction(() => {
    129131        foreach (int rowIndex in rows) {
    130           preprocessingData.DeleteRow(rowIndex);
     132          PreprocessingData.DeleteRow(rowIndex);
    131133        }
    132134      });
     
    135137
    136138    public event DataPreprocessingChangedEventHandler Changed {
    137       add { preprocessingData.Changed += value; }
    138       remove { preprocessingData.Changed -= value; }
     139      add { PreprocessingData.Changed += value; }
     140      remove { PreprocessingData.Changed -= value; }
    139141    }
    140142
    141143    public bool AreAllStringColumns(IEnumerable<int> columnIndices) {
    142       return columnIndices.All(x => preprocessingData.IsType<string>(x));
     144      return columnIndices.All(x => PreprocessingData.IsType<string>(x));
    143145    }
    144146
    145147
    146148    public void SetSelection(IDictionary<int, IList<int>> selection) {
    147       preprocessingData.Selection = selection;
     149      PreprocessingData.Selection = selection;
    148150    }
    149151
    150152    public IDictionary<int, IList<int>> GetSelection() {
    151       return preprocessingData.Selection;
     153      return PreprocessingData.Selection;
    152154    }
    153155    public void ClearSelection() {
    154       preprocessingData.ClearSelection();
     156      PreprocessingData.ClearSelection();
    155157    }
    156158
    157159    public event EventHandler SelectionChanged {
    158       add { preprocessingData.SelectionChanged += value; }
    159       remove { preprocessingData.SelectionChanged -= value; }
     160      add { PreprocessingData.SelectionChanged += value; }
     161      remove { PreprocessingData.SelectionChanged -= value; }
    160162    }
    161163
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/Filter/ComparisonFilter.cs

    r10947 r10999  
    3131  public class ComparisonFilter : ComparisonConstraint, IFilter {
    3232
    33    
    34 
    35     protected ComparisonFilter(bool deserializing) : base(deserializing) {
    36    
    37     }
    38 
    39     protected ComparisonFilter(ComparisonFilter original, Cloner cloner)
    40       : base(original, cloner) {
    41       constraintColumn = original.constraintColumn;
    42     }
    43     public override IDeepCloneable Clone(Cloner cloner) {
    44       return new ComparisonFilter(this, cloner);
    45     }
    46 
    47     public ComparisonFilter() : base() { }
    48     public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData)
    49       : base(constrainedValue, constraintOperation, constraintData) {
    50     }
    51 
    52     public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData, bool active)
    53       : base(constrainedValue, constraintOperation, constraintData, active) {
    54     }
    55 
    56 
    5733    public override string ItemName {
    5834      get { return "ComparisonFilter"; }
     
    7753    }
    7854
     55    public ComparisonFilter() : base() { }
     56    protected ComparisonFilter(bool deserializing) : base(deserializing) { }
     57
     58    public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData)
     59      : base(constrainedValue, constraintOperation, constraintData) {
     60    }
     61
     62    public ComparisonFilter(IPreprocessingData constrainedValue, ConstraintOperation constraintOperation, object constraintData, bool active)
     63      : base(constrainedValue, constraintOperation, constraintData, active) {
     64    }
     65
     66    protected ComparisonFilter(ComparisonFilter original, Cloner cloner)
     67      : base(original, cloner) {
     68      constraintColumn = original.constraintColumn;
     69    }
     70    public override IDeepCloneable Clone(Cloner cloner) {
     71      return new ComparisonFilter(this, cloner);
     72    }
    7973
    8074    private int constraintColumn;
     
    9286      }
    9387    }
    94 
    9588
    9689    public new bool[] Check() {
     
    121114    }
    122115
    123     public event EventHandler ConstraintColumnChanged;
    124     protected virtual void OnConstraintColumnChanged() {
    125       EventHandler handler = ConstraintColumnChanged;
    126       if (handler != null)
    127         handler(this, EventArgs.Empty);
    128     }
    129 
    130116    public override string ToString() {
    131117      string s = string.Empty;
     
    144130      return s;
    145131    }
     132
     133    public event EventHandler ConstraintColumnChanged;
     134    protected virtual void OnConstraintColumnChanged() {
     135      EventHandler handler = ConstraintColumnChanged;
     136      if (handler != null)
     137        handler(this, EventArgs.Empty);
     138    }
    146139  }
    147140}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilterContent.cs

    r10964 r10999  
    2929  public class FilterContent : Item, IViewShortcut {
    3030
    31     private ICheckedItemCollection<IFilter> filters = new CheckedItemCollection<IFilter>();
    32 
    3331    public static new Image StaticItemImage {
    3432      get { return HeuristicLab.Common.Resources.VSImageLibrary.Filter; }
    3533    }
    3634
    37     private readonly IFilterLogic filterLogic;
     35    private ICheckedItemCollection<IFilter> filters = new CheckedItemCollection<IFilter>();
    3836
    39     public bool isAndCombination = true;
    40 
    41 
    42     public IFilterLogic FilterLogic {
    43       get {
    44         return filterLogic;
    45       }
    46     }
     37    public IFilterLogic FilterLogic { get; private set; }
    4738
    4839    public ICheckedItemCollection<IFilter> Filters {
     
    5546    }
    5647
     48    private bool isAndCombination = true;
    5749    public bool IsAndCombination {
    5850      get {
     
    6456    }
    6557
    66     public FilterContent(IFilterLogic theFilterLogic) {
    67       filterLogic = theFilterLogic;
     58    public FilterContent(IFilterLogic filterLogic) {
     59      FilterLogic = filterLogic;
    6860    }
    6961
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilterLogic.cs

    r10939 r10999  
    2727namespace HeuristicLab.DataPreprocessing {
    2828  public class FilterLogic : IFilterLogic {
    29     private IFilteredPreprocessingData preprocessingData;
     29
     30    public IFilteredPreprocessingData PreprocessingData { get; private set; }
     31
     32    public bool IsFiltered {
     33      get {
     34        return PreprocessingData.IsFiltered;
     35      }
     36    }
    3037
    3138    public FilterLogic(IFilteredPreprocessingData preprocessingData) {
    32       this.preprocessingData = preprocessingData;
     39      PreprocessingData = preprocessingData;
    3340    }
    3441
     
    3744
    3845      if (activeFilters.Count == 0) {
    39         return CreateBoolArray(preprocessingData.Rows, false);
     46        return CreateBoolArray(PreprocessingData.Rows, false);
    4047      }
    4148      return GetActiveFilterResult(activeFilters, isAndCombination);
     
    4350
    4451    private bool[] GetActiveFilterResult(IList<IFilter> activeFilters, bool isAndCombination) {
    45       bool[] result = CreateBoolArray(preprocessingData.Rows, !isAndCombination);
     52      bool[] result = CreateBoolArray(PreprocessingData.Rows, !isAndCombination);
    4653
    4754      foreach (IFilter filter in activeFilters) {
     
    5865      if (activeFilters.Count > 0) {
    5966        var result = GetActiveFilterResult(activeFilters, isAndCombination);
    60         preprocessingData.SetFilter(result);
     67        PreprocessingData.SetFilter(result);
    6168        return result;
    6269      } else {
    63         return CreateBoolArray(preprocessingData.Rows, false);
     70        return CreateBoolArray(PreprocessingData.Rows, false);
    6471      }
    6572    }
     
    7481
    7582    public void Apply(IList<IFilter> filters, bool isAndCombination) {
    76       preprocessingData.PersistFilter();
     83      PreprocessingData.PersistFilter();
    7784      Reset();
    7885    }
    7986
    8087    public void Reset() {
    81       preprocessingData.ResetFilter();
    82     }
    83 
    84     public bool IsFiltered {
    85       get {
    86         return preprocessingData.IsFiltered;
    87       }
    88     }
    89 
    90     public IPreprocessingData PreprocessingData {
    91       get { return preprocessingData; }
     88      PreprocessingData.ResetFilter();
    9289    }
    9390
    9491    public event EventHandler FilterChanged {
    95       add { preprocessingData.FilterChanged += value; }
    96       remove { preprocessingData.FilterChanged -= value; }
     92      add { PreprocessingData.FilterChanged += value; }
     93      remove { PreprocessingData.FilterChanged -= value; }
    9794    }
    9895  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilteredPreprocessingData.cs

    r10992 r10999  
    1313    private ITransactionalPreprocessingData filteredData;
    1414
     15    public IntRange TrainingPartition {
     16      get { return originalData.TrainingPartition; }
     17    }
     18
     19    public IntRange TestPartition {
     20      get { return originalData.TestPartition; }
     21    }
     22
     23    public IList<ITransformation> Transformations {
     24      get { return originalData.Transformations; }
     25    }
     26
     27    public IEnumerable<string> VariableNames {
     28      get { return ActiveData.VariableNames; }
     29    }
     30
    1531    public IDictionary<int, IList<int>> Selection {
    1632      get { return originalData.Selection; }
    1733      set { originalData.Selection = value; }
     34    }
     35
     36    public int Columns {
     37      get { return ActiveData.Columns; }
     38    }
     39
     40    public int Rows {
     41      get { return ActiveData.Rows; }
     42    }
     43
     44    public ITransactionalPreprocessingData ActiveData {
     45      get { return IsFiltered ? filteredData : originalData; }
     46    }
     47
     48    public bool IsUndoAvailable {
     49      get { return IsFiltered ? false : originalData.IsUndoAvailable; }
     50    }
     51
     52    public bool IsFiltered {
     53      get { return filteredData != null; }
     54    }
     55
     56
     57    public FilteredPreprocessingData(ITransactionalPreprocessingData preporcessingData)
     58      : base() {
     59      originalData = preporcessingData;
     60      filteredData = null;
    1861    }
    1962
     
    2366      filteredData = original.filteredData;
    2467    }
    25 
    26     public FilteredPreprocessingData(ITransactionalPreprocessingData preporcessingData)
    27       : base() {
    28       originalData = preporcessingData;
    29       filteredData = null;
    30     }
    31 
    3268    public override IDeepCloneable Clone(Cloner cloner) {
    3369      return new FilteredPreprocessingData(this, cloner);
     
    91127    }
    92128
    93     public IntRange TrainingPartition {
    94       get { return originalData.TrainingPartition; }
    95     }
    96 
    97     public IntRange TestPartition {
    98       get { return originalData.TestPartition; }
    99     }
    100 
    101     public IList<ITransformation> Transformations {
    102       get { return originalData.Transformations; }
    103     }
    104 
    105     public IEnumerable<string> VariableNames {
    106       get { return ActiveData.VariableNames; }
    107     }
    108 
    109129    public string GetVariableName(int columnIndex) {
    110130      return ActiveData.GetVariableName(columnIndex);
     
    117137    public bool IsType<T>(int columnIndex) {
    118138      return originalData.IsType<T>(columnIndex);
    119     }
    120 
    121     public int Columns {
    122       get { return ActiveData.Columns; }
    123     }
    124 
    125     public int Rows {
    126       get { return ActiveData.Rows; }
    127139    }
    128140
     
    171183    }
    172184
    173     public ITransactionalPreprocessingData ActiveData {
    174       get { return IsFiltered ? filteredData : originalData; }
    175     }
    176 
    177 
    178     public bool IsUndoAvailable {
    179       get { return IsFiltered ? false : originalData.IsUndoAvailable; }
    180     }
    181 
    182 
    183     public bool IsFiltered {
    184       get { return filteredData != null; }
     185    public void Undo() {
     186      if (IsFiltered)
     187        throw new InvalidOperationException("Undo not possible while data is filtered");
     188
     189      originalData.Undo();
     190    }
     191
     192    public void InTransaction(Action action, DataPreprocessingChangedEventType type = DataPreprocessingChangedEventType.Any) {
     193      if (IsFiltered)
     194        throw new InvalidOperationException("Transaction not possible while data is filtered");
     195      originalData.InTransaction(action, type);
     196    }
     197
     198    public void BeginTransaction(DataPreprocessingChangedEventType type) {
     199      if (IsFiltered)
     200        throw new InvalidOperationException("Transaction not possible while data is filtered");
     201      originalData.BeginTransaction(type);
     202    }
     203
     204    public void EndTransaction() {
     205      originalData.EndTransaction();
     206    }
     207
     208    public IEnumerable<string> GetDoubleVariableNames() {
     209      return originalData.GetDoubleVariableNames();
     210    }
     211
     212    public void ClearSelection() {
     213      originalData.ClearSelection();
    185214    }
    186215
     
    190219    }
    191220
    192 
    193     public void Undo() {
    194       if (IsFiltered)
    195         throw new InvalidOperationException("Undo not possible while data is filtered");
    196 
    197       originalData.Undo();
    198     }
    199 
    200     public void InTransaction(Action action, DataPreprocessingChangedEventType type = DataPreprocessingChangedEventType.Any) {
    201       if (IsFiltered)
    202         throw new InvalidOperationException("Transaction not possible while data is filtered");
    203       originalData.InTransaction(action, type);
    204     }
    205 
    206     public void BeginTransaction(DataPreprocessingChangedEventType type) {
    207       if (IsFiltered)
    208         throw new InvalidOperationException("Transaction not possible while data is filtered");
    209       originalData.BeginTransaction(type);
    210     }
    211 
    212     public void EndTransaction() {
    213       originalData.EndTransaction();
    214     }
    215 
    216     public event EventHandler FilterChanged;
    217 
    218     #region IPreprocessingData Members
    219 
    220     public void ClearSelection() {
    221       originalData.ClearSelection();
    222     }
    223 
    224221    public event EventHandler SelectionChanged {
    225222      add { originalData.SelectionChanged += value; }
     
    227224    }
    228225
    229     #endregion
    230 
    231     #region IPreprocessingData Members
    232 
    233 
    234     public IEnumerable<string> GetDoubleVariableNames() {
    235       return originalData.GetDoubleVariableNames();
    236     }
    237 
    238     #endregion
     226    public event EventHandler FilterChanged;
    239227  }
    240228}
Note: See TracChangeset for help on using the changeset viewer.