Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/06/09 21:54:04 (15 years ago)
Author:
gkronber
Message:

Implemented filtering of result entries in bubble chart and table view. #691 (CEDMA result views should allow filtering of displayed results)

Location:
trunk/sources/HeuristicLab.CEDMA.Charting/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Charting/3.3/BubbleChart.cs

    r2137 r2139  
    5656    private double maxX = double.NegativeInfinity;
    5757    private double maxY = double.NegativeInfinity;
    58     private List<ResultsEntry> records;
     58    private List<ResultsEntry> filteredEntries;
    5959    private Results results;
    6060    private Dictionary<IPrimitive, ResultsEntry> primitiveToEntryDictionary;
     
    6464    public BubbleChart(Results results, PointD lowerLeft, PointD upperRight)
    6565      : base(lowerLeft, upperRight) {
    66       records = new List<ResultsEntry>();
     66      //      records = new List<ResultsEntry>();
    6767      primitiveToEntryDictionary = new Dictionary<IPrimitive, ResultsEntry>();
    6868      this.results = results;
     69      filteredEntries = new List<ResultsEntry>();
    6970
    7071      foreach (var resultsEntry in results.GetEntries()) {
     
    7374        if (resultsEntry.Get(Y_JITTER) == null)
    7475          resultsEntry.Set(Y_JITTER, random.NextDouble() * 2.0 - 1.0);
    75         records.Add(resultsEntry);
     76        //        records.Add(resultsEntry);
    7677      }
    7778
     
    123124      double minSize = 1;
    124125      if (sizeDimension != null && results.OrdinalVariables.Contains(sizeDimension)) {
    125         var sizes = records
     126        var sizes = results.GetEntries()
    126127          .Select(x => Convert.ToDouble(x.Get(sizeDimension)))
    127128          .Where(size => !double.IsInfinity(size) && size != double.MaxValue && size != double.MinValue)
     
    139140      Group.Add(new Axis(this, 0, 0, AxisType.Both));
    140141      UpdateViewSize(0, 0, 5);
    141       foreach (ResultsEntry r in records) {
     142      foreach (ResultsEntry r in results.GetEntries().Where(x => x.Visible)) {
    142143        List<double> xs = new List<double>();
    143144        List<double> ys = new List<double>();
     
    145146        List<object> actualYValues = new List<object>();
    146147        int size;
    147         if (results.OrdinalVariables.Contains(xDimension)) {
     148        if (results.OrdinalVariables.Contains(xDimension) && r.Get(xDimension) != null) {
    148149          xs.Add(Convert.ToDouble(r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor);
    149150          actualXValues.Add(r.Get(xDimension));
    150         } else if (results.CategoricalVariables.Contains(xDimension)) {
     151        } else if (results.CategoricalVariables.Contains(xDimension) && r.Get(xDimension) != null) {
    151152          xs.Add(results.IndexOfCategoricalValue(xDimension, r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor);
    152153          actualXValues.Add(r.Get(xDimension));
     
    155156          IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
    156157          foreach (ResultsEntry subEntry in subEntries) {
    157             xs.Add(results.IndexOfCategoricalValue(xDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor);
    158             actualXValues.Add(subEntry.Get(path.ElementAt(1)));
     158            if (subEntry.Get(path.ElementAt(1)) != null) {
     159              xs.Add(results.IndexOfCategoricalValue(xDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor);
     160              actualXValues.Add(subEntry.Get(path.ElementAt(1)));
     161            }
    159162          }
    160163        } else if (results.MultiDimensionalOrdinalVariables.Contains(xDimension)) {
     
    162165          IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
    163166          foreach (ResultsEntry subEntry in subEntries) {
    164             xs.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor);
    165             actualXValues.Add(subEntry.Get(path.ElementAt(1)));
    166           }
    167         }
    168         if (results.OrdinalVariables.Contains(yDimension)) {
     167            if (subEntry.Get(path.ElementAt(1)) != null) {
     168              xs.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor);
     169              actualXValues.Add(subEntry.Get(path.ElementAt(1)));
     170            }
     171          }
     172        }
     173        if (results.OrdinalVariables.Contains(yDimension) && r.Get(yDimension) != null) {
    169174          ys.Add(Convert.ToDouble(r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor);
    170175          actualYValues.Add(r.Get(yDimension));
    171         } else if (results.CategoricalVariables.Contains(yDimension)) {
     176        } else if (results.CategoricalVariables.Contains(yDimension) && r.Get(yDimension) != null) {
    172177          ys.Add(results.IndexOfCategoricalValue(yDimension, r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor);
    173178          actualYValues.Add(r.Get(yDimension));
     
    176181          IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
    177182          foreach (ResultsEntry subEntry in subEntries) {
    178             ys.Add(results.IndexOfCategoricalValue(yDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor);
    179             actualYValues.Add(subEntry.Get(path.ElementAt(1)));
     183            if (subEntry.Get(path.ElementAt(1)) != null) {
     184              ys.Add(results.IndexOfCategoricalValue(yDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor);
     185              actualYValues.Add(subEntry.Get(path.ElementAt(1)));
     186            }
    180187          }
    181188        } else if (results.MultiDimensionalOrdinalVariables.Contains(yDimension)) {
     
    183190          IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
    184191          foreach (ResultsEntry subEntry in subEntries) {
    185             ys.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor);
    186             actualYValues.Add(subEntry.Get(path.ElementAt(1)));
     192            if (subEntry.Get(path.ElementAt(1)) != null) {
     193              ys.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor);
     194              actualYValues.Add(subEntry.Get(path.ElementAt(1)));
     195            }
    187196          }
    188197        }
     
    324333      }
    325334    }
     335
     336    internal void ToggleSelected() {
     337      foreach (ResultsEntry entry in results.GetEntries()) {
     338        entry.ToggleSelected();
     339      }
     340      results.FireChanged();
     341    }
     342
     343    internal void ClearSelection() {
     344      foreach (ResultsEntry entry in results.GetEntries().Where(x=>x.Selected)) {
     345        entry.ToggleSelected();
     346      }
     347      results.FireChanged();
     348    }
     349
     350    internal void ApplyFilter(Func<ResultsEntry, bool> filterPred) {
     351      foreach (ResultsEntry r in results.GetEntries()) {
     352        if (filterPred(r)) {
     353          r.Visible = false;
     354          r.Selected = false;
     355          filteredEntries.Add(r);
     356        }
     357      }
     358      results.FireChanged();
     359    }
     360
     361    internal void ClearFilter() {
     362      foreach (ResultsEntry r in filteredEntries) {
     363        r.Visible = true;
     364      }
     365      filteredEntries.Clear();
     366      results.FireChanged();
     367    }
    326368  }
    327369}
  • trunk/sources/HeuristicLab.CEDMA.Charting/3.3/BubbleChartControl.Designer.cs

    r1529 r2139  
    5151      this.zoomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5252      this.selectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     53      this.invertSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     54      this.filterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5355      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     56      this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
     57      this.clearSelectionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     58      this.showHiddenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5459      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
    5560      this.pictureBoxContextMenuStrip.SuspendLayout();
     
    8287            this.moveToolStripMenuItem,
    8388            this.zoomToolStripMenuItem,
    84             this.selectToolStripMenuItem});
     89            this.selectToolStripMenuItem,
     90            this.toolStripSeparator1,
     91            this.clearSelectionMenuItem,
     92            this.invertSelectionToolStripMenuItem,
     93            this.filterToolStripMenuItem,
     94            this.showHiddenToolStripMenuItem});
    8595      this.pictureBoxContextMenuStrip.Name = "pictureBoxContextMenuStrip";
    86       this.pictureBoxContextMenuStrip.Size = new System.Drawing.Size(153, 92);
     96      this.pictureBoxContextMenuStrip.Size = new System.Drawing.Size(155, 186);
    8797      //
    8898      // moveToolStripMenuItem
    8999      //
    90100      this.moveToolStripMenuItem.Name = "moveToolStripMenuItem";
    91       this.moveToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     101      this.moveToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
    92102      this.moveToolStripMenuItem.Text = "Move";
    93103      this.moveToolStripMenuItem.Click += new System.EventHandler(this.moveToolStripMenuItem_Click);
     
    96106      //
    97107      this.zoomToolStripMenuItem.Name = "zoomToolStripMenuItem";
    98       this.zoomToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     108      this.zoomToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
    99109      this.zoomToolStripMenuItem.Text = "&Zoom";
    100110      this.zoomToolStripMenuItem.Click += new System.EventHandler(this.zoomToolStripMenuItem_Click);
     
    103113      //
    104114      this.selectToolStripMenuItem.Name = "selectToolStripMenuItem";
    105       this.selectToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
     115      this.selectToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
    106116      this.selectToolStripMenuItem.Text = "&Select";
    107117      this.selectToolStripMenuItem.Click += new System.EventHandler(this.selectToolStripMenuItem_Click);
     118      //
     119      // invertSelectionToolStripMenuItem
     120      //
     121      this.invertSelectionToolStripMenuItem.Name = "invertSelectionToolStripMenuItem";
     122      this.invertSelectionToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
     123      this.invertSelectionToolStripMenuItem.Text = "Invert selection";
     124      this.invertSelectionToolStripMenuItem.Click += new System.EventHandler(this.invertSelectionToolStripMenuItem_Click);
     125      //
     126      // filterToolStripMenuItem
     127      //
     128      this.filterToolStripMenuItem.Name = "filterToolStripMenuItem";
     129      this.filterToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
     130      this.filterToolStripMenuItem.Text = "Hide selected";
     131      this.filterToolStripMenuItem.Click += new System.EventHandler(this.hideSelectedToolStripMenuItem_Click);
     132      //
     133      // toolStripSeparator1
     134      //
     135      this.toolStripSeparator1.Name = "toolStripSeparator1";
     136      this.toolStripSeparator1.Size = new System.Drawing.Size(151, 6);
     137      //
     138      // clearSelectionMenuItem
     139      //
     140      this.clearSelectionMenuItem.Name = "clearSelectionMenuItem";
     141      this.clearSelectionMenuItem.Size = new System.Drawing.Size(154, 22);
     142      this.clearSelectionMenuItem.Text = "Clear selection";
     143      this.clearSelectionMenuItem.Click += new System.EventHandler(this.clearSelectionMenuItem_Click);
     144      //
     145      // showHiddenToolStripMenuItem
     146      //
     147      this.showHiddenToolStripMenuItem.Enabled = false;
     148      this.showHiddenToolStripMenuItem.Name = "showHiddenToolStripMenuItem";
     149      this.showHiddenToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
     150      this.showHiddenToolStripMenuItem.Text = "Show hidden";
     151      this.showHiddenToolStripMenuItem.Click += new System.EventHandler(this.showHiddenToolStripMenuItem_Click);
    108152      //
    109153      // BubbleChartControl
     
    129173    protected System.Windows.Forms.ToolStripMenuItem selectToolStripMenuItem;
    130174    private System.Windows.Forms.ToolStripMenuItem moveToolStripMenuItem;
     175    private System.Windows.Forms.ToolStripMenuItem invertSelectionToolStripMenuItem;
     176    private System.Windows.Forms.ToolStripMenuItem filterToolStripMenuItem;
     177    private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
     178    private System.Windows.Forms.ToolStripMenuItem clearSelectionMenuItem;
     179    private System.Windows.Forms.ToolStripMenuItem showHiddenToolStripMenuItem;
    131180
    132181  }
  • trunk/sources/HeuristicLab.CEDMA.Charting/3.3/BubbleChartControl.cs

    r2132 r2139  
    177177      Chart.MouseDoubleClick(e.Location, e.Button);
    178178    }
     179
     180    private void invertSelectionToolStripMenuItem_Click(object sender, EventArgs e) {
     181      Chart.ToggleSelected();
     182    }
     183
     184    private void hideSelectedToolStripMenuItem_Click(object sender, EventArgs e) {
     185      showHiddenToolStripMenuItem.Enabled = true;
     186      Chart.ApplyFilter(x => x.Selected == true && x.Visible==true);
     187    }
     188
     189    private void clearSelectionMenuItem_Click(object sender, EventArgs e) {
     190      Chart.ClearSelection();
     191    }
     192
     193    private void showHiddenToolStripMenuItem_Click(object sender, EventArgs e) {
     194      Chart.ClearFilter();
     195      showHiddenToolStripMenuItem.Enabled = false;
     196    }
    179197  }
    180198}
Note: See TracChangeset for help on using the changeset viewer.