Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 866 was 861, checked in by mstoeger, 16 years ago

Adjustments on LineChart for new interface. #345

File size: 2.0 KB
Line 
1using System.Drawing;
2
3namespace HeuristicLab.Visualization {
4  public class LineShape : IShape {
5    private RectangleD boundingBox;
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.boundingBox = new RectangleD(x1, y1, x2, y2);
19      this.z = z;
20      this.color = color;
21    }
22
23    public RectangleD BoundingBox {
24      get { return boundingBox; }
25    }
26
27    public double Y1 {
28      get { return boundingBox.Y1; }
29      set { boundingBox.Y1 = value; }
30    }
31
32    public double Y2 {
33      get { return boundingBox.Y2; }
34      set { boundingBox.Y2 = value; }
35    }
36
37    public double X1 {
38      get { return boundingBox.X1; }
39      set { boundingBox.X1 = value; }
40    }
41
42    public double X2 {
43      get { return boundingBox.X2; }
44      set { boundingBox.X2 = value; }
45    }
46
47    /// <summary>
48    /// Draws the LineShape.
49    /// </summary>
50    /// <param name="graphics">graphics handle to draw to</param>
51    /// <param name="viewport">rectangle in value-coordinates to display</param>
52    /// <param name="clippingArea">rectangle in screen-coordinates to draw</param>
53    public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
54      using (Pen pen = new Pen(color, 3)){
55        Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea);
56        graphics.DrawLine(pen,screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top);
57      }
58    }
59
60    public double Z {
61      get { return z; }
62      set { z = value; }
63    }
64  }
65}
Note: See TracBrowser for help on using the repository browser.