using System.Drawing;
namespace HeuristicLab.Visualization {
public class LineShape : IShape {
private RectangleD boundingRect;
private double z;
private Color color;
///
/// Initializes the LineShape.
///
/// x coordinate of left lineEndPoind
/// y coordinate of left lineEndPoind
/// x coordinate of right lineEndPoind
/// y coordinate of right lineEndPoind
/// color for the LineShape
public LineShape(double x1, double y1, double x2, double y2, double z, Color color) {
this.boundingRect = new RectangleD(x1, y1, x2, y2);
this.z = z;
this.color = color;
}
public RectangleD BoundingBox {
get { return boundingRect; }
}
///
/// Draws the LineShape.
///
/// graphics handle to draw to
/// rectangle in value-coordinates to display
/// rectangle in screen-coordinates to draw
public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
using (Pen pen = new Pen(color, 3)){
Rectangle screenRect = Transform.ToScreen(boundingRect, viewport, clippingArea);
graphics.DrawLine(pen,screenRect.Left, screenRect.Bottom, screenRect.Right, screenRect.Top);
}
}
public double Z {
get { return z; }
set { z = value; }
}
}
}