Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10992


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
Files:
2 deleted
13 edited

Legend:

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

    r10990 r10992  
    4949        var statisticsLogic = new StatisticsLogic(data, searchLogic);
    5050        var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic);
    51         var chartLogic = new ChartLogic(data);
    5251        //var correlationMatrixLogic = new ChartLogic(data);
    5352        var filterLogic = new FilterLogic(data);
     
    5958          new StatisticsContent(statisticsLogic),
    6059
    61           new LineChartContent(chartLogic),
    62           new HistogramContent(chartLogic),
    63           new ScatterPlotContent(Content),
     60          new LineChartContent(data),
     61          new HistogramContent(data),
     62          new ScatterPlotContent(data),
    6463          new CorrelationMatrixContent(Content),
    6564          new DataCompletenessChartContent(dataGridLogic, searchLogic),
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs

    r10942 r10992  
    1818 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
    1919 */
    20 #endregion 
     20#endregion
    2121using System;
    2222using System.Windows.Forms;
     
    4040      base.OnContentChanged();
    4141      if (Content != null) {
    42         logic = Content.ChartLogic;
    4342
    4443        classifierComboBox.Items.Clear();
    4544        classifierComboBox.Items.Add("None");
    4645
    47         foreach (string var in logic.GetVariableNamesForHistogramClassification()) {
     46        foreach (string var in Content.GetVariableNamesForHistogramClassification()) {
    4847          classifierComboBox.Items.Add(var);
    4948        }
     
    6665
    6766      if (classifierComboBox.SelectedIndex != 0) {
    68         Classification = logic.GetVariableValues(classifierComboBox.SelectedItem.ToString());
     67        int columndIndex = Content.PreprocessingData.GetColumnIndex(classifierComboBox.SelectedItem.ToString());
     68        Classification = Content.PreprocessingData.GetValues<double>(columndIndex);
    6969      } else {
    7070        Classification = null;
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs

    r10987 r10992  
    2424using System.Windows.Forms;
    2525using HeuristicLab.Analysis;
    26 using HeuristicLab.Analysis.Views;
    2726using HeuristicLab.Collections;
    28 using HeuristicLab.Core;
    2927using HeuristicLab.Core.Views;
    3028using HeuristicLab.Data;
     
    4543    protected DataRowVisualProperties.DataRowChartType chartType;
    4644    protected string chartTitle;
    47     protected IChartLogic logic;
    4845
    4946    private const string DEFAULT_CHART_TITLE = "Chart";
    5047    private const int FIXED_CHART_SIZE = 300;
    51     private const int MAX_TABLE_AUTO_SIZE_ROWS = 3;
     48    private const int MAX_TABLE_ROWS = 3;
    5249
    5350    public IEnumerable<double> Classification { get; set; }
     
    7067          dataTable.SelectedRows.Remove(variableName);
    7168          dataTablePerVariable.Remove(dataTablePerVariable.Find(x => (x.Name == variableName)));
    72         //variable isnt't displayed -> add
     69          //variable isnt't displayed -> add
    7370        } else {
    7471          DataRow row = GetDataRow(variableName);
     
    8178
    8279          //update selection
    83           if (selectedRow != null)
    84           {
     80          if (selectedRow != null) {
    8581            dataTable.SelectedRows.Add(selectedRow);
    8682            pdt.SelectedRows.Add(selectedRow);
     83          }
    8784        }
    88       }
    8985      }
    9086
     
    106102    protected override void RegisterContentEvents() {
    107103      base.RegisterContentEvents();
    108       Content.ChartLogic.Changed += PreprocessingData_Changed;
    109       Content.ChartLogic.SelectionChanged += PreprocessingData_SelctionChanged;
     104      Content.PreprocessingData.Changed += PreprocessingData_Changed;
     105      Content.PreprocessingData.SelectionChanged += PreprocessingData_SelctionChanged;
    110106
    111107    }
     
    113109    protected override void DeregisterContentEvents() {
    114110      base.DeregisterContentEvents();
    115       Content.ChartLogic.Changed -= PreprocessingData_Changed;
    116       Content.ChartLogic.SelectionChanged -= PreprocessingData_SelctionChanged;
     111      Content.PreprocessingData.Changed -= PreprocessingData_Changed;
     112      Content.PreprocessingData.SelectionChanged -= PreprocessingData_SelctionChanged;
    117113    }
    118114
     
    123119
    124120    private void InitData() {
    125       if (Content.VariableItemList == null)
    126       {
    127         Content.VariableItemList = logic.CreateVariableItemList();
     121      if (Content.VariableItemList == null) {
     122        Content.VariableItemList = Content.CreateVariableItemList();
    128123      }
    129124      checkedItemList.Content = Content.VariableItemList;
    130125
    131126      //Create data tables and data rows
    132       dataRows = logic.CreateAllDataRows(chartType);
     127      dataRows = Content.CreateAllDataRows(chartType);
    133128      dataTable = new PreprocessingDataTable(chartTitle);
    134129      dataTablePerVariable = new List<PreprocessingDataTable>();
    135130
    136131      //add data rows to data tables according to checked item list
    137       foreach (var checkedItem in Content.VariableItemList.CheckedItems)
    138       {
     132      foreach (var checkedItem in Content.VariableItemList.CheckedItems) {
    139133        string variableName = Content.VariableItemList[checkedItem.Index].Value;
    140134        PreprocessingDataTable d = new PreprocessingDataTable(variableName);
     
    155149
    156150      //update data table selection
    157       selectedDataRows = logic.CreateAllSelectedDataRows(chartType);
     151      selectedDataRows = Content.CreateAllSelectedDataRows(chartType);
    158152      dataTable.SelectedRows.Clear();
    159153      dataTable.SelectedRows.AddRange(selectedDataRows);
     
    188182      base.OnContentChanged();
    189183      if (Content != null) {
    190         logic = Content.ChartLogic;
    191184        InitData();
    192185        Content.VariableItemList.CheckedItemsChanged += CheckedItemsChanged;
     
    199192      switch (e.Type) {
    200193        case DataPreprocessingChangedEventType.DeleteColumn:
    201           RemoveVariable(logic.GetVariableNameByIndex(e.Column));
     194          RemoveVariable(Content.PreprocessingData.GetVariableName(e.Column));
    202195          break;
    203196        case DataPreprocessingChangedEventType.AddColumn:
    204           AddVariable(logic.GetVariableNameByIndex(e.Column));
     197          AddVariable(Content.PreprocessingData.GetVariableName(e.Column));
    205198          break;
    206199        case DataPreprocessingChangedEventType.ChangeColumn:
    207200        case DataPreprocessingChangedEventType.ChangeItem:
    208           UpdateDataForVariable(logic.GetVariableNameByIndex(e.Column));
     201          UpdateDataForVariable(Content.PreprocessingData.GetVariableName(e.Column));
    209202          break;
    210203        case DataPreprocessingChangedEventType.DeleteRow:
     
    212205        case DataPreprocessingChangedEventType.Any:
    213206        default:
    214            //TODO: test with transform
     207          //TODO: test with transform
    215208          InitData();
    216209          GenerateChart();
     
    224217
    225218    private void UpdateDataForVariable(string variableName) {
    226       DataRow newRow = logic.CreateDataRow(variableName, chartType);
     219      DataRow newRow = Content.CreateDataRow(variableName, chartType);
    227220      dataTable.Rows.Remove(variableName);
    228221      dataTable.Rows.Add(newRow);
     
    236229    // add variable to data table and item list
    237230    private void AddVariable(string name) {
    238       DataRow row = logic.CreateDataRow(name, chartType);
     231      DataRow row = Content.CreateDataRow(name, chartType);
    239232      dataTable.Rows.Add(row);
    240233      PreprocessingDataTable d = new PreprocessingDataTable(name);
     
    259252
    260253    private StringValue FindVariableItemList(string name) {
    261       foreach (StringValue stringValue in Content.VariableItemList)
    262       {
     254      foreach (StringValue stringValue in Content.VariableItemList) {
    263255        if (stringValue.Value == name)
    264256          return stringValue;
     
    270262
    271263      ClearTableLayout();
    272       if (Content.AllInOneMode)
    273       {
     264      if (Content.AllInOneMode) {
    274265        GenerateSingleChartLayout();
    275266      } else
     
    328319      int columns = GetNrOfMultiChartColumns(checkedItemsCnt);
    329320      int rows = GetNrOfMultiChartRows(checkedItemsCnt, columns);
    330       tableLayoutPanel.VerticalScroll.Enabled = true;
    331      
     321
    332322      tableLayoutPanel.ColumnCount = columns;
    333323      tableLayoutPanel.RowCount = rows;
     
    336326      for (int x = 0; x < columns; x++) {
    337327
    338         if (rows <= MAX_TABLE_AUTO_SIZE_ROWS)
     328        if (rows <= MAX_TABLE_ROWS)
    339329          tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100 / columns));
    340330        else
     
    345335          if (x == 0) {
    346336            // fixed chart size when there are more than 3 tables
    347             if (rows > MAX_TABLE_AUTO_SIZE_ROWS)
     337            if (rows > MAX_TABLE_ROWS)
    348338              tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, FIXED_CHART_SIZE));
    349339            else
     
    354344          PreprocessingDataTable d = enumerator.Current;
    355345          AddDataTableToTableLayout(d, x, y);
    356          
     346
    357347        }
    358348      }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs

    r10987 r10992  
    11using System;
    22using System.Collections.Generic;
    3 using System.ComponentModel;
    43using System.Drawing;
    54using System.Linq;
    6 using System.Text;
    75using System.Windows.Forms;
    86using HeuristicLab.Analysis;
    9 using HeuristicLab.Analysis.Views;
    10 using HeuristicLab.Collections;
    117using HeuristicLab.Common;
    12 using HeuristicLab.Core;
    138using HeuristicLab.Core.Views;
    14 using HeuristicLab.Data;
    159using HeuristicLab.DataPreprocessing.Implementations;
    1610using HeuristicLab.MainForm;
     
    4741    private void addHeaderToTableLayoutPanels() {
    4842
    49       List<string> variables = Content.GetVariableNames().ToList();
     43      List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList();
    5044
    5145      for (int i = 1; i < variables.Count + 1; i++) {
     
    6660    }
    6761
    68     private void GenerateMultiLayout()
    69     {
    70       List<string> variables = Content.GetVariableNames().ToList();
     62    private void GenerateMultiLayout() {
     63      List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList();
    7164
    7265      tableLayoutPanel.Controls.Clear();
     
    7669
    7770      //Set row and column count
    78       tableLayoutPanel.ColumnCount = variables.Count+1;
    79       tableLayoutPanel.RowCount = variables.Count+1;
     71      tableLayoutPanel.ColumnCount = variables.Count + 1;
     72      tableLayoutPanel.RowCount = variables.Count + 1;
    8073
    8174      tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, HEADER_WIDTH));
    8275      tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, HEADER_HEIGHT));
    8376      // set column and row layout
    84       for (int x = 0; x < variables.Count; x++)
    85       {
     77      for (int x = 0; x < variables.Count; x++) {
    8678        // auto size
    8779        if (variables.Count <= MAX_AUTO_SIZE_ELEMENTS) {
    8880          tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (tableLayoutPanel.Width - HEADER_WIDTH) / variables.Count));
    8981          tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, (tableLayoutPanel.Height - HEADER_HEIGHT) / variables.Count));
    90         } 
    91         // fixed size
     82        }
     83          // fixed size
    9284        else {
    9385          tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, FIXED_CHART_WIDTH));
     
    9890      addHeaderToTableLayoutPanels();
    9991      addChartsToTableLayoutPanel();
    100  
     92
    10193    }
    10294
    10395    private void addChartsToTableLayoutPanel() {
    10496
    105       List<string> variables = Content.GetVariableNames().ToList();
     97      List<string> variables = Content.PreprocessingData.GetDoubleVariableNames().ToList();
    10698
    10799      //set scatter plots and histograms
     
    119111            tableLayoutPanel.Controls.Add(pcv, y, x);
    120112          }
    121           //scatter plot
     113            //scatter plot
    122114          else {
    123115            ScatterPlot scatterPlot = Content.CreateScatterPlot(variables[x - 1], variables[y - 1]);
     
    147139      // only one data row should be in scatter plot
    148140      if (scatterPlot.Rows.Count == 1) {
    149         string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[]{" - "},StringSplitOptions.None); // extract variable names from string
     141        string[] variables = scatterPlot.Rows.ElementAt(0).Name.Split(new string[] { " - " }, StringSplitOptions.None); // extract variable names from string
    150142        scatterContent.SelectedXVariable = variables[0];
    151143        scatterContent.SelectedYVariable = variables[1];
     
    161153
    162154        // set only variable name checked
    163         foreach(var checkedItem in histoContent.VariableItemList)
    164         {
    165           if(checkedItem.Value == variableName)
    166             histoContent.VariableItemList.SetItemCheckedState(checkedItem,true);
     155        foreach (var checkedItem in histoContent.VariableItemList) {
     156          if (checkedItem.Value == variableName)
     157            histoContent.VariableItemList.SetItemCheckedState(checkedItem, true);
    167158          else
    168             histoContent.VariableItemList.SetItemCheckedState(checkedItem,false);
    169            
     159            histoContent.VariableItemList.SetItemCheckedState(checkedItem, false);
     160
    170161        }
    171162      }
     
    174165    //open histogram in new tab with new content when double clicked
    175166    private void HistogramDoubleClick(object sender, EventArgs e) {
    176       //PreprocessingDataTableView pcv = (PreprocessingDataTableView)sender;
    177       //HistogramContent histoContent = new HistogramContent(Content,);  // create new content     
    178       //histoContent.VariableItemList = logic.CreateVariableItemList();
    179       //PreprocessingDataTable dataTable = pcv.Content;
    180       //setVariableItemListFromDataTable(histoContent, dataTable);
     167      PreprocessingDataTableView pcv = (PreprocessingDataTableView)sender;
     168      HistogramContent histoContent = new HistogramContent(Content.PreprocessingData);  // create new content     
     169      histoContent.VariableItemList = Content.CreateVariableItemList();
     170      PreprocessingDataTable dataTable = pcv.Content;
     171      setVariableItemListFromDataTable(histoContent, dataTable);
    181172
    182       //MainFormManager.MainForm.ShowContent(histoContent, typeof(HistogramView));  // open in new tab
     173      MainFormManager.MainForm.ShowContent(histoContent, typeof(HistogramView));  // open in new tab
    183174    }
    184    
     175
    185176
    186177  }
    187178
    188  
     179
    189180}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotSingleView.cs

    r10987 r10992  
    11using System;
    22using System.Collections.Generic;
    3 using System.ComponentModel;
    4 using System.Drawing;
    5 using System.Data;
    63using System.Linq;
    7 using System.Text;
    84using System.Windows.Forms;
    95using HeuristicLab.Analysis;
    10 using HeuristicLab.Analysis.Views;
    11 using HeuristicLab.Collections;
    12 using HeuristicLab.Core;
    136using HeuristicLab.Core.Views;
    14 using HeuristicLab.Data;
    15 using HeuristicLab.DataPreprocessing.Implementations;
    167using HeuristicLab.MainForm;
    178
     
    3324    public void InitData() {
    3425
    35       IEnumerable<string> variables = Content.GetVariableNames();
     26      IEnumerable<string> variables = Content.PreprocessingData.GetDoubleVariableNames();
    3627
    3728      // add variables to combo boxes
     
    8071  }
    8172
    82  
     73
    8374}
  • 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.