[754] | 1 | using System.Drawing;
|
---|
| 2 |
|
---|
| 3 | namespace HeuristicLab.Visualization {
|
---|
| 4 | public class LineShape : IShape {
|
---|
[861] | 5 | private RectangleD boundingBox;
|
---|
[754] | 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) {
|
---|
[861] | 18 | this.boundingBox = new RectangleD(x1, y1, x2, y2);
|
---|
[754] | 19 | this.z = z;
|
---|
| 20 | this.color = color;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | public RectangleD BoundingBox {
|
---|
[861] | 24 | get { return boundingBox; }
|
---|
[754] | 25 | }
|
---|
| 26 |
|
---|
[861] | 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 |
|
---|
[754] | 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)){
|
---|
[861] | 55 | Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea);
|
---|
[754] | 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 | }
|
---|