- Timestamp:
- 03/13/09 19:07:53 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.Test/LineChartTests.cs
r1326 r1342 311 311 IDataRow row3 = new DataRow(); 312 312 313 IDataRow row4 = new DataRow(); 314 IDataRow row5 = new DataRow(); 315 IDataRow row6 = new DataRow(); 316 313 317 row1.Color = Color.Red; 314 318 row2.Color = Color.Green; 315 319 row3.Color = Color.Blue; 316 320 321 row4.Color = Color.DeepPink; 322 row5.Color = Color.Firebrick; 323 row6.Color = Color.DarkSlateGray; 324 317 325 row1.Thickness = 3; 318 326 row2.Thickness = 4; 319 327 row3.Thickness = 5; 328 329 row4.Thickness = 3; 330 row5.Thickness = 4; 331 row6.Thickness = 5; 320 332 321 333 row1.Label = "SingleValue"; … … 323 335 row3.Label = "Maxi"; 324 336 337 row4.Label = "Simon"; 338 row5.Label = "klausmuellerwesternhagenunddierasperies"; 339 row6.Label = "anyways"; 340 325 341 row1.Style = DrawingStyle.Solid; 326 342 row2.Style = DrawingStyle.Solid; 327 343 row3.Style = DrawingStyle.Dashed; 344 345 row4.Style = DrawingStyle.Solid; 346 row5.Style = DrawingStyle.Solid; 347 row6.Style = DrawingStyle.Dashed; 328 348 329 349 row1.LineType = DataRowType.SingleValue; … … 331 351 row1.AddValue(12); 332 352 333 model.AddDataRow(row1);334 model.AddDataRow(row2);335 model.AddDataRow(row3);336 337 338 339 353 row2.AddValue(5); 340 354 … … 347 361 348 362 349 363 row4.AddValue(10); 364 row5.AddValue(11); 365 row6.AddValue(11); 366 367 model.AddDataRow(row1); 368 model.AddDataRow(row2); 369 model.AddDataRow(row3); 370 model.AddDataRow(row4); 371 model.AddDataRow(row5); 372 model.AddDataRow(row6); 350 373 351 374 f.ShowDialog(); -
trunk/sources/HeuristicLab.Visualization/Legend/LegendItem.cs
r1233 r1342 3 3 namespace HeuristicLab.Visualization.Legend { 4 4 public class LegendItem { 5 6 public static readonly int WIDTH = 100; 7 5 8 public LegendItem(string label, Color color, int thickness) { 6 9 Label = label; -
trunk/sources/HeuristicLab.Visualization/Legend/LegendShape.cs
r1337 r1342 1 using System; 1 2 using System.Collections.Generic; 2 3 using System.Drawing; 3 4 4 5 namespace HeuristicLab.Visualization.Legend { 6 public enum LegendPosition { 7 Top, 8 Bottom, 9 Left, 10 Right 11 } 12 5 13 public class LegendShape : WorldShape { 6 14 private readonly IList<LegendItem> legendItems = new List<LegendItem>(); 15 // legend draw default value: column 16 private bool row; 17 private bool top; 18 7 19 8 20 private Color color = Color.Blue; … … 13 25 } 14 26 27 public bool Row { 28 set { row = value; } 29 get { return row; } 30 } 31 32 public bool Top { 33 set { top = value; } 34 get { return top; } 35 } 36 15 37 public void CreateLegend() { 16 38 ClearShapes(); 39 double x = ClippingArea.X1; 17 40 double y = ClippingArea.Y2; 41 int numberOfItemsPerRow = 0; 42 int rowCounter = 0; 43 int rowsToDraw = 1; 44 if (row) { 45 numberOfItemsPerRow = (int)ClippingArea.Width/LegendItem.WIDTH; 46 int nrOfItems = legendItems.Count; 47 if (nrOfItems > numberOfItemsPerRow) { 48 int rest; 49 int value = Math.DivRem(nrOfItems, numberOfItemsPerRow, out rest); 50 rowsToDraw = value + rest; 51 } 52 if (!top) 53 y = 25*rowsToDraw; 54 } 18 55 foreach (LegendItem item in legendItems) { 19 AddShape(new LineShape(10, y - 10, 30, y - 10, item.Color, item.Thickness, DrawingStyle.Solid)); 20 AddShape(new TextShape(35, y, item.Label, font, color)); 21 y -= 15; 56 if (!row) { 57 CreateColumn(item, y); 58 y -= 15; 59 } else { 60 if (rowCounter >= numberOfItemsPerRow) { 61 x = ClippingArea.X1; 62 y -= 25; 63 } 64 CreateRow(item, x, y); 65 x += LegendItem.WIDTH; 66 rowCounter++; 67 } 22 68 } 69 } 70 71 /// <summary> 72 /// draws the legend as a row at the top or bottom of the WorldShape 73 /// </summary> 74 /// <param name="item"></param> 75 /// <param name="x"></param> 76 /// <param name="y"></param> 77 private void CreateRow(LegendItem item, double x, double y) { 78 AddShape(new LineShape(x, y - 10, x + 20, y - 10, item.Color, item.Thickness, DrawingStyle.Solid)); 79 AddShape(new TextShape(x + 25, y, item.Label, Font, Color)); 80 } 81 82 /// <summary> 83 /// draws the legend as a column on the right or left side of the WorldShape 84 /// </summary> 85 /// <param name="item"></param> 86 /// <param name="y"></param> 87 private void CreateColumn(LegendItem item, double y) { 88 AddShape(new LineShape(10, y - 10, 30, y - 10, item.Color, item.Thickness, DrawingStyle.Solid)); 89 AddShape(new TextShape(35, y, item.Label, Font, Color)); 23 90 } 24 91 -
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r1341 r1342 52 52 this.model = model; 53 53 viewSettings = model.ViewSettings; 54 viewSettings.OnUpdateSettings += UpdateView Properties;54 viewSettings.OnUpdateSettings += UpdateViewSettings; 55 55 56 56 Item = model; … … 62 62 } 63 63 64 private void UpdateView Properties() {64 private void UpdateViewSettings() { 65 65 titleShape.Font = viewSettings.TitleFont; 66 66 titleShape.Color = viewSettings.TitleColor; … … 71 71 xAxis.Font = viewSettings.XAxisFont; 72 72 xAxis.Color = viewSettings.XAxisColor; 73 74 switch (viewSettings.LegendPosition) { 75 case LegendPosition.Bottom: 76 setLegendBottom(); 77 break; 78 79 case LegendPosition.Top: 80 setLegendTop(); 81 break; 82 83 case LegendPosition.Left: 84 setLegendLeft(); 85 break; 86 87 case LegendPosition.Right: 88 setLegendRight(); 89 break; 90 } 73 91 74 92 canvasUI.Invalidate(); … … 138 156 linesAreaBoundingBox.Y1); 139 157 158 setLegendBottom(); 159 } 160 161 public void setLegendRight() { 162 // legend right 163 legendShape.BoundingBox = new RectangleD(canvasUI.Width - 110, 10, canvasUI.Width, canvasUI.Height - 50); 164 legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height); 165 legendShape.Row = false; 166 legendShape.CreateLegend(); 167 } 168 169 public void setLegendLeft() { 170 // legend left 140 171 legendShape.BoundingBox = new RectangleD(10, 10, 110, canvasUI.Height - 50); 141 legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, 142 legendShape.BoundingBox.Height); 143 144 canvasUI.Invalidate(); 172 legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height); 173 legendShape.Row = false; 174 legendShape.CreateLegend(); 175 176 canvasUI.Invalidate(); 177 } 178 179 public void setLegendTop() { 180 // legend top 181 legendShape.BoundingBox = new RectangleD(100, canvasUI.Height - canvasUI.Height, canvasUI.Width, canvasUI.Height - 10); 182 legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height); 183 legendShape.Row = true; 184 legendShape.Top = true; 185 legendShape.CreateLegend(); 186 } 187 188 public void setLegendBottom() { 189 // legend bottom 190 legendShape.BoundingBox = new RectangleD(100, 10, canvasUI.Width, 200); 191 legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, legendShape.BoundingBox.Height); 192 legendShape.Row = true; 193 legendShape.Top = false; 194 legendShape.CreateLegend(); 145 195 } 146 196 147 197 private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { 148 198 OptionsDialog optionsdlg = new OptionsDialog(model); 199 //var optionsdlg = new OptionsDialog(model, this); 149 200 optionsdlg.ShowDialog(this); 201 Invalidate(); 150 202 } 151 203 -
trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.Designer.cs
r1337 r1342 32 32 this.tabPage2 = new System.Windows.Forms.TabPage(); 33 33 this.btnChangeLegendFont = new System.Windows.Forms.Button(); 34 this.l abelposition = new System.Windows.Forms.Label();35 this.cbL abelPosition = new System.Windows.Forms.ComboBox();34 this.legendposition = new System.Windows.Forms.Label(); 35 this.cbLegendPosition = new System.Windows.Forms.ComboBox(); 36 36 this.tabPage1 = new System.Windows.Forms.TabPage(); 37 37 this.OptionsDialogSelectColorBt = new System.Windows.Forms.Button(); … … 113 113 // 114 114 this.tabPage2.Controls.Add(this.btnChangeLegendFont); 115 this.tabPage2.Controls.Add(this.l abelposition);116 this.tabPage2.Controls.Add(this.cbL abelPosition);115 this.tabPage2.Controls.Add(this.legendposition); 116 this.tabPage2.Controls.Add(this.cbLegendPosition); 117 117 this.tabPage2.Location = new System.Drawing.Point(4, 22); 118 118 this.tabPage2.Name = "tabPage2"; … … 133 133 this.btnChangeLegendFont.Click += new System.EventHandler(this.btnChangeLegendFont_Click); 134 134 // 135 // l abelposition136 // 137 this.l abelposition.AutoSize = true;138 this.l abelposition.Location = new System.Drawing.Point(3, 47);139 this.l abelposition.Name = "labelposition";140 this.l abelposition.Size = new System.Drawing.Size(72, 13);141 this.l abelposition.TabIndex = 1;142 this.l abelposition.Text = "Labelposition:";143 // 144 // cbL abelPosition145 // 146 this.cbL abelPosition.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;147 this.cbL abelPosition.FormattingEnabled = true;148 this.cbL abelPosition.Items.AddRange(new object[] {135 // legendposition 136 // 137 this.legendposition.AutoSize = true; 138 this.legendposition.Location = new System.Drawing.Point(8, 38); 139 this.legendposition.Name = "legendposition"; 140 this.legendposition.Size = new System.Drawing.Size(82, 13); 141 this.legendposition.TabIndex = 1; 142 this.legendposition.Text = "Legendposition:"; 143 // 144 // cbLegendPosition 145 // 146 this.cbLegendPosition.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 147 this.cbLegendPosition.FormattingEnabled = true; 148 this.cbLegendPosition.Items.AddRange(new object[] { 149 149 "left", 150 150 "right", 151 151 "top", 152 152 "bottom"}); 153 this.cbLabelPosition.Location = new System.Drawing.Point(81, 44); 154 this.cbLabelPosition.Name = "cbLabelPosition"; 155 this.cbLabelPosition.Size = new System.Drawing.Size(121, 21); 156 this.cbLabelPosition.TabIndex = 0; 153 this.cbLegendPosition.Location = new System.Drawing.Point(96, 35); 154 this.cbLegendPosition.Name = "cbLegendPosition"; 155 this.cbLegendPosition.Size = new System.Drawing.Size(121, 21); 156 this.cbLegendPosition.TabIndex = 0; 157 this.cbLegendPosition.SelectedIndexChanged += new System.EventHandler(this.cbLegendPosition_SelectedIndexChanged); 157 158 // 158 159 // tabPage1 … … 335 336 private System.Windows.Forms.Button btnChangeTitleFont; 336 337 private System.Windows.Forms.TabPage tabPage2; 337 private System.Windows.Forms.Label labelposition;338 private System.Windows.Forms.ComboBox cbLabelPosition;339 338 private System.Windows.Forms.TabPage tabPage1; 340 339 private System.Windows.Forms.Button OptionsDialogSelectColorBt; … … 346 345 private System.Windows.Forms.GroupBox groupBox1; 347 346 private System.Windows.Forms.Label label4; 347 private System.Windows.Forms.ComboBox cbLegendPosition; 348 private System.Windows.Forms.Label legendposition; 348 349 private System.Windows.Forms.ComboBox LineThicknessCB; 349 350 private System.Windows.Forms.Label label3; -
trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs
r1341 r1342 2 2 using System.Collections.Generic; 3 3 using System.Windows.Forms; 4 using HeuristicLab.Visualization.Legend; 4 5 5 6 namespace HeuristicLab.Visualization.Options { … … 74 75 } 75 76 77 private void cbLegendPosition_SelectedIndexChanged(object sender, EventArgs e) { 78 string pos = cbLegendPosition.SelectedItem.ToString(); 79 if (pos.Equals("left")) { 80 viewSettings.LegendPosition = LegendPosition.Left; 81 } else if (pos.Equals("right")) { 82 viewSettings.LegendPosition = LegendPosition.Right; 83 } else if (pos.Equals("bottom")) { 84 viewSettings.LegendPosition = LegendPosition.Bottom; 85 } else { 86 viewSettings.LegendPosition = LegendPosition.Top; 87 } 88 89 viewSettings.UpdateView(); 90 } 91 76 92 private void btnChangeTitleFont_Click(object sender, EventArgs e) { 77 93 fdFont.Font = viewSettings.TitleFont; -
trunk/sources/HeuristicLab.Visualization/Options/ViewSettings.cs
r1341 r1342 1 1 using System.Drawing; 2 using HeuristicLab.Visualization.Legend; 2 3 3 4 namespace HeuristicLab.Visualization.Options { … … 11 12 private Font xAxisFont; 12 13 private Color xAxisColor; 14 private LegendPosition legendPosition; 13 15 14 16 public ViewSettings() { … … 21 23 xAxisFont = new Font("Arial", 8); 22 24 xAxisColor = Color.Blue; 25 26 legendPosition = LegendPosition.Left; 23 27 } 24 28 … … 58 62 set { xAxisColor = value; } 59 63 } 64 65 public LegendPosition LegendPosition { 66 get { return legendPosition; } 67 set { legendPosition = value; } 68 } 60 69 } 61 70
Note: See TracChangeset
for help on using the changeset viewer.