[754] | 1 | using System.Drawing;
|
---|
[980] | 2 | using System.Drawing.Drawing2D;
|
---|
[754] | 3 |
|
---|
| 4 | namespace HeuristicLab.Visualization {
|
---|
| 5 | public class LineShape : IShape {
|
---|
[861] | 6 | private RectangleD boundingBox;
|
---|
[754] | 7 | private double z;
|
---|
| 8 | private Color color;
|
---|
[869] | 9 | private int thickness;
|
---|
[980] | 10 | private DashStyle dashStyle;
|
---|
[754] | 11 |
|
---|
| 12 | /// <summary>
|
---|
| 13 | /// Initializes the LineShape.
|
---|
| 14 | /// </summary>
|
---|
| 15 | /// <param name="x1">x coordinate of left lineEndPoind</param>
|
---|
| 16 | /// <param name="y1">y coordinate of left lineEndPoind</param>
|
---|
| 17 | /// <param name="x2">x coordinate of right lineEndPoind</param>
|
---|
| 18 | /// <param name="y2">y coordinate of right lineEndPoind</param>
|
---|
| 19 | /// <param name="color">color for the LineShape</param>
|
---|
[980] | 20 | public LineShape(double x1, double y1, double x2, double y2, double z, Color color, int thickness, DrawingStyle style) {
|
---|
[861] | 21 | this.boundingBox = new RectangleD(x1, y1, x2, y2);
|
---|
[754] | 22 | this.z = z;
|
---|
| 23 | this.color = color;
|
---|
[869] | 24 | this.thickness = thickness;
|
---|
[980] | 25 | if (style==DrawingStyle.Dashed) {
|
---|
| 26 | this.dashStyle = DashStyle.Dash;
|
---|
| 27 | }
|
---|
| 28 | else {
|
---|
| 29 | this.dashStyle = DashStyle.Solid; //default
|
---|
| 30 | }
|
---|
[754] | 31 | }
|
---|
| 32 |
|
---|
| 33 | public RectangleD BoundingBox {
|
---|
[861] | 34 | get { return boundingBox; }
|
---|
[754] | 35 | }
|
---|
| 36 |
|
---|
[861] | 37 | public double Y1 {
|
---|
| 38 | get { return boundingBox.Y1; }
|
---|
| 39 | set { boundingBox.Y1 = value; }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | public double Y2 {
|
---|
| 43 | get { return boundingBox.Y2; }
|
---|
| 44 | set { boundingBox.Y2 = value; }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | public double X1 {
|
---|
| 48 | get { return boundingBox.X1; }
|
---|
| 49 | set { boundingBox.X1 = value; }
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | public double X2 {
|
---|
| 53 | get { return boundingBox.X2; }
|
---|
| 54 | set { boundingBox.X2 = value; }
|
---|
| 55 | }
|
---|
| 56 |
|
---|
[754] | 57 | /// <summary>
|
---|
| 58 | /// Draws the LineShape.
|
---|
| 59 | /// </summary>
|
---|
| 60 | /// <param name="graphics">graphics handle to draw to</param>
|
---|
| 61 | /// <param name="viewport">rectangle in value-coordinates to display</param>
|
---|
| 62 | /// <param name="clippingArea">rectangle in screen-coordinates to draw</param>
|
---|
| 63 | public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
|
---|
[869] | 64 | using (Pen pen = new Pen(color, thickness)){
|
---|
[980] | 65 | pen.DashStyle = this.dashStyle;
|
---|
[861] | 66 | Rectangle screenRect = Transform.ToScreen(boundingBox, viewport, clippingArea);
|
---|
[754] | 67 | graphics.DrawLine(pen,screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top);
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | public double Z {
|
---|
| 72 | get { return z; }
|
---|
| 73 | set { z = value; }
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 | }
|
---|