Changeset 232 for trunk/sources
- Timestamp:
- 05/11/08 12:33:07 (17 years ago)
- Location:
- trunk/sources/HeuristicLab.DataAnalysis
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DataAnalysis/Dataset.cs
r207 r232 60 60 if(v != samples[columns * i + j]) { 61 61 samples[columns * i + j] = v; 62 CreateDictionaries(); 62 63 FireChanged(); 63 64 } … … 85 86 Rows = 1; 86 87 Samples = new double[1]; 87 }88 89 void samples_Changed(object sender, EventArgs e) {90 CreateDictionaries();91 88 } 92 89 … … 233 230 } 234 231 } 232 233 public double GetMaximum(int column) { 234 double max = Double.NegativeInfinity; 235 for(int i = 0; i < Rows; i++) { 236 double val = GetValue(i, column); 237 if(val > max) max = val; 238 } 239 return max; 240 } 241 242 public double GetMinimum(int column) { 243 double min = Double.PositiveInfinity; 244 for(int i = 0; i < Rows; i++) { 245 double val = GetValue(i, column); 246 if(val < min) min = val; 247 } 248 return min; 249 } 235 250 } 236 251 } -
trunk/sources/HeuristicLab.DataAnalysis/DatasetView.cs
r168 r232 25 25 26 26 namespace HeuristicLab.DataAnalysis { 27 public partial class DatasetView : ViewBase { 28 29 private OpenFileDialog openFileDialog; 30 27 public partial class DatasetView : EditorBase { 31 28 public Dataset Dataset { 32 29 get { return (Dataset)Item; } … … 37 34 } 38 35 36 private double[] scalingFactor; 37 private double[] scalingOffset; 39 38 public DatasetView() 40 39 : base() { 41 40 InitializeComponent(); 42 openFileDialog = new OpenFileDialog();43 41 } 44 42 … … 50 48 protected override void UpdateControls() { 51 49 base.UpdateControls(); 50 if(this.scalingFactor == null) { 51 this.scalingFactor = new double[Dataset.Columns]; 52 this.scalingOffset = new double[Dataset.Columns]; 53 for(int i = 0; i < scalingFactor.Length; i++) { 54 scalingFactor[i] = 1.0; 55 scalingOffset[i] = 0.0; 56 } 57 } 52 58 if (Dataset != null) { 53 59 int rows = Dataset.Rows; … … 63 69 } 64 70 } 65 if (Dataset.VariableNames.Length == dataGridView.Columns.Count) { 66 for (int i = 0; i < columns; i++) { 67 dataGridView.Columns[i].Name = Dataset.VariableNames[i]; 68 } 69 } else { 70 for (int i = 0; i < columns; i++) { 71 dataGridView.Columns[i].Name = "Var" + i; 72 } 71 for (int i = 0; i < columns; i++) { 72 dataGridView.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; 73 dataGridView.Columns[i].Name = GetColumnName(i); 74 dataGridView.Columns[i].ContextMenuStrip = contextMenuStrip; 73 75 } 74 76 dataGridView.SelectionMode = DataGridViewSelectionMode.ColumnHeaderSelect; 75 77 } else { 76 78 rowsTextBox.Text = "1"; … … 104 106 return element != null && double.TryParse(element, out result); 105 107 } 108 109 private void exportButton_Click(object sender, EventArgs e) { 110 throw new NotImplementedException(); 111 } 112 113 private void scaleValuesToolStripMenuItem_Click(object sender, EventArgs e) { 114 foreach(DataGridViewColumn column in dataGridView.SelectedColumns) { 115 if(scalingFactor[column.Index] == 1.0) { 116 double min = Dataset.GetMinimum(column.Index); 117 double max = Dataset.GetMaximum(column.Index); 118 double range = max - min; 119 scalingFactor[column.Index] = range; 120 scalingOffset[column.Index] = min; 121 column.Name = GetColumnName(column.Index) + " [scaled]"; 122 for(int i = 0; i < Dataset.Rows; i++) { 123 Dataset.SetValue(i, column.Index, (Dataset.GetValue(i, column.Index)-min) / range); 124 } 125 } 126 } 127 Refresh(); 128 } 129 130 private void originalValuesToolStripMenuItem_Click(object sender, EventArgs e) { 131 foreach(DataGridViewColumn column in dataGridView.SelectedColumns) { 132 if(scalingFactor[column.Index] != 1.0) { 133 column.Name = GetColumnName(column.Index); 134 for(int i = 0; i < Dataset.Rows; i++) { 135 Dataset.SetValue(i, column.Index, Dataset.GetValue(i, column.Index) * scalingFactor[column.Index] + scalingOffset[column.Index]); 136 } 137 scalingFactor[column.Index] = 1.0; 138 scalingOffset[column.Index] = 0.0; 139 } 140 } 141 Refresh(); 142 } 143 144 private string GetColumnName(int index) { 145 if(Dataset.VariableNames.Length == dataGridView.Columns.Count) { 146 return Dataset.VariableNames[index]; 147 } else { 148 return "Var " + index; 149 } 150 } 106 151 } 107 152 } -
trunk/sources/HeuristicLab.DataAnalysis/DatasetView.designer.cs
r2 r232 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container(); 47 48 this.rowsTextBox = new System.Windows.Forms.TextBox(); 48 49 this.columnsTextBox = new System.Windows.Forms.TextBox(); … … 52 53 this.nameLabel = new System.Windows.Forms.Label(); 53 54 this.nameTextBox = new System.Windows.Forms.TextBox(); 55 this.exportButton = new System.Windows.Forms.Button(); 56 this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); 57 this.scaleValuesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 58 this.originalValuesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 54 59 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); 60 this.contextMenuStrip.SuspendLayout(); 55 61 this.SuspendLayout(); 56 62 // 57 63 // rowsTextBox 58 64 // 59 this.rowsTextBox.Location = new System.Drawing.Point( 46, 32);65 this.rowsTextBox.Location = new System.Drawing.Point(50, 29); 60 66 this.rowsTextBox.Name = "rowsTextBox"; 61 67 this.rowsTextBox.ReadOnly = true; … … 65 71 // columnsTextBox 66 72 // 67 this.columnsTextBox.Location = new System.Drawing.Point(2 08, 32);73 this.columnsTextBox.Location = new System.Drawing.Point(217, 29); 68 74 this.columnsTextBox.Name = "columnsTextBox"; 69 75 this.columnsTextBox.ReadOnly = true; … … 79 85 | System.Windows.Forms.AnchorStyles.Right))); 80 86 this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 81 this.dataGridView.Location = new System.Drawing.Point(3, 58);87 this.dataGridView.Location = new System.Drawing.Point(3, 84); 82 88 this.dataGridView.Name = "dataGridView"; 83 this.dataGridView.Size = new System.Drawing.Size(554, 4 82);89 this.dataGridView.Size = new System.Drawing.Size(554, 456); 84 90 this.dataGridView.TabIndex = 3; 85 91 this.dataGridView.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.dataGridView_CellValidating); … … 88 94 // 89 95 this.rowsLabel.AutoSize = true; 90 this.rowsLabel.Location = new System.Drawing.Point(3, 3 5);96 this.rowsLabel.Location = new System.Drawing.Point(3, 32); 91 97 this.rowsLabel.Name = "rowsLabel"; 92 98 this.rowsLabel.Size = new System.Drawing.Size(37, 13); … … 97 103 // 98 104 this.columnsLabel.AutoSize = true; 99 this.columnsLabel.Location = new System.Drawing.Point(1 52, 35);105 this.columnsLabel.Location = new System.Drawing.Point(161, 32); 100 106 this.columnsLabel.Name = "columnsLabel"; 101 107 this.columnsLabel.Size = new System.Drawing.Size(50, 13); … … 114 120 // nameTextBox 115 121 // 116 this.nameTextBox.Location = new System.Drawing.Point( 46, 3);122 this.nameTextBox.Location = new System.Drawing.Point(50, 3); 117 123 this.nameTextBox.Name = "nameTextBox"; 118 124 this.nameTextBox.ReadOnly = true; 119 this.nameTextBox.Size = new System.Drawing.Size(2 62, 20);125 this.nameTextBox.Size = new System.Drawing.Size(219, 20); 120 126 this.nameTextBox.TabIndex = 7; 127 // 128 // exportButton 129 // 130 this.exportButton.Location = new System.Drawing.Point(6, 55); 131 this.exportButton.Name = "exportButton"; 132 this.exportButton.Size = new System.Drawing.Size(75, 23); 133 this.exportButton.TabIndex = 11; 134 this.exportButton.Text = "Export ..."; 135 this.exportButton.UseVisualStyleBackColor = true; 136 this.exportButton.Click += new System.EventHandler(this.exportButton_Click); 137 // 138 // contextMenuStrip 139 // 140 this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 141 this.scaleValuesToolStripMenuItem, 142 this.originalValuesToolStripMenuItem}); 143 this.contextMenuStrip.Name = "contextMenuStrip"; 144 this.contextMenuStrip.Size = new System.Drawing.Size(146, 48); 145 // 146 // scaleValuesToolStripMenuItem 147 // 148 this.scaleValuesToolStripMenuItem.Name = "scaleValuesToolStripMenuItem"; 149 this.scaleValuesToolStripMenuItem.Size = new System.Drawing.Size(145, 22); 150 this.scaleValuesToolStripMenuItem.Text = "Scale values"; 151 this.scaleValuesToolStripMenuItem.Click += new System.EventHandler(this.scaleValuesToolStripMenuItem_Click); 152 // 153 // originalValuesToolStripMenuItem 154 // 155 this.originalValuesToolStripMenuItem.Name = "originalValuesToolStripMenuItem"; 156 this.originalValuesToolStripMenuItem.Size = new System.Drawing.Size(145, 22); 157 this.originalValuesToolStripMenuItem.Text = "Unscale values"; 158 this.originalValuesToolStripMenuItem.Click += new System.EventHandler(this.originalValuesToolStripMenuItem_Click); 121 159 // 122 160 // DatasetView … … 125 163 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 126 164 this.Controls.Add(this.nameTextBox); 165 this.Controls.Add(this.exportButton); 127 166 this.Controls.Add(this.nameLabel); 128 167 this.Controls.Add(this.columnsLabel); … … 134 173 this.Size = new System.Drawing.Size(560, 543); 135 174 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); 175 this.contextMenuStrip.ResumeLayout(false); 136 176 this.ResumeLayout(false); 137 177 this.PerformLayout(); … … 148 188 private System.Windows.Forms.Label nameLabel; 149 189 private System.Windows.Forms.TextBox nameTextBox; 190 private System.Windows.Forms.Button exportButton; 191 private System.Windows.Forms.ContextMenuStrip contextMenuStrip; 192 private System.Windows.Forms.ToolStripMenuItem scaleValuesToolStripMenuItem; 193 private System.Windows.Forms.ToolStripMenuItem originalValuesToolStripMenuItem; 150 194 } 151 195 } -
trunk/sources/HeuristicLab.DataAnalysis/DatasetView.resx
r2 r232 118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 119 119 </resheader> 120 <metadata name="contextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 121 <value>17, 17</value> 122 </metadata> 120 123 </root>
Note: See TracChangeset
for help on using the changeset viewer.