Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/LineShape.cs @ 846

Last change on this file since 846 was 754, checked in by dwagner, 16 years ago

#345 First implementation of LineChart

File size: 1.6 KB
Line 
1using System.Drawing;
2
3namespace HeuristicLab.Visualization {
4  public class LineShape : IShape {
5    private RectangleD boundingRect;
6    private double z;
7    private Color color;
8
9    /// <summary>
10    /// Initializes the LineShape.
11    /// </summary>
12    /// <param name="x1">x coordinate of left lineEndPoind</param>
13    /// <param name="y1">y coordinate of left lineEndPoind</param>
14    /// <param name="x2">x coordinate of right lineEndPoind</param>
15    /// <param name="y2">y coordinate of right lineEndPoind</param>
16    /// <param name="color">color for the LineShape</param>
17    public LineShape(double x1, double y1, double x2, double y2, double z, Color color) {
18      this.boundingRect = new RectangleD(x1, y1, x2, y2);
19      this.z = z;
20      this.color = color;
21    }
22
23    public RectangleD BoundingBox {
24      get { return boundingRect; }
25    }
26
27    /// <summary>
28    /// Draws the LineShape.
29    /// </summary>
30    /// <param name="graphics">graphics handle to draw to</param>
31    /// <param name="viewport">rectangle in value-coordinates to display</param>
32    /// <param name="clippingArea">rectangle in screen-coordinates to draw</param>
33    public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
34      using (Pen pen = new Pen(color, 3)){
35        Rectangle screenRect = Transform.ToScreen(boundingRect, viewport, clippingArea);
36        graphics.DrawLine(pen,screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top);
37      }
38    }
39
40    public double Z {
41      get { return z; }
42      set { z = value; }
43    }
44  }
45}
Note: See TracBrowser for help on using the repository browser.