Changeset 8529


Ignore:
Timestamp:
08/27/12 17:59:55 (7 years ago)
Author:
sforsten
Message:

#1292:

  • BackgroundWorker is now reused in FeatureCorrelation
  • renamed some variables
  • ComboBoxes are now DropDownLists
  • FeatureCorrelation doesn't calculate the elements in the constructor anymore
  • small changes in the views
Location:
branches/DatasetFeatureCorrelation
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelationView.Designer.cs

    r8492 r8529  
    3535      this.PictureBox = new System.Windows.Forms.PictureBox();
    3636      this.SplitContainer = new System.Windows.Forms.SplitContainer();
     37      this.CalculatingPanel = new System.Windows.Forms.Panel();
     38      this.CalculatingLabel = new System.Windows.Forms.Label();
    3739      ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
    3840      ((System.ComponentModel.ISupportInitialize)(this.PictureBox)).BeginInit();
     
    4143      this.SplitContainer.Panel2.SuspendLayout();
    4244      this.SplitContainer.SuspendLayout();
     45      this.CalculatingPanel.SuspendLayout();
    4346      this.SuspendLayout();
    4447      //
     
    5558      this.DataGridView.TabIndex = 0;
    5659      this.DataGridView.VirtualMode = true;
     60      this.DataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.DataGridView_CellPainting);
    5761      this.DataGridView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.DataGridView_CellValueNeeded);
    5862      this.DataGridView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.DataGridView_ColumnHeaderMouseClick);
     
    6165      // HeatMapProgressBar
    6266      //
    63       this.HeatMapProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    64                   | System.Windows.Forms.AnchorStyles.Right)));
    65       this.HeatMapProgressBar.Location = new System.Drawing.Point(490, 6);
     67      this.HeatMapProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
     68      this.HeatMapProgressBar.Location = new System.Drawing.Point(25, 46);
    6669      this.HeatMapProgressBar.Name = "HeatMapProgressBar";
    6770      this.HeatMapProgressBar.RightToLeft = System.Windows.Forms.RightToLeft.No;
    68       this.HeatMapProgressBar.Size = new System.Drawing.Size(76, 21);
     71      this.HeatMapProgressBar.Size = new System.Drawing.Size(154, 21);
    6972      this.HeatMapProgressBar.TabIndex = 9;
    70       this.HeatMapProgressBar.Visible = false;
    7173      //
    7274      // PartitionComboBox
    7375      //
     76      this.PartitionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    7477      this.PartitionComboBox.FormattingEnabled = true;
    75       this.PartitionComboBox.Location = new System.Drawing.Point(348, 3);
     78      this.PartitionComboBox.Location = new System.Drawing.Point(333, 3);
    7679      this.PartitionComboBox.Name = "PartitionComboBox";
    77       this.PartitionComboBox.Size = new System.Drawing.Size(124, 21);
     80      this.PartitionComboBox.Size = new System.Drawing.Size(142, 21);
    7881      this.PartitionComboBox.TabIndex = 8;
    7982      this.PartitionComboBox.SelectedIndexChanged += new System.EventHandler(this.PartitionComboBox_SelectedIndexChanged);
     
    9093      // CorrelationCalcComboBox
    9194      //
     95      this.CorrelationCalcComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    9296      this.CorrelationCalcComboBox.FormattingEnabled = true;
    9397      this.CorrelationCalcComboBox.Location = new System.Drawing.Point(110, 3);
     
    121125      this.maximumLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    122126      this.maximumLabel.BackColor = System.Drawing.Color.Transparent;
    123       this.maximumLabel.Location = new System.Drawing.Point(487, 30);
     127      this.maximumLabel.Location = new System.Drawing.Point(487, 2);
    124128      this.maximumLabel.Name = "maximumLabel";
    125129      this.maximumLabel.Size = new System.Drawing.Size(73, 25);
     
    134138      this.PictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    135139      this.PictureBox.Image = ((System.Drawing.Image)(resources.GetObject("PictureBox.Image")));
    136       this.PictureBox.Location = new System.Drawing.Point(507, 58);
     140      this.PictureBox.Location = new System.Drawing.Point(507, 30);
    137141      this.PictureBox.Name = "PictureBox";
    138       this.PictureBox.Size = new System.Drawing.Size(35, 253);
     142      this.PictureBox.Size = new System.Drawing.Size(35, 281);
    139143      this.PictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
    140144      this.PictureBox.TabIndex = 15;
     
    161165      // SplitContainer.Panel2
    162166      //
     167      this.SplitContainer.Panel2.Controls.Add(this.CalculatingPanel);
    163168      this.SplitContainer.Panel2.Controls.Add(this.DataGridView);
    164169      this.SplitContainer.Size = new System.Drawing.Size(475, 330);
     
    166171      this.SplitContainer.TabIndex = 16;
    167172      //
     173      // CalculatingPanel
     174      //
     175      this.CalculatingPanel.Anchor = System.Windows.Forms.AnchorStyles.None;
     176      this.CalculatingPanel.Controls.Add(this.CalculatingLabel);
     177      this.CalculatingPanel.Controls.Add(this.HeatMapProgressBar);
     178      this.CalculatingPanel.Location = new System.Drawing.Point(138, 95);
     179      this.CalculatingPanel.Name = "CalculatingPanel";
     180      this.CalculatingPanel.Size = new System.Drawing.Size(200, 81);
     181      this.CalculatingPanel.TabIndex = 10;
     182      //
     183      // CalculatingLabel
     184      //
     185      this.CalculatingLabel.AutoSize = true;
     186      this.CalculatingLabel.Location = new System.Drawing.Point(42, 19);
     187      this.CalculatingLabel.Name = "CalculatingLabel";
     188      this.CalculatingLabel.Size = new System.Drawing.Size(120, 13);
     189      this.CalculatingLabel.TabIndex = 10;
     190      this.CalculatingLabel.Text = "Calculating correlation...";
     191      //
    168192      // FeatureCorrelationView
    169193      //
     
    172196      this.Controls.Add(this.SplitContainer);
    173197      this.Controls.Add(this.minimumLabel);
    174       this.Controls.Add(this.HeatMapProgressBar);
    175198      this.Controls.Add(this.PictureBox);
    176199      this.Controls.Add(this.maximumLabel);
     
    184207      ((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).EndInit();
    185208      this.SplitContainer.ResumeLayout(false);
     209      this.CalculatingPanel.ResumeLayout(false);
     210      this.CalculatingPanel.PerformLayout();
    186211      this.ResumeLayout(false);
    187212
     
    200225    protected System.Windows.Forms.PictureBox PictureBox;
    201226    protected System.Windows.Forms.SplitContainer SplitContainer;
     227    protected System.Windows.Forms.Panel CalculatingPanel;
     228    protected System.Windows.Forms.Label CalculatingLabel;
    202229
    203230  }
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelationView.cs

    r8492 r8529  
    6565
    6666    protected void Content_ProgressCalculation(object sender, ProgressChangedEventArgs e) {
    67       if (!HeatMapProgressBar.Visible && e.ProgressPercentage != HeatMapProgressBar.Maximum) {
    68         HeatMapProgressBar.Show();
     67      if (!CalculatingPanel.Visible && e.ProgressPercentage != HeatMapProgressBar.Maximum) {
     68        CalculatingPanel.Show();
    6969      } else if (e.ProgressPercentage == HeatMapProgressBar.Maximum) {
    70         HeatMapProgressBar.Hide();
     70        CalculatingPanel.Hide();
    7171      }
    7272      HeatMapProgressBar.Value = e.ProgressPercentage;
     
    7676      base.OnContentChanged();
    7777      if (Content != null) {
    78         UpdateDataGrid();
    7978        CorrelationCalcComboBox.DataSource = Content.CorrelationCalculators;
    8079        PartitionComboBox.DataSource = Content.Partitions;
     
    9493      string partition = (string)PartitionComboBox.SelectedItem;
    9594      if (calc != null && partition != null) {
     95        DataGridView.Columns.Clear();
    9696        DataGridView.Enabled = false;
    9797        Content.Recalculate(calc, partition);
     
    144144    }
    145145
    146     private void DataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {
     146    protected void DataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {
    147147      if (Content != null && DataGridView.Enabled && e.RowIndex < Content.Rows && e.ColumnIndex < Content.Columns) {
    148148        int rowIndex = virtualRowIndices[e.RowIndex];
    149149        e.Value = Content[rowIndex, e.ColumnIndex];
    150         DataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = GetDataPointColor(Content[rowIndex, e.ColumnIndex], Content.Minimum, Content.Maximum);
    151       }
     150      }
     151    }
     152
     153    protected void DataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
     154      if (Content != null && DataGridView.Enabled && e.RowIndex >= 0 && e.ColumnIndex >= 0 && e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) {
     155        int rowIndex = virtualRowIndices[e.RowIndex];
     156        e.CellStyle.BackColor = GetDataPointColor(Content[rowIndex, e.ColumnIndex], Content.Minimum, Content.Maximum);
     157      }
     158      e.Paint(e.CellBounds, e.PaintParts);
    152159    }
    153160
     
    158165      if (index < 0) index = 0;
    159166      return colors[index];
    160     }
    161 
    162     protected override void OnShown(ViewShownEventArgs e) {
    163       base.OnShown(e);
    164       CalculateCorrelation();
    165167    }
    166168
     
    204206      UpdateSortGlyph();
    205207      UpdateRowHeaders();
     208      DataGridView.Invalidate();
    206209    }
    207210
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeframeFeatureCorrelationView.Designer.cs

    r8492 r8529  
    3131      ((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).BeginInit();
    3232      this.SplitContainer.Panel1.SuspendLayout();
     33      this.SplitContainer.Panel2.SuspendLayout();
    3334      this.SplitContainer.SuspendLayout();
     35      this.CalculatingPanel.SuspendLayout();
    3436      this.SuspendLayout();
     37      //
     38      // PartitionComboBox
     39      //
     40      this.PartitionComboBox.Location = new System.Drawing.Point(344, 3);
     41      this.PartitionComboBox.Size = new System.Drawing.Size(131, 21);
    3542      //
    3643      // maximumLabel
    3744      //
    38       this.maximumLabel.Location = new System.Drawing.Point(487, 62);
     45      this.maximumLabel.Location = new System.Drawing.Point(487, 3);
    3946      //
    4047      // PictureBox
    4148      //
    42       this.PictureBox.Location = new System.Drawing.Point(506, 91);
    43       this.PictureBox.Size = new System.Drawing.Size(35, 220);
     49      this.PictureBox.Location = new System.Drawing.Point(506, 31);
     50      this.PictureBox.Size = new System.Drawing.Size(35, 280);
    4451      //
    4552      // SplitContainer
     
    5461      this.SplitContainer.SplitterDistance = 52;
    5562      //
     63      // CalculatingPanel
     64      //
     65      this.CalculatingPanel.Location = new System.Drawing.Point(138, 82);
     66      //
    5667      // VariableSelectionLabel
    5768      //
     
    6576      // VariableSelectionComboBox
    6677      //
     78      this.VariableSelectionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    6779      this.VariableSelectionComboBox.FormattingEnabled = true;
    6880      this.VariableSelectionComboBox.Location = new System.Drawing.Point(110, 30);
     
    8395      // TimeframeComboBox
    8496      //
     97      this.TimeframeComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    8598      this.TimeframeComboBox.FormattingEnabled = true;
    86       this.TimeframeComboBox.Location = new System.Drawing.Point(348, 30);
     99      this.TimeframeComboBox.Location = new System.Drawing.Point(344, 30);
    87100      this.TimeframeComboBox.Name = "TimeframeComboBox";
    88       this.TimeframeComboBox.Size = new System.Drawing.Size(124, 21);
     101      this.TimeframeComboBox.Size = new System.Drawing.Size(131, 21);
    89102      this.TimeframeComboBox.TabIndex = 19;
    90103      this.TimeframeComboBox.SelectedIndexChanged += new System.EventHandler(this.TimeframeComboBox_SelectedIndexChanged);
     
    98111      this.SplitContainer.Panel1.ResumeLayout(false);
    99112      this.SplitContainer.Panel1.PerformLayout();
     113      this.SplitContainer.Panel2.ResumeLayout(false);
    100114      ((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).EndInit();
    101115      this.SplitContainer.ResumeLayout(false);
     116      this.CalculatingPanel.ResumeLayout(false);
     117      this.CalculatingPanel.PerformLayout();
    102118      this.ResumeLayout(false);
    103119
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis.Views/3.4/TimeframeFeatureCorrelationView.cs

    r8492 r8529  
    5959      string variable = (string)VariableSelectionComboBox.SelectedItem;
    6060      if (calc != null && partition != null && variable != null) {
     61        DataGridView.Columns.Clear();
    6162        DataGridView.Enabled = false;
    6263        int frames = (int)TimeframeComboBox.SelectedItem;
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs

    r8483 r8529  
    3737    protected const string TrainingPartitionParameterName = "TrainingPartition";
    3838    protected const string TestPartitionParameterName = "TestPartition";
    39     protected const string DatasetHeatMapParameterName = "DatasetCorrelationHeatMap";
     39    protected const string DatasetCorrelationParameterName = "Dataset Correlation";
    4040
    4141    #region parameter properites
     
    5252      get { return (IFixedValueParameter<IntRange>)Parameters[TestPartitionParameterName]; }
    5353    }
    54     public IFixedValueParameter<FeatureCorrelation> DatasetHeatMapParameter {
    55       get { return (IFixedValueParameter<FeatureCorrelation>)Parameters[DatasetHeatMapParameterName]; }
     54    public IFixedValueParameter<FeatureCorrelation> DatasetCorrelationParameter {
     55      get { return (IFixedValueParameter<FeatureCorrelation>)Parameters[DatasetCorrelationParameterName]; }
    5656    }
    5757    #endregion
     
    7878      get { return TestPartitionParameter.Value; }
    7979    }
    80     public FeatureCorrelation DatasetHeatMap {
    81       get { return DatasetHeatMapParameter.Value; }
     80    public FeatureCorrelation DatasetCorrelation {
     81      get { return DatasetCorrelationParameter.Value; }
    8282    }
    8383
     
    119119      // BackwardsCompatibility3.3
    120120      #region Backwards compatible code, remove with 3.4
    121       if (!Parameters.ContainsKey(DatasetHeatMapParameterName)) {
    122         Parameters.Add(new FixedValueParameter<FeatureCorrelation>(DatasetHeatMapParameterName, "", new FeatureCorrelation()));
     121      if (!Parameters.ContainsKey(DatasetCorrelationParameterName)) {
     122        Parameters.Add(new FixedValueParameter<FeatureCorrelation>(DatasetCorrelationParameterName, "", new FeatureCorrelation()));
    123123      }
    124124      #endregion
    125       DatasetHeatMap.ProblemData = this;
     125      DatasetCorrelation.ProblemData = this;
    126126      RegisterEventHandlers();
    127127    }
     
    147147      Parameters.Add(new FixedValueParameter<IntRange>(TrainingPartitionParameterName, "", new IntRange(trainingPartitionStart, trainingPartitionEnd)));
    148148      Parameters.Add(new FixedValueParameter<IntRange>(TestPartitionParameterName, "", new IntRange(testPartitionStart, testPartitionEnd)));
    149       Parameters.Add(new FixedValueParameter<FeatureCorrelation>(DatasetHeatMapParameterName, "", new FeatureCorrelation(this)));
     149      Parameters.Add(new FixedValueParameter<FeatureCorrelation>(DatasetCorrelationParameterName, "", new FeatureCorrelation(this)));
    150150
    151151      ((ValueParameter<Dataset>)DatasetParameter).ReactOnValueToStringChangedAndValueItemImageChanged = false;
  • branches/DatasetFeatureCorrelation/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/FeatureCorrelation.cs

    r8492 r8529  
    6565
    6666    private BackgroundWorker bw;
     67    private BackgroundWorkerInfo bwInfo;
    6768
    6869    public FeatureCorrelation()
     
    8081      this.rowNames = problemData.Dataset.DoubleVariables.ToList();
    8182      sortableView = true;
    82 
    83       CalculateElements(problemData.Dataset);
    8483    }
    8584    protected FeatureCorrelation(FeatureCorrelation original, Cloner cloner)
     
    107106
    108107    private void CalculateElements(Dataset dataset, string calc, string partition, string variable = null, int frames = 0) {
    109       if (bw == null || bw.IsBusy) {
    110         if (bw != null) {
    111           bw.CancelAsync();
    112         }
     108      bwInfo = new BackgroundWorkerInfo { Dataset = dataset, Calculator = calc, Partition = partition, Variable = variable, Frames = frames };
     109      if (bw == null) {
    113110        bw = new BackgroundWorker();
    114111        bw.WorkerReportsProgress = true;
     
    118115        bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BwRunWorkerCompleted);
    119116      }
    120       bw.RunWorkerAsync(new BackgroundWorkerInfo { Dataset = dataset, Calculator = calc, Partition = partition, Variable = variable, Frames = frames });
     117      if (bw.IsBusy) {
     118        bw.CancelAsync();
     119      } else {
     120        bw.RunWorkerAsync(bwInfo);
     121      }
    121122      if (calc.Equals(PearsonsR) || calc.Equals(SpearmansRank)) {
    122123        Maximum = 1.0;
     
    256257          OnCorrelationCalculationFinished();
    257258        }
     259      } else {
     260        bw.RunWorkerAsync(bwInfo);
    258261      }
    259262    }
Note: See TracChangeset for help on using the changeset viewer.