Changeset 12881
- Timestamp:
- 08/19/15 13:13:51 (9 years ago)
- Location:
- branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.Designer.cs
r12600 r12881 62 62 this.includeChildrenCheckBox = new System.Windows.Forms.CheckBox(); 63 63 this.sizeTrackBar = new System.Windows.Forms.TrackBar(); 64 this.yJitterLabel = new System.Windows.Forms.Label(); 65 this.xJitterLabel = new System.Windows.Forms.Label(); 66 this.yJitterTrackBar = new System.Windows.Forms.TrackBar(); 67 this.xJitterTrackBar = new System.Windows.Forms.TrackBar(); 64 68 ((System.ComponentModel.ISupportInitialize)(this.chart)).BeginInit(); 65 69 this.childrenGroupBox.SuspendLayout(); … … 70 74 ((System.ComponentModel.ISupportInitialize)(this.levelNumericUpDown)).BeginInit(); 71 75 ((System.ComponentModel.ISupportInitialize)(this.sizeTrackBar)).BeginInit(); 76 ((System.ComponentModel.ISupportInitialize)(this.yJitterTrackBar)).BeginInit(); 77 ((System.ComponentModel.ISupportInitialize)(this.xJitterTrackBar)).BeginInit(); 72 78 this.SuspendLayout(); 73 79 // … … 85 91 this.xLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 86 92 this.xLabel.AutoSize = true; 87 this.xLabel.Location = new System.Drawing.Point(7 25, 713);93 this.xLabel.Location = new System.Drawing.Point(700, 712); 88 94 this.xLabel.Name = "xLabel"; 89 95 this.xLabel.Size = new System.Drawing.Size(15, 13); … … 107 113 series1.YValuesPerPoint = 2; 108 114 this.chart.Series.Add(series1); 109 this.chart.Size = new System.Drawing.Size(96 5, 668);115 this.chart.Size = new System.Drawing.Size(966, 668); 110 116 this.chart.TabIndex = 7; 111 117 this.chart.AxisViewChanged += new System.EventHandler<System.Windows.Forms.DataVisualization.Charting.ViewEventArgs>(this.chart_AxisViewChanged); … … 117 123 this.yAxisComboBox.Location = new System.Drawing.Point(239, 2); 118 124 this.yAxisComboBox.Name = "yAxisComboBox"; 119 this.yAxisComboBox.Size = new System.Drawing.Size( 340, 21);125 this.yAxisComboBox.Size = new System.Drawing.Size(263, 21); 120 126 this.yAxisComboBox.TabIndex = 8; 121 127 this.yAxisComboBox.SelectedValueChanged += new System.EventHandler(this.axisComboBox_SelectedValueChanged); … … 126 132 this.xAxisComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 127 133 this.xAxisComboBox.FormattingEnabled = true; 128 this.xAxisComboBox.Location = new System.Drawing.Point(7 46, 710);134 this.xAxisComboBox.Location = new System.Drawing.Point(721, 709); 129 135 this.xAxisComboBox.Name = "xAxisComboBox"; 130 this.xAxisComboBox.Size = new System.Drawing.Size( 340, 21);136 this.xAxisComboBox.Size = new System.Drawing.Size(249, 21); 131 137 this.xAxisComboBox.TabIndex = 9; 132 138 this.xAxisComboBox.SelectedValueChanged += new System.EventHandler(this.axisComboBox_SelectedValueChanged); … … 140 146 this.treeView.Location = new System.Drawing.Point(6, 19); 141 147 this.treeView.Name = "treeView"; 142 this.treeView.Size = new System.Drawing.Size( 90, 643);148 this.treeView.Size = new System.Drawing.Size(89, 643); 143 149 this.treeView.TabIndex = 10; 144 150 this.treeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterCheck); … … 153 159 this.childrenGroupBox.Location = new System.Drawing.Point(3, 3); 154 160 this.childrenGroupBox.Name = "childrenGroupBox"; 155 this.childrenGroupBox.Size = new System.Drawing.Size(10 2, 668);161 this.childrenGroupBox.Size = new System.Drawing.Size(101, 668); 156 162 this.childrenGroupBox.TabIndex = 11; 157 163 this.childrenGroupBox.TabStop = false; … … 174 180 this.splitContainer.Panel2.Controls.Add(this.chart); 175 181 this.splitContainer.Size = new System.Drawing.Size(1083, 674); 176 this.splitContainer.SplitterDistance = 10 8;182 this.splitContainer.SplitterDistance = 107; 177 183 this.splitContainer.TabIndex = 12; 178 184 // … … 242 248 this.sizeTrackBar.ValueChanged += new System.EventHandler(this.sizeTrackBar_ValueChanged); 243 249 // 250 // yJitterLabel 251 // 252 this.yJitterLabel.AutoSize = true; 253 this.yJitterLabel.Location = new System.Drawing.Point(509, 6); 254 this.yJitterLabel.Name = "yJitterLabel"; 255 this.yJitterLabel.Size = new System.Drawing.Size(32, 13); 256 this.yJitterLabel.TabIndex = 19; 257 this.yJitterLabel.Text = "Jitter:"; 258 // 259 // xJitterLabel 260 // 261 this.xJitterLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 262 this.xJitterLabel.AutoSize = true; 263 this.xJitterLabel.Location = new System.Drawing.Point(977, 712); 264 this.xJitterLabel.Name = "xJitterLabel"; 265 this.xJitterLabel.Size = new System.Drawing.Size(32, 13); 266 this.xJitterLabel.TabIndex = 20; 267 this.xJitterLabel.Text = "Jitter:"; 268 // 269 // yJitterTrackBar 270 // 271 this.yJitterTrackBar.Enabled = false; 272 this.yJitterTrackBar.Location = new System.Drawing.Point(547, 2); 273 this.yJitterTrackBar.Maximum = 100; 274 this.yJitterTrackBar.Name = "yJitterTrackBar"; 275 this.yJitterTrackBar.Size = new System.Drawing.Size(65, 45); 276 this.yJitterTrackBar.TabIndex = 21; 277 this.yJitterTrackBar.TickStyle = System.Windows.Forms.TickStyle.None; 278 this.yJitterTrackBar.ValueChanged += new System.EventHandler(this.jitterTrackBar_ValueChanged); 279 // 280 // xJitterTrackBar 281 // 282 this.xJitterTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 283 this.xJitterTrackBar.Enabled = false; 284 this.xJitterTrackBar.Location = new System.Drawing.Point(1019, 707); 285 this.xJitterTrackBar.Maximum = 100; 286 this.xJitterTrackBar.Name = "xJitterTrackBar"; 287 this.xJitterTrackBar.Size = new System.Drawing.Size(65, 45); 288 this.xJitterTrackBar.TabIndex = 22; 289 this.xJitterTrackBar.TickStyle = System.Windows.Forms.TickStyle.None; 290 this.xJitterTrackBar.ValueChanged += new System.EventHandler(this.jitterTrackBar_ValueChanged); 291 // 244 292 // BubbleChartView 245 293 // … … 248 296 this.BackColor = System.Drawing.SystemColors.Window; 249 297 this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 298 this.Controls.Add(this.xJitterTrackBar); 299 this.Controls.Add(this.yJitterTrackBar); 300 this.Controls.Add(this.xJitterLabel); 301 this.Controls.Add(this.yJitterLabel); 250 302 this.Controls.Add(this.sizeTrackBar); 251 303 this.Controls.Add(this.includeChildrenCheckBox); … … 269 321 ((System.ComponentModel.ISupportInitialize)(this.levelNumericUpDown)).EndInit(); 270 322 ((System.ComponentModel.ISupportInitialize)(this.sizeTrackBar)).EndInit(); 323 ((System.ComponentModel.ISupportInitialize)(this.yJitterTrackBar)).EndInit(); 324 ((System.ComponentModel.ISupportInitialize)(this.xJitterTrackBar)).EndInit(); 271 325 this.ResumeLayout(false); 272 326 this.PerformLayout(); … … 290 344 private System.Windows.Forms.CheckBox includeChildrenCheckBox; 291 345 private System.Windows.Forms.TrackBar sizeTrackBar; 346 private System.Windows.Forms.Label yJitterLabel; 347 private System.Windows.Forms.Label xJitterLabel; 348 private System.Windows.Forms.TrackBar yJitterTrackBar; 349 private System.Windows.Forms.TrackBar xJitterTrackBar; 292 350 } 293 351 } -
branches/BubbleChart/HeuristicLab.Optimization.BubbleChart/3.3/BubbleChartView.cs
r12880 r12881 21 21 22 22 using System; 23 using System.Collections;24 23 using System.Collections.Generic; 25 24 using System.Linq; … … 44 43 private readonly Dictionary<string, Dictionary<object, double>> categoricalMapping = new Dictionary<string, Dictionary<object, double>>(); 45 44 45 private readonly Dictionary<RecursiveDataItem, double> xJitter = new Dictionary<RecursiveDataItem, double>(); 46 private readonly Dictionary<RecursiveDataItem, double> yJitter = new Dictionary<RecursiveDataItem, double>(); 47 private readonly Random random = new Random(); 48 49 46 50 private string XAxisValue { get { return (string)xAxisComboBox.SelectedItem; } } 47 51 private string YAxisValue { get { return (string)yAxisComboBox.SelectedItem; } } … … 49 53 50 54 private bool updating = false; 55 56 private double xJitterFactor = 0.0; 57 private double yJitterFactor = 0.0; 51 58 52 59 public new RecursiveDataItem Content { … … 78 85 base.SetEnabledStateOfControls(); 79 86 levelNumericUpDown.Enabled = Content != null; 80 // ToDo 87 xJitterTrackBar.Enabled = Content != null; 88 yJitterTrackBar.Enabled = Content != null; 89 xAxisComboBox.Enabled = Content != null; 90 yAxisComboBox.Enabled = Content != null; 81 91 } 82 92 … … 200 210 AddPoints(xss[i], yss[j], series); 201 211 } 202 } 203 void AddPoints(double[] xs, double[] ys, Series series) { 204 if (xs.Length != ys.Length) return; 205 for (int k = 0; k < xs.Length; k++) { 206 series.Points.Add(new DataPoint(xs[k], new[] { ys[k], 1.0 })); 207 } 208 } 209 210 private List<double[]> GetValues(string key) { 211 var collector = new List<double[]>(); 212 213 xJitterTrackBar.Value = 0; 214 yJitterTrackBar.Value = 0; 215 216 //needed to set axis back to automatic and refresh them, otherwise their values may remain NaN 217 var xAxis = chart.ChartAreas[0].AxisX; 218 var yAxis = chart.ChartAreas[0].AxisY; 219 SetAutomaticUpdateOfAxis(xAxis, true); 220 SetAutomaticUpdateOfAxis(yAxis, true); 221 chart.Refresh(); 222 } 223 void AddPoints(Tuple<double[], RecursiveDataItem> xs, Tuple<double[], RecursiveDataItem> ys, Series series) { 224 if (xs.Item1.Length != ys.Item1.Length) return; 225 for (int k = 0; k < xs.Item1.Length; k++) { 226 series.Points.Add(new DataPoint(xs.Item1[k], new[] { ys.Item1[k], 1.0 }) { 227 Tag = Tuple.Create(xs.Item1[k], ys.Item1[k], xs.Item2, ys.Item2) 228 }); 229 } 230 } 231 232 private List<Tuple<double[], RecursiveDataItem>> GetValues(string key) { 233 var collector = new List<Tuple<double[], RecursiveDataItem>>(); 212 234 GetValues(Content, key, collector); 213 235 return collector; 214 236 } 215 private void GetValues(RecursiveDataItem node, string key, List< double[]> collector) {237 private void GetValues(RecursiveDataItem node, string key, List<Tuple<double[], RecursiveDataItem>> collector) { 216 238 IItem item; 217 239 if (node.Data.TryGetValue(key, out item)) { 218 240 var value = ConvertToDoubles(node, key); 219 collector.Add( value);241 collector.Add(Tuple.Create(value, node)); 220 242 } 221 243 … … 437 459 } 438 460 } 461 462 private void UpdateDataPointJitter() { 463 var xAxis = this.chart.ChartAreas[0].AxisX; 464 var yAxis = this.chart.ChartAreas[0].AxisY; 465 466 double xAxisRange = xAxis.Maximum - xAxis.Minimum; 467 double yAxisRange = yAxis.Maximum - yAxis.Minimum; 468 469 foreach (DataPoint point in chart.Series[0].Points) { 470 var tag = (Tuple<double, double, RecursiveDataItem, RecursiveDataItem>)point.Tag; 471 var xItem = tag.Item3; 472 var yItem = tag.Item4; 473 double xValue = tag.Item1; 474 double yValue = tag.Item2; 475 476 if (!xJitterFactor.IsAlmost(0.0)) 477 xValue += 0.1 * GetXJitter(xItem) * xJitterFactor * (xAxisRange); 478 if (!yJitterFactor.IsAlmost(0.0)) 479 yValue += 0.1 * GetYJitter(yItem) * yJitterFactor * (yAxisRange); 480 481 point.XValue = xValue; 482 point.YValues[0] = yValue; 483 } 484 485 if (xJitterFactor.IsAlmost(0.0) && yJitterFactor.IsAlmost(0.0)) { 486 SetAutomaticUpdateOfAxis(xAxis, true); 487 SetAutomaticUpdateOfAxis(yAxis, true); 488 chart.ChartAreas[0].RecalculateAxesScale(); 489 } else { 490 SetAutomaticUpdateOfAxis(xAxis, false); 491 SetAutomaticUpdateOfAxis(yAxis, false); 492 } 493 } 494 private double GetXJitter(RecursiveDataItem item) { 495 if (!this.xJitter.ContainsKey(item)) 496 this.xJitter[item] = random.NextDouble() * 2.0 - 1.0; 497 return this.xJitter[item]; 498 } 499 private double GetYJitter(RecursiveDataItem item) { 500 if (!this.yJitter.ContainsKey(item)) 501 this.yJitter[item] = random.NextDouble() * 2.0 - 1.0; 502 return this.yJitter[item]; 503 } 504 505 // sets an axis to automatic or restrains it to its current values 506 // this is used that none of the set values is changed when jitter is applied, so that the chart stays the same 507 private void SetAutomaticUpdateOfAxis(Axis axis, bool enabled) { 508 if (enabled) { 509 axis.Maximum = double.NaN; 510 axis.Minimum = double.NaN; 511 axis.MajorGrid.Interval = double.NaN; 512 axis.MajorTickMark.Interval = double.NaN; 513 axis.LabelStyle.Interval = double.NaN; 514 } else { 515 axis.Minimum = axis.Minimum; 516 axis.Maximum = axis.Maximum; 517 axis.MajorGrid.Interval = axis.MajorGrid.Interval; 518 axis.MajorTickMark.Interval = axis.MajorTickMark.Interval; 519 axis.LabelStyle.Interval = axis.LabelStyle.Interval; 520 } 521 } 439 522 #endregion 440 523 … … 480 563 UpdateMarkerSizes(); 481 564 } 565 566 private void jitterTrackBar_ValueChanged(object sender, EventArgs e) { 567 this.xJitterFactor = xJitterTrackBar.Value / 100.0; 568 this.yJitterFactor = yJitterTrackBar.Value / 100.0; 569 UpdateDataPointJitter(); 570 } 482 571 #endregion 483 572
Note: See TracChangeset
for help on using the changeset viewer.