[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;
|
---|
[869] | 8 | private int thickness;
|
---|
[754] | 9 |
|
---|
| 10 | /// <summary>
|
---|
| 11 | /// Initializes the LineShape.
|
---|
| 12 | /// </summary>
|
---|
| 13 | /// <param name="x1">x coordinate of left lineEndPoind</param>
|
---|
| 14 | /// <param name="y1">y coordinate of left lineEndPoind</param>
|
---|
| 15 | /// <param name="x2">x coordinate of right lineEndPoind</param>
|
---|
| 16 | /// <param name="y2">y coordinate of right lineEndPoind</param>
|
---|
| 17 | /// <param name="color">color for the LineShape</param>
|
---|
[869] | 18 | public LineShape(double x1, double y1, double x2, double y2, double z, Color color, int thickness) {
|
---|
[861] | 19 | this.boundingBox = new RectangleD(x1, y1, x2, y2);
|
---|
[754] | 20 | this.z = z;
|
---|
| 21 | this.color = color;
|
---|
[869] | 22 | this.thickness = thickness;
|
---|
[754] | 23 | }
|
---|
| 24 |
|
---|
| 25 | public RectangleD BoundingBox {
|
---|
[861] | 26 | get { return boundingBox; }
|
---|
[754] | 27 | }
|
---|
| 28 |
|
---|
[861] | 29 | public double Y1 {
|
---|
| 30 | get { return boundingBox.Y1; }
|
---|
| 31 | set { boundingBox.Y1 = value; }
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public double Y2 {
|
---|
| 35 | get { return boundingBox.Y2; }
|
---|
| 36 | set { boundingBox.Y2 = value; }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | public double X1 {
|
---|
| 40 | get { return boundingBox.X1; }
|
---|
| 41 | set { boundingBox.X1 = value; }
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | public double X2 {
|
---|
| 45 | get { return boundingBox.X2; }
|
---|
| 46 | set { boundingBox.X2 = value; }
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[754] | 49 | /// <summary>
|
---|
| 50 | /// Draws the LineShape.
|
---|
| 51 | /// </summary>
|
---|
| 52 | /// <param name="graphics">graphics handle to draw to</param>
|
---|
| 53 | /// <param name="viewport">rectangle in value-coordinates to display</param>
|
---|
| 54 | /// <param name="clippingArea">rectangle in screen-coordinates to draw</param>
|
---|
| 55 | public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
|
---|
[869] | 56 | using (Pen pen = new Pen(color, thickness)){
|
---|
[870] | 57 | // TODO there seems to be a bug with drawing straight lines.
|
---|
[861] | 58 | Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea);
|
---|
[754] | 59 | graphics.DrawLine(pen,screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top);
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | public double Z {
|
---|
| 64 | get { return z; }
|
---|
| 65 | set { z = value; }
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 | }
|
---|