- Timestamp:
- 07/04/16 23:43:46 (8 years ago)
- Location:
- branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.Designer.cs
r13855 r13995 42 42 // 43 43 this.calculationPendingLabel.BackColor = System.Drawing.Color.White; 44 this.calculationPendingLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Timer;44 this.calculationPendingLabel.Image = ((System.Drawing.Image)(resources.GetObject("calculationPendingLabel.Image"))); 45 45 this.calculationPendingLabel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 46 46 this.calculationPendingLabel.Location = new System.Drawing.Point(3, 3); … … 66 66 verticalLineAnnotation1.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash; 67 67 verticalLineAnnotation1.Name = "VerticalLineAnnotation"; 68 verticalLineAnnotation1.YAxisName = "ChartArea 1\\rY";68 verticalLineAnnotation1.YAxisName = "ChartArea\\rY"; 69 69 this.chart.Annotations.Add(verticalLineAnnotation1); 70 70 stripLine1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(223)))), ((int)(((byte)(58)))), ((int)(((byte)(2))))); … … 97 97 this.configurationButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 98 98 this.configurationButton.AutoSize = true; 99 this.configurationButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Properties;99 this.configurationButton.Image = ((System.Drawing.Image)(resources.GetObject("configurationButton.Image"))); 100 100 this.configurationButton.Location = new System.Drawing.Point(426, 3); 101 101 this.configurationButton.Name = "configurationButton"; -
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/GradientChart.cs
r13855 r13995 116 116 if ((value.HasValue && fixedYAxisMin.HasValue && !value.Value.IsAlmost(fixedYAxisMin.Value)) || (value.HasValue != fixedYAxisMin.HasValue)) { 117 117 fixedYAxisMin = value; 118 SetupAxis(chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 118 // the check below prevents an exception when yMin >= yMax 119 if (yMin < yMax) 120 SetupAxis(chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 119 121 } 120 122 } … … 126 128 if ((value.HasValue && fixedYAxisMax.HasValue && !value.Value.IsAlmost(fixedYAxisMax.Value)) || (value.HasValue != fixedYAxisMax.HasValue)) { 127 129 fixedYAxisMax = value; 128 SetupAxis(chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 130 // the check below prevents an exception when yMin >= yMax 131 if (yMin < yMax) 132 SetupAxis(chart.ChartAreas[0].AxisY, yMin, yMax, YAxisTicks, FixedYAxisMin, FixedYAxisMax); 129 133 } 130 134 } … … 258 262 259 263 // Set cursor and x-axis 264 // Make sure to allow a small offset to be able to distinguish the vertical line annotation from the axis 260 265 var defaultValue = sharedFixedVariables.GetDoubleValue(freeVariable, 0); 261 VerticalLineAnnotation.X = defaultValue; 266 var step = (trainingMax - trainingMin) / drawingSteps; 267 var minimum = chart.ChartAreas[0].AxisX.Minimum; 268 var maximum = chart.ChartAreas[0].AxisX.Maximum; 269 if (defaultValue.IsAlmost(minimum)) 270 VerticalLineAnnotation.X = minimum + step; 271 else if (defaultValue.IsAlmost(maximum)) 272 VerticalLineAnnotation.X = maximum - step; 273 else 274 VerticalLineAnnotation.X = defaultValue; 275 262 276 if (ShowCursor) 263 277 chart.ChartAreas[0].AxisX.Title = FreeVariable + " : " + defaultValue.ToString("N3", CultureInfo.CurrentCulture); … … 379 393 if (ciSeriesCache.TryGetValue(solution, out ciSeries)) { 380 394 var series = seriesCache[solution]; 381 ciSeries.Color = 395 ciSeries.Color = Color.FromArgb(40, series.Color); 382 396 int idx = chart.Series.IndexOf(seriesCache[solution]); 383 397 chart.Series.Insert(idx, ciSeries); … … 484 498 485 499 await RecalculateAsync(); 486 } 500 var args = new EventArgs<IRegressionSolution>(solution); 501 OnSolutionAdded(this, args); 502 } 503 487 504 public async Task RemoveSolutionAsync(IRegressionSolution solution) { 488 505 if (!solutions.Remove(solution)) … … 495 512 496 513 await RecalculateAsync(); 514 var args = new EventArgs<IRegressionSolution>(solution); 515 OnSolutionRemoved(this, args); 497 516 } 498 517 … … 524 543 525 544 #region Events 545 public event EventHandler<EventArgs<IRegressionSolution>> SolutionAdded; 546 public void OnSolutionAdded(object sender, EventArgs<IRegressionSolution> args) { 547 var added = SolutionAdded; 548 if (added == null) return; 549 added(sender, args); 550 } 551 552 public event EventHandler<EventArgs<IRegressionSolution>> SolutionRemoved; 553 public void OnSolutionRemoved(object sender, EventArgs<IRegressionSolution> args) { 554 var removed = SolutionRemoved; 555 if (removed == null) return; 556 removed(sender, args); 557 } 558 526 559 public event EventHandler VariableValueChanged; 527 560 public void OnVariableValueChanged(object sender, EventArgs args) { … … 544 577 } 545 578 546 private double oldCurserPosition = double.NaN;547 579 private void chart_AnnotationPositionChanging(object sender, AnnotationPositionChangingEventArgs e) { 548 580 var step = (trainingMax - trainingMin) / drawingSteps; 549 581 double newLocation = step * (long)Math.Round(e.NewLocationX / step); 550 582 var axisX = chart.ChartAreas[0].AxisX; 551 if (newLocation > axisX.Maximum) 552 newLocation = axisX.Maximum; 553 if (newLocation < axisX.Minimum) 554 newLocation = axisX.Minimum; 555 556 if (oldCurserPosition.IsAlmost(newLocation)) 557 return; 583 if (newLocation >= axisX.Maximum) 584 newLocation = axisX.Maximum - step; 585 if (newLocation <= axisX.Minimum) 586 newLocation = axisX.Minimum + step; 558 587 559 588 e.NewLocationX = newLocation; 560 oldCurserPosition = e.NewLocationX;561 562 589 var annotation = VerticalLineAnnotation; 563 590 var x = annotation.X; -
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionTargetResponseGradientView.Designer.cs
r13853 r13995 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 this.components = new System.ComponentModel.Container(); 26 27 this.variableListView = new System.Windows.Forms.ListView(); 27 28 this.gradientChartTableLayout = new System.Windows.Forms.TableLayoutPanel(); … … 33 34 this.configSplitContainer = new System.Windows.Forms.SplitContainer(); 34 35 this.variableGroupBox = new System.Windows.Forms.GroupBox(); 36 this.layoutGroupBox = new System.Windows.Forms.GroupBox(); 37 this.columnsTextBox = new System.Windows.Forms.TextBox(); 38 this.columnsLabel = new System.Windows.Forms.Label(); 35 39 this.scrollPanel = new System.Windows.Forms.Panel(); 40 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 36 41 this.yAxisConfigGroupBox.SuspendLayout(); 37 42 this.densityGroupBox.SuspendLayout(); … … 41 46 this.configSplitContainer.SuspendLayout(); 42 47 this.variableGroupBox.SuspendLayout(); 48 this.layoutGroupBox.SuspendLayout(); 43 49 this.scrollPanel.SuspendLayout(); 50 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 44 51 this.SuspendLayout(); 45 52 // … … 50 57 this.variableListView.Location = new System.Drawing.Point(3, 16); 51 58 this.variableListView.Name = "variableListView"; 52 this.variableListView.Size = new System.Drawing.Size(163, 503);59 this.variableListView.Size = new System.Drawing.Size(163, 458); 53 60 this.variableListView.TabIndex = 0; 54 61 this.variableListView.UseCompatibleStateImageBehavior = false; … … 142 149 // 143 150 this.configSplitContainer.Panel1.Controls.Add(this.variableGroupBox); 151 this.configSplitContainer.Panel1.Controls.Add(this.layoutGroupBox); 144 152 this.configSplitContainer.Panel1.Controls.Add(this.densityGroupBox); 145 153 this.configSplitContainer.Panel1.Controls.Add(this.yAxisConfigGroupBox); … … 156 164 this.variableGroupBox.Controls.Add(this.variableListView); 157 165 this.variableGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; 158 this.variableGroupBox.Location = new System.Drawing.Point(0, 1 26);166 this.variableGroupBox.Location = new System.Drawing.Point(0, 171); 159 167 this.variableGroupBox.Name = "variableGroupBox"; 160 this.variableGroupBox.Size = new System.Drawing.Size(169, 522);168 this.variableGroupBox.Size = new System.Drawing.Size(169, 477); 161 169 this.variableGroupBox.TabIndex = 1; 162 170 this.variableGroupBox.TabStop = false; 163 171 this.variableGroupBox.Text = "Variables"; 172 // 173 // layoutGroupBox 174 // 175 this.layoutGroupBox.Controls.Add(this.columnsTextBox); 176 this.layoutGroupBox.Controls.Add(this.columnsLabel); 177 this.layoutGroupBox.Dock = System.Windows.Forms.DockStyle.Top; 178 this.layoutGroupBox.Location = new System.Drawing.Point(0, 126); 179 this.layoutGroupBox.Name = "layoutGroupBox"; 180 this.layoutGroupBox.Size = new System.Drawing.Size(169, 45); 181 this.layoutGroupBox.TabIndex = 5; 182 this.layoutGroupBox.TabStop = false; 183 this.layoutGroupBox.Text = "Layout"; 184 // 185 // columnsTextBox 186 // 187 this.columnsTextBox.Location = new System.Drawing.Point(66, 17); 188 this.columnsTextBox.Name = "columnsTextBox"; 189 this.columnsTextBox.Size = new System.Drawing.Size(94, 20); 190 this.columnsTextBox.TabIndex = 1; 191 this.columnsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.columnsTextBox_Validating); 192 this.columnsTextBox.Validated += new System.EventHandler(this.columnsTextBox_Validated); 193 // 194 // columnsLabel 195 // 196 this.columnsLabel.AutoSize = true; 197 this.columnsLabel.Location = new System.Drawing.Point(7, 20); 198 this.columnsLabel.Name = "columnsLabel"; 199 this.columnsLabel.Size = new System.Drawing.Size(50, 13); 200 this.columnsLabel.TabIndex = 0; 201 this.columnsLabel.Text = "Columns:"; 164 202 // 165 203 // scrollPanel … … 171 209 this.scrollPanel.Size = new System.Drawing.Size(542, 648); 172 210 this.scrollPanel.TabIndex = 0; 211 // 212 // errorProvider 213 // 214 this.errorProvider.ContainerControl = this; 173 215 // 174 216 // RegressionSolutionTargetResponseGradientView … … 187 229 this.configSplitContainer.ResumeLayout(false); 188 230 this.variableGroupBox.ResumeLayout(false); 231 this.layoutGroupBox.ResumeLayout(false); 232 this.layoutGroupBox.PerformLayout(); 189 233 this.scrollPanel.ResumeLayout(false); 190 234 this.scrollPanel.PerformLayout(); 235 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 191 236 this.ResumeLayout(false); 192 237 … … 205 250 private System.Windows.Forms.GroupBox variableGroupBox; 206 251 private System.Windows.Forms.Panel scrollPanel; 252 private System.Windows.Forms.GroupBox layoutGroupBox; 253 private System.Windows.Forms.TextBox columnsTextBox; 254 private System.Windows.Forms.Label columnsLabel; 255 private System.Windows.Forms.ErrorProvider errorProvider; 207 256 } 208 257 } -
branches/HeuristicLab.RegressionSolutionGradientView/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionTargetResponseGradientView.cs
r13948 r13995 39 39 40 40 private const int Points = 200; 41 private constint MaxColumns = 4;41 private int MaxColumns = 4; 42 42 43 43 private IEnumerable<string> VisibleVariables { … … 66 66 densityComboBox.SelectedIndex = 0; // select None 67 67 68 columnsTextBox.Text = "4"; 69 68 70 // Avoid additional horizontal scrollbar 69 71 var vertScrollWidth = SystemInformation.VerticalScrollBarWidth; … … 82 84 limitView.Content.ValueChanged += limit_ValueChanged; 83 85 automaticYAxisCheckBox.CheckedChanged += automaticYAxisCheckBox_CheckedChanged; 86 Content.ModelChanged += solution_ModelChanged; 84 87 } 85 88 … … 88 91 limitView.Content.ValueChanged -= limit_ValueChanged; 89 92 automaticYAxisCheckBox.CheckedChanged -= automaticYAxisCheckBox_CheckedChanged; 93 Content.ModelChanged -= solution_ModelChanged; 90 94 base.DeregisterContentEvents(); 91 95 } … … 171 175 }; 172 176 gradientChart.Configure(new[] { Content }, sharedFixedVariables, variableName, Points); 173 177 gradientChart.SolutionAdded += gradientChart_SolutionAdded; 178 gradientChart.SolutionRemoved += gradientChart_SolutionRemoved; 174 179 return gradientChart; 175 180 } … … 214 219 } 215 220 221 private void SetStyles() { 222 var tl = gradientChartTableLayout; 223 tl.RowStyles.Clear(); 224 tl.ColumnStyles.Clear(); 225 int numVariables = VisibleVariables.Count(); 226 if (numVariables == 0) 227 return; 228 229 // set column styles 230 tl.ColumnCount = Math.Min(numVariables, MaxColumns); 231 for (int c = 0; c < tl.ColumnCount; c++) 232 tl.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100.0f / tl.ColumnCount)); 233 234 // set row styles 235 tl.RowCount = (int)Math.Ceiling((double)numVariables / tl.ColumnCount); 236 var columnWidth = tl.Width / tl.ColumnCount; // assume all columns have the same width 237 var rowHeight = (int)(0.8 * columnWidth); 238 for (int r = 0; r < tl.RowCount; r++) 239 tl.RowStyles.Add(new RowStyle(SizeType.Absolute, rowHeight)); 240 } 241 242 private async void gradientChart_SolutionAdded(object sender, EventArgs<IRegressionSolution> e) { 243 var solution = e.Value; 244 foreach (var chart in gradientCharts.Values) { 245 if (sender == chart) continue; 246 await chart.AddSolutionAsync(solution); 247 } 248 } 249 250 private async void gradientChart_SolutionRemoved(object sender, EventArgs<IRegressionSolution> e) { 251 var solution = e.Value; 252 foreach (var chart in gradientCharts.Values) { 253 if (sender == chart) continue; 254 await chart.RemoveSolutionAsync(solution); 255 } 256 } 257 216 258 private async void variableListView_ItemChecked(object sender, ItemCheckedEventArgs e) { 217 259 var item = e.Item; … … 223 265 224 266 tl.SuspendLayout(); 225 226 267 if (item.Checked) { 227 268 tl.Controls.Add(chartsPanel); … … 234 275 if (tl.Controls.Count > 0) { 235 276 SetupYAxis(); 236 237 277 ReOrderControls(); 238 239 // set column styles 240 int numVariables = VisibleVariables.Count(); 241 tl.ColumnCount = Math.Min(numVariables, MaxColumns); 242 tl.ColumnStyles.Clear(); 243 for (int c = 0; c < tl.ColumnCount; c++) 244 tl.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100.0f / tl.ColumnCount)); 245 246 // set column styles 247 tl.RowCount = (int)Math.Ceiling((double)numVariables / tl.ColumnCount); 248 var columnWidth = tl.Width / tl.ColumnCount; // assume all columns have the same width 249 var rowHeight = (int)(0.8 * columnWidth); 250 tl.RowStyles.Clear(); 251 for (int r = 0; r < tl.RowCount; r++) 252 tl.RowStyles.Add(new RowStyle(SizeType.Absolute, rowHeight)); 253 } 254 278 SetStyles(); 279 } 255 280 tl.ResumeLayout(); 256 281 } … … 314 339 } 315 340 } 341 342 private void columnsTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { 343 int columns; 344 if (!int.TryParse(columnsTextBox.Text, out columns)) { 345 e.Cancel = true; 346 columnsTextBox.Select(); 347 errorProvider.SetError(columnsTextBox, "Columns number must be a positive integer."); 348 } 349 } 350 351 private void columnsTextBox_Validated(object sender, EventArgs e) { 352 errorProvider.SetError(columnsTextBox, ""); 353 MaxColumns = int.Parse(columnsTextBox.Text); 354 int columns = Math.Min(VisibleVariables.Count(), MaxColumns); 355 if (columns > 0) { 356 var tl = gradientChartTableLayout; 357 MaxColumns = columns; 358 tl.SuspendLayout(); 359 ReOrderControls(); 360 SetStyles(); 361 tl.ResumeLayout(); 362 } 363 } 364 365 private void solution_ModelChanged(object sender, EventArgs e) { 366 OnContentChanged(); 367 } 316 368 } 317 369 } 318 370 371
Note: See TracChangeset
for help on using the changeset viewer.