Changeset 1240 for trunk/sources/HeuristicLab.Visualization/LineChart.cs
- Timestamp:
- 03/02/09 22:03:41 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/LineChart.cs
r1237 r1240 12 12 13 13 private readonly IChartDataRowsModel model; 14 private readonly Canvas canvas; 15 14 16 private int maxDataRowCount; 15 17 private Boolean zoomFullView; … … 20 22 private IShape minLineShape; 21 23 22 private readonly WorldShape root;23 24 private readonly TextShape titleShape; 24 25 private readonly LinesShape linesShape; … … 28 29 private readonly YAxis yAxis; 29 30 private readonly Grid grid; 31 32 private readonly WorldShape berni; 33 private readonly RectangleShape mousePointer; 30 34 31 35 /// <summary> … … 45 49 } 46 50 47 //TODO: correct Rectangle to fit48 49 root = new WorldShape();51 minMaxLineEnabled = true; 52 53 canvas = canvasUI.Canvas; 50 54 51 55 grid = new Grid(); 52 minMaxLineEnabled = true; 53 root.AddShape(grid); 56 canvas.AddShape(grid); 54 57 55 58 linesShape = new LinesShape(); 56 root.AddShape(linesShape);59 canvas.AddShape(linesShape); 57 60 58 61 xAxis = new XAxis(); 59 root.AddShape(xAxis);62 canvas.AddShape(xAxis); 60 63 61 64 yAxis = new YAxis(); 62 root.AddShape(yAxis);65 canvas.AddShape(yAxis); 63 66 64 67 titleShape = new TextShape(0, 0, model.Title, 15); 65 root.AddShape(titleShape);68 canvas.AddShape(titleShape); 66 69 67 70 minMaxLineShape = new MinMaxLineShape(this.minDataValue, this.maxDataValue, Color.Yellow, 4, DrawingStyle.Solid); 68 root.AddShape(minMaxLineShape);71 canvas.AddShape(minMaxLineShape); 69 72 70 73 legendShape = new LegendShape(); 71 root.AddShape(legendShape); 72 73 canvas.MainCanvas.WorldShape = root; 74 canvas.Resize += delegate { UpdateLayout(); }; 75 76 UpdateLayout(); 74 canvas.AddShape(legendShape); 75 76 berni = new WorldShape(); 77 canvas.AddShape(berni); 78 79 mousePointer = new RectangleShape(10, 10, 20, 20, Color.Black); 80 berni.AddShape(mousePointer); 81 77 82 maxDataRowCount = 0; 78 83 this.model = model; 79 84 Item = model; 80 85 86 UpdateLayout(); 87 canvasUI.Resize += delegate { UpdateLayout(); }; 81 88 82 89 //The whole data rows are shown per default … … 88 95 /// </summary> 89 96 private void UpdateLayout() { 90 root.ClippingArea = new RectangleD(0, 0, canvas.Width, canvas.Height);91 92 97 titleShape.X = 10; 93 titleShape.Y = canvas .Height - 10;98 titleShape.Y = canvasUI.Height - 10; 94 99 95 100 const int yAxisWidth = 100; … … 98 103 linesShape.BoundingBox = new RectangleD(yAxisWidth, 99 104 xAxisHeight, 100 canvas.Width, 101 canvas.Height); 105 canvasUI.Width, 106 canvasUI.Height); 107 108 berni.BoundingBox = linesShape.BoundingBox; 109 berni.ClippingArea = new RectangleD(0, 0, berni.BoundingBox.Width, berni.BoundingBox.Height); 102 110 103 111 grid.BoundingBox = linesShape.BoundingBox; … … 115 123 linesShape.BoundingBox.Y1); 116 124 117 legendShape.BoundingBox = new RectangleD(10, 10, 110, canvas .Height - 50);125 legendShape.BoundingBox = new RectangleD(10, 10, 110, canvasUI.Height - 50); 118 126 legendShape.ClippingArea = new RectangleD(0, 0, legendShape.BoundingBox.Width, 119 127 legendShape.BoundingBox.Height); … … 124 132 ZoomToFullView(); 125 133 126 canvas .Invalidate();134 canvasUI.Invalidate(); 127 135 } 128 136 … … 162 170 InitLineShapes(row); 163 171 } 172 173 private void OnDataRowRemoved(IDataRow row) { 174 row.ValueChanged -= OnRowValueChanged; 175 row.ValuesChanged -= OnRowValuesChanged; 176 row.DataRowChanged -= OnDataRowChanged; 177 } 178 179 #endregion 164 180 165 181 private void ZoomToFullView() { … … 221 237 ZoomToFullView(); 222 238 223 canvas.Invalidate(); 224 } 225 226 private void OnDataRowRemoved(IDataRow row) { 227 row.ValueChanged -= OnRowValueChanged; 228 row.ValuesChanged -= OnRowValuesChanged; 229 row.DataRowChanged -= OnDataRowChanged; 239 canvasUI.Invalidate(); 230 240 } 231 241 … … 267 277 ZoomToFullView(); 268 278 269 canvas .Invalidate();270 } 271 272 279 canvasUI.Invalidate(); 280 } 281 282 // TODO remove (see ticket #501) 273 283 public IList<IDataRow> GetRows() { 274 284 return model.Rows; … … 286 296 titleShape.Text = model.Title; 287 297 288 Invalidate(); 289 } 290 291 #endregion 298 canvasUI.Invalidate(); 299 } 300 301 public void OnDataRowChanged(IDataRow row) { 302 foreach (LineShape ls in rowToLineShapes[row]) { 303 ls.LSColor = row.Color; 304 ls.LSThickness = row.Thickness; 305 ls.LSDrawingStyle = row.Style; 306 } 307 canvasUI.Invalidate(); 308 } 292 309 293 310 #region Begin-/EndUpdate … … 307 324 308 325 if (beginUpdateCount == 0) { 309 canvas .Invalidate();326 canvasUI.Invalidate(); 310 327 } 311 328 } … … 325 342 326 343 SetNewClippingArea(clippingArea); 327 canvas .Invalidate();344 canvasUI.Invalidate(); 328 345 } 329 346 } … … 346 363 } 347 364 365 private void canvas_MouseMove(object sender, MouseEventArgs e) { 366 double x = Transform.ToWorldX(e.X, berni.Viewport, berni.ClippingArea); 367 double y = Transform.ToWorldY(e.Y, berni.Viewport, berni.ClippingArea); 368 369 mousePointer.Rectangle = new RectangleD(x-1, y-1, x+1, y+1); 370 canvasUI.Invalidate(); 371 } 372 348 373 private void canvasUI1_MouseWheel(object sender, MouseEventArgs e) { 349 374 if (ModifierKeys == Keys.Control) { … … 353 378 354 379 SetLineClippingArea(clippingArea); 355 canvas .Invalidate();380 canvasUI.Invalidate(); 356 381 } 357 382 } … … 362 387 zoomListener.OnMouseUp += OnZoom_MouseUp; 363 388 364 canvas .MouseEventListener = zoomListener;389 canvasUI.MouseEventListener = zoomListener; 365 390 366 391 rectangleShape = new RectangleShape(e.X, e.Y, e.X, e.Y, Color.Blue); … … 371 396 372 397 private void OnZoom_MouseUp(object sender, MouseEventArgs e) { 373 canvas .MouseEventListener = null;398 canvasUI.MouseEventListener = null; 374 399 375 400 RectangleD clippingArea = rectangleShape.Rectangle; … … 382 407 zoomFullView = false; //user wants to zoom => no full view 383 408 384 canvas .Invalidate();409 canvasUI.Invalidate(); 385 410 } 386 411 387 412 private void DrawRectangle(Rectangle rectangle) { 388 rectangleShape.Rectangle = Transform.ToWorld(rectangle, canvas .ClientRectangle, linesShape.ClippingArea);389 canvas .Invalidate();413 rectangleShape.Rectangle = Transform.ToWorld(rectangle, canvasUI.ClientRectangle, linesShape.ClippingArea); 414 canvasUI.Invalidate(); 390 415 } 391 416 392 417 private void CreatePanListener(MouseEventArgs e) { 393 PanListener panListener = new PanListener(canvas .ClientRectangle, linesShape.ClippingArea, e.Location);418 PanListener panListener = new PanListener(canvasUI.ClientRectangle, linesShape.ClippingArea, e.Location); 394 419 395 420 panListener.SetNewClippingArea += SetNewClippingArea; 396 421 panListener.OnMouseUp += delegate { 397 422 historyStack.Push(linesShape.ClippingArea); 398 canvas .MouseEventListener = null;423 canvasUI.MouseEventListener = null; 399 424 }; 400 425 401 canvas .MouseEventListener = panListener;426 canvasUI.MouseEventListener = panListener; 402 427 } 403 428 … … 406 431 407 432 zoomFullView = false; 408 canvas .Invalidate();433 canvasUI.Invalidate(); 409 434 } 410 435 … … 415 440 optionsdlg.ShowDialog(this); 416 441 } 417 418 public void OnDataRowChanged(IDataRow row) {419 foreach (LineShape ls in rowToLineShapes[row]) {420 ls.LSColor = row.Color;421 ls.LSThickness = row.Thickness;422 ls.LSDrawingStyle = row.Style;423 }424 canvas.Invalidate();425 }426 442 } 427 443 }
Note: See TracChangeset
for help on using the changeset viewer.