Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14388 for trunk


Ignore:
Timestamp:
11/11/16 16:16:40 (8 years ago)
Author:
pfleck
Message:

#2698

  • Implemented (re)checking of variables in multi-scatterplot.
  • Added 2 sliders for changing the chart size.
Location:
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.Designer.cs

    r14384 r14388  
    5252      this.bodyScrollPanel = new System.Windows.Forms.Panel();
    5353      this.bodyTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     54      this.sizeGroupBox = new System.Windows.Forms.GroupBox();
     55      this.heightLabel = new System.Windows.Forms.Label();
     56      this.widthLabel = new System.Windows.Forms.Label();
     57      this.heightTrackBar = new System.Windows.Forms.TrackBar();
     58      this.widthTrackBar = new System.Windows.Forms.TrackBar();
    5459      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    5560      this.splitContainer.Panel1.SuspendLayout();
     
    6065      this.rowHeaderScrollPanel.SuspendLayout();
    6166      this.bodyScrollPanel.SuspendLayout();
     67      this.sizeGroupBox.SuspendLayout();
     68      ((System.ComponentModel.ISupportInitialize)(this.heightTrackBar)).BeginInit();
     69      ((System.ComponentModel.ISupportInitialize)(this.widthTrackBar)).BeginInit();
    6270      this.SuspendLayout();
    6371      //
     72      // checkedItemList
     73      //
     74      this.checkedItemList.Size = new System.Drawing.Size(113, 369);
     75      //
    6476      // splitContainer
    6577      //
    6678      //
     79      // splitContainer.Panel1
     80      //
     81      this.splitContainer.Panel1.Controls.Add(this.sizeGroupBox);
     82      //
    6783      // splitContainer.Panel2
    6884      //
    6985      this.splitContainer.Panel2.Controls.Add(this.frameTableLayoutPanel);
     86      this.splitContainer.Size = new System.Drawing.Size(863, 520);
     87      this.splitContainer.SplitterDistance = 120;
    7088      //
    7189      // frameTableLayoutPanel
     
    83101      this.frameTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
    84102      this.frameTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());
    85       this.frameTableLayoutPanel.Size = new System.Drawing.Size(739, 517);
     103      this.frameTableLayoutPanel.Size = new System.Drawing.Size(739, 520);
    86104      this.frameTableLayoutPanel.TabIndex = 0;
    87105      //
     
    120138      this.rowHeaderScrollPanel.Margin = new System.Windows.Forms.Padding(0);
    121139      this.rowHeaderScrollPanel.Name = "rowHeaderScrollPanel";
    122       this.rowHeaderScrollPanel.Size = new System.Drawing.Size(40, 477);
     140      this.rowHeaderScrollPanel.Size = new System.Drawing.Size(40, 480);
    123141      this.rowHeaderScrollPanel.TabIndex = 4;
    124142      //
     
    148166      this.bodyScrollPanel.Margin = new System.Windows.Forms.Padding(0);
    149167      this.bodyScrollPanel.Name = "bodyScrollPanel";
    150       this.bodyScrollPanel.Size = new System.Drawing.Size(699, 477);
     168      this.bodyScrollPanel.Size = new System.Drawing.Size(699, 480);
    151169      this.bodyScrollPanel.TabIndex = 5;
    152170      this.bodyScrollPanel.Scroll += new System.Windows.Forms.ScrollEventHandler(this.bodyScrollPanel_Scroll);
     
    168186      this.bodyTableLayoutPanel.TabIndex = 0;
    169187      //
     188      // sizeGroupBox
     189      //
     190      this.sizeGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
     191            | System.Windows.Forms.AnchorStyles.Right)));
     192      this.sizeGroupBox.Controls.Add(this.heightLabel);
     193      this.sizeGroupBox.Controls.Add(this.widthLabel);
     194      this.sizeGroupBox.Controls.Add(this.heightTrackBar);
     195      this.sizeGroupBox.Controls.Add(this.widthTrackBar);
     196      this.sizeGroupBox.Location = new System.Drawing.Point(4, 379);
     197      this.sizeGroupBox.Name = "sizeGroupBox";
     198      this.sizeGroupBox.Size = new System.Drawing.Size(113, 124);
     199      this.sizeGroupBox.TabIndex = 5;
     200      this.sizeGroupBox.TabStop = false;
     201      this.sizeGroupBox.Text = "Chart Size";
     202      //
     203      // heightLabel
     204      //
     205      this.heightLabel.AutoSize = true;
     206      this.heightLabel.Location = new System.Drawing.Point(6, 64);
     207      this.heightLabel.Name = "heightLabel";
     208      this.heightLabel.Size = new System.Drawing.Size(41, 13);
     209      this.heightLabel.TabIndex = 2;
     210      this.heightLabel.Text = "Height:";
     211      //
     212      // widthLabel
     213      //
     214      this.widthLabel.AutoSize = true;
     215      this.widthLabel.Location = new System.Drawing.Point(6, 16);
     216      this.widthLabel.Name = "widthLabel";
     217      this.widthLabel.Size = new System.Drawing.Size(38, 13);
     218      this.widthLabel.TabIndex = 1;
     219      this.widthLabel.Text = "Width:";
     220      //
     221      // heightTrackBar
     222      //
     223      this.heightTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     224            | System.Windows.Forms.AnchorStyles.Right)));
     225      this.heightTrackBar.LargeChange = 50;
     226      this.heightTrackBar.Location = new System.Drawing.Point(6, 83);
     227      this.heightTrackBar.Maximum = 100;
     228      this.heightTrackBar.Name = "heightTrackBar";
     229      this.heightTrackBar.Size = new System.Drawing.Size(101, 45);
     230      this.heightTrackBar.SmallChange = 10;
     231      this.heightTrackBar.TabIndex = 0;
     232      this.heightTrackBar.TickFrequency = 10;
     233      this.heightTrackBar.Value = 20;
     234      this.heightTrackBar.ValueChanged += new System.EventHandler(this.heightTrackBar_ValueChanged);
     235      //
     236      // widthTrackBar
     237      //
     238      this.widthTrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     239            | System.Windows.Forms.AnchorStyles.Right)));
     240      this.widthTrackBar.LargeChange = 50;
     241      this.widthTrackBar.Location = new System.Drawing.Point(6, 32);
     242      this.widthTrackBar.Maximum = 100;
     243      this.widthTrackBar.Name = "widthTrackBar";
     244      this.widthTrackBar.Size = new System.Drawing.Size(101, 45);
     245      this.widthTrackBar.SmallChange = 10;
     246      this.widthTrackBar.TabIndex = 0;
     247      this.widthTrackBar.TickFrequency = 10;
     248      this.widthTrackBar.Value = 20;
     249      this.widthTrackBar.ValueChanged += new System.EventHandler(this.widthTrackBar_ValueChanged);
     250      //
    170251      // ScatterPlotMultiView
    171252      //
     
    173254      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    174255      this.Name = "ScatterPlotMultiView";
    175       this.Size = new System.Drawing.Size(863, 517);
     256      this.Size = new System.Drawing.Size(863, 520);
    176257      this.splitContainer.Panel1.ResumeLayout(false);
    177258      this.splitContainer.Panel2.ResumeLayout(false);
     
    185266      this.bodyScrollPanel.ResumeLayout(false);
    186267      this.bodyScrollPanel.PerformLayout();
     268      this.sizeGroupBox.ResumeLayout(false);
     269      this.sizeGroupBox.PerformLayout();
     270      ((System.ComponentModel.ISupportInitialize)(this.heightTrackBar)).EndInit();
     271      ((System.ComponentModel.ISupportInitialize)(this.widthTrackBar)).EndInit();
    187272      this.ResumeLayout(false);
    188273
     
    198283    private System.Windows.Forms.Panel rowHeaderScrollPanel;
    199284    private System.Windows.Forms.Panel bodyScrollPanel;
     285    private System.Windows.Forms.GroupBox sizeGroupBox;
     286    private System.Windows.Forms.TrackBar widthTrackBar;
     287    private System.Windows.Forms.TrackBar heightTrackBar;
     288    private System.Windows.Forms.Label heightLabel;
     289    private System.Windows.Forms.Label widthLabel;
    200290  }
    201291}
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/ScatterPlotMultiView.cs

    r14384 r14388  
    1616  [Content(typeof(ScatterPlotContent), false)]
    1717  public partial class ScatterPlotMultiView : PreprocessingCheckedVariablesView {
    18     private const int MaxAutoSizeElements = 6;
    19     private const int FixedChartWidth = 250;
    20     private const int FixedChartHeight = 150;
    21 
    2218    private readonly IDictionary<string, Label> columnHeaderCache;
    2319    private readonly IDictionary<string, Label> rowHeaderCache;
     
    2723      InitializeComponent();
    2824
     25      #region Initialize Scrollbars
    2926      columnHeaderScrollPanel.HorizontalScroll.Enabled = true;
    3027      columnHeaderScrollPanel.VerticalScroll.Enabled = false;
     
    4239      bodyScrollPanel.VerticalScroll.Visible = true;
    4340      bodyScrollPanel.AutoScroll = true;
     41      #endregion
    4442
    4543      columnHeaderCache = new Dictionary<string, Label>();
     
    7270    }
    7371
     72    #region Add and remove charts
    7473    private void AddChartToTable(string variable) {
    75 
    76     }
    77     // remove from headers and body and shift remaining slots to fill the gap
     74      frameTableLayoutPanel.SuspendLayout();
     75
     76      // find index to insert
     77      var variables = checkedItemList.Content.Select(v => v.Value).ToList();
     78      int idx = variables              // all variables
     79        .TakeWhile(t => t != variable) // ... until the variable that was checked
     80        .Count(IsVariableChecked);     // ... how many checked variables
     81
     82      // add column header
     83      var colH = columnHeaderTableLayoutPanel;
     84      AddColumnHelper(colH, idx, _ => GetColumnHeader(variable));
     85
     86      // add row header
     87      var rowH = rowHeaderTableLayoutPanel;
     88      AddRowHelper(rowH, idx, _ => GetRowHeader(variable));
     89
     90      // add body
     91      var body = bodyTableLayoutPanel;
     92      var vars = GetCheckedVariables();
     93      var varsMinus = vars.Except(new[] { variable }).ToList();
     94      AddColumnHelper(body, idx, r => GetBody(variable, varsMinus[r])); // exclude "variable" because the row for it does not exist yet
     95      AddRowHelper(body, idx, c => GetBody(vars[c], variable));
     96
     97      frameTableLayoutPanel.ResumeLayout(true);
     98    }
     99    private void AddColumnHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) {
     100      // add column
     101      tlp.ColumnCount++;
     102      tlp.ColumnStyles.Insert(idx, new ColumnStyle(SizeType.Absolute, GetColumnWidth()));
     103      // shift right
     104      for (int c = tlp.ColumnCount; c >  idx - 1; c--) {
     105        for (int r = 0; r < tlp.RowCount; r++) {
     106          var control = tlp.GetControlFromPosition(c, r);
     107          if (control != null) {
     108            tlp.SetColumn(control, c + 1);
     109          }
     110        }
     111      }
     112      // add controls
     113      for (int r = 0; r < tlp.RowCount; r++) {
     114        if (tlp.GetControlFromPosition(idx, r) == null)
     115          tlp.Controls.Add(creatorFunc(r), idx, r);
     116      }
     117
     118    }
     119    private void AddRowHelper(TableLayoutPanel tlp, int idx, Func<int, Control> creatorFunc) {
     120      // add row
     121      tlp.RowCount++;
     122      tlp.RowStyles.Insert(idx, new RowStyle(SizeType.Absolute, GetRowHeight()));
     123      // shift right
     124      for (int r = tlp.RowCount; r > idx - 1; r--) {
     125        for (int c = 0; c < tlp.ColumnCount; c++) {
     126          var control = tlp.GetControlFromPosition(c, r);
     127          if (control != null) {
     128            tlp.SetRow(control, r + 1);
     129          }
     130        }
     131      }
     132      // add controls
     133      for (int c = 0; c < tlp.ColumnCount; c++)
     134        if (tlp.GetControlFromPosition(c, idx) == null)
     135          tlp.Controls.Add(creatorFunc(c), c, idx);
     136    }
     137
    78138    private void RemoveChartFromTable(string variable) {
    79139      frameTableLayoutPanel.SuspendLayout();
     
    96156      frameTableLayoutPanel.ResumeLayout(true);
    97157    }
    98 
    99158    private void RemoveColumnHelper(TableLayoutPanel tlp, int idx) {
     159      // remove controls
    100160      for (int r = 0; r < tlp.RowCount; r++)
    101161        tlp.Controls.Remove(tlp.GetControlFromPosition(idx, r));
     162      // shift left
    102163      for (int c = idx + 1; c < tlp.ColumnCount; c++) {
    103164        for (int r = 0; r < tlp.RowCount; r++) {
     
    108169        }
    109170      }
     171      // delete column
    110172      tlp.ColumnStyles.RemoveAt(tlp.ColumnCount - 1);
    111173      tlp.ColumnCount--;
    112174    }
    113175    private void RemoveRowHelper(TableLayoutPanel tlp, int idx) {
     176      // remove controls
    114177      for (int c = 0; c < tlp.ColumnCount; c++)
    115178        tlp.Controls.Remove(tlp.GetControlFromPosition(c, idx));
     179      // shift left
    116180      for (int r = idx + 1; r < tlp.RowCount; r++) {
    117181        for (int c = 0; c < tlp.ColumnCount; c++) {
     
    122186        }
    123187      }
     188      // delete rows
    124189      tlp.RowStyles.RemoveAt(tlp.RowCount - 1);
    125190      tlp.RowCount--;
    126191    }
    127 
    128     #region Add/Remove/Update Variable, Reset
     192    #endregion
     193
     194    #region Add/Remove/Update Variable
    129195    protected override void AddVariable(string name) {
    130196      base.AddVariable(name);
    131     }
    132 
     197      if (IsVariableChecked(name))
     198        AddChartToTable(name);
     199    }
    133200    protected override void RemoveVariable(string name) {
    134201      base.RemoveVariable(name);
     
    147214    protected override void UpdateVariable(string name) {
    148215      base.UpdateVariable(name);
     216      RemoveVariable(name);
     217      AddVariable(name);
    149218    }
    150219    protected override void ResetAllVariables() {
     
    153222    #endregion
    154223
    155 
    156     #region Creating Header and Body
     224    #region Creating Headers and Body
    157225    private Label GetColumnHeader(string variable) {
    158226      if (!columnHeaderCache.ContainsKey(variable)) {
     
    214282    #endregion
    215283
    216 
    217 
    218 
    219284    #region Generate Charts
    220285    private void GenerateCharts() {
     
    238303
    239304      // Set column and row layout
    240       int width = variables.Count <= MaxAutoSizeElements ? bodyTableLayoutPanel.Width / variables.Count : FixedChartWidth;
    241       int height = variables.Count <= MaxAutoSizeElements ? bodyTableLayoutPanel.Height / variables.Count : FixedChartHeight;
    242305      for (int i = 0; i < variables.Count; i++) {
    243         columnHeaderTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, width));
    244         rowHeaderTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, height));
    245         bodyTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, width));
    246         bodyTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, height));
     306        columnHeaderTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, GetColumnWidth()));
     307        rowHeaderTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, GetRowHeight()));
     308        bodyTableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, GetColumnWidth()));
     309        bodyTableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, GetRowHeight()));
    247310      }
    248311
     
    315378    #endregion
    316379
     380    #region Scrolling
    317381    private void bodyScrollPanel_Scroll(object sender, ScrollEventArgs e) {
    318382      SyncScroll();
     
    325389    }
    326390    private void SyncScroll() {
    327       //Debug.WriteLine("H: {0} <- {1}", columnHeaderScrollPanel.HorizontalScroll.Value, bodyScrollPanel.HorizontalScroll.Value);
    328       //Debug.WriteLine("V: {0} <- {1}", rowScrollLayoutPanel.VerticalScroll.Value, bodyScrollPanel.VerticalScroll.Value);
    329 
    330391      frameTableLayoutPanel.SuspendRepaint();
    331392
     
    344405      frameTableLayoutPanel.ResumeRepaint(true);
    345406    }
    346 
    347407    // add a margin to the header table layouts if the scollbar is visible to account for the width/height of the scrollbar
    348408    private void UpdateHeaderMargin() {
     
    350410      rowHeaderScrollPanel.Margin = new Padding(0, 0, 0, bodyScrollPanel.HorizontalScroll.Visible ? SystemInformation.HorizontalScrollBarHeight : 0);
    351411    }
     412    #endregion
     413
     414    #region Sizing of Charts
     415    private int GetColumnWidth() { return (int)(bodyScrollPanel.Width * ((float)widthTrackBar.Value / 100)); }
     416    private int GetRowHeight() { return (int)(bodyScrollPanel.Height * ((float)heightTrackBar.Value / 100)); }
     417    private void widthTrackBar_ValueChanged(object sender, EventArgs e) {
     418      frameTableLayoutPanel.SuspendRepaint();
     419      for (int i = 0; i < columnHeaderTableLayoutPanel.ColumnCount; i++) {
     420        columnHeaderTableLayoutPanel.ColumnStyles[i].Width = GetColumnWidth();
     421        bodyTableLayoutPanel.ColumnStyles[i].Width = GetColumnWidth();
     422      }
     423      frameTableLayoutPanel.ResumeRepaint(true);
     424    }
     425    private void heightTrackBar_ValueChanged(object sender, EventArgs e) {
     426      frameTableLayoutPanel.SuspendRepaint();
     427
     428      for (int i = 0; i < rowHeaderTableLayoutPanel.RowCount; i++) {
     429        rowHeaderTableLayoutPanel.RowStyles[i].Height = GetRowHeight();
     430        bodyTableLayoutPanel.RowStyles[i].Height = GetRowHeight();
     431      }
     432      frameTableLayoutPanel.ResumeRepaint(true);
     433    }
     434    #endregion
    352435  }
    353436}
Note: See TracChangeset for help on using the changeset viewer.