/// <summary> /// Renders the legend symbol for the series on the specified rendering context. /// </summary> /// <param name="rc"> /// The rendering context. /// </param> /// <param name="legendBox"> /// The bounding rectangle of the legend box. /// </param> public override void RenderLegend(IRenderContext rc, OxyRect legendBox) { double xmid = (legendBox.Left + legendBox.Right) / 2; double yopen = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.7); double yclose = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.3); double[] dashArray = LineStyleHelper.GetDashArray(this.LineStyle); var color = this.GetSelectableColor(this.ActualColor); rc.DrawLine( new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, legendBox.Bottom) }, color, this.StrokeThickness, dashArray, OxyPenLineJoin.Miter, true); rc.DrawLine( new[] { new ScreenPoint(xmid - this.TickLength, yopen), new ScreenPoint(xmid, yopen) }, color, this.StrokeThickness, dashArray, OxyPenLineJoin.Miter, true); rc.DrawLine( new[] { new ScreenPoint(xmid + this.TickLength, yclose), new ScreenPoint(xmid, yclose) }, color, this.StrokeThickness, dashArray, OxyPenLineJoin.Miter, true); }
/// <summary> /// Draws the clipped line segments. /// </summary> /// <param name="rc">The render context.</param> /// <param name="points">The points.</param> /// <param name="clippingRectangle">The clipping rectangle.</param> /// <param name="stroke">The stroke.</param> /// <param name="strokeThickness">The stroke thickness.</param> /// <param name="lineStyle">The line style.</param> /// <param name="lineJoin">The line join.</param> /// <param name="aliased">if set to <c>true</c> [aliased].</param> public static void DrawClippedLineSegments( this IRenderContext rc, IList <ScreenPoint> points, OxyRect clippingRectangle, OxyColor stroke, double strokeThickness, LineStyle lineStyle, OxyPenLineJoin lineJoin, bool aliased) { var clipping = new CohenSutherlandClipping(clippingRectangle.Left, clippingRectangle.Right, clippingRectangle.Top, clippingRectangle.Bottom); var clippedPoints = new List <ScreenPoint>(points.Count); for (int i = 0; i + 1 < points.Count; i += 2) { var s0 = points[i]; var s1 = points[i + 1]; if (clipping.ClipLine(ref s0, ref s1)) { clippedPoints.Add(s0); clippedPoints.Add(s1); } } rc.DrawLineSegments(clippedPoints, stroke, strokeThickness, LineStyleHelper.GetDashArray(lineStyle), lineJoin, aliased); }
/// <summary> /// Initializes a new instance of the <see cref="OxyPen"/> class. /// </summary> /// <param name="color"> /// The color. /// </param> /// <param name="thickness"> /// The thickness. /// </param> /// <param name="lineStyle"> /// The line style. /// </param> /// <param name="lineJoin"> /// The line join. /// </param> public OxyPen( OxyColor color, double thickness = 1.0, LineStyle lineStyle = LineStyle.Solid, OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter) { this.Color = color; this.Thickness = thickness; this.DashArray = LineStyleHelper.GetDashArray(lineStyle); this.LineStyle = lineStyle; this.LineJoin = lineJoin; }
/// <summary> /// The draw clipped polygon. /// </summary> /// <param name="rc"> /// The render context. /// </param> /// <param name="points"> /// The points. /// </param> /// <param name="clippingRectangle"> /// The clipping rectangle. /// </param> /// <param name="minDistSquared"> /// The min dist squared. /// </param> /// <param name="fill"> /// The fill. /// </param> /// <param name="stroke"> /// The stroke. /// </param> /// <param name="strokeThickness"> /// The stroke thickness. /// </param> /// <param name="lineStyle"> /// The line style. /// </param> /// <param name="lineJoin"> /// The line join. /// </param> /// <param name="aliased"> /// The aliased. /// </param> public static void DrawClippedPolygon( this IRenderContext rc, IList <ScreenPoint> points, OxyRect clippingRectangle, double minDistSquared, OxyColor fill, OxyColor stroke, double strokeThickness = 1.0, LineStyle lineStyle = LineStyle.Solid, OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter, bool aliased = false) { var clippedPoints = SutherlandHodgmanClipping.ClipPolygon(clippingRectangle, points); rc.DrawPolygon( clippedPoints, fill, stroke, strokeThickness, LineStyleHelper.GetDashArray(lineStyle), lineJoin, aliased); }
/// <summary> /// Renders the legend symbol for the line series on the /// specified rendering context. /// </summary> /// <param name="rc"> /// The rendering context. /// </param> /// <param name="legendBox"> /// The bounding rectangle of the legend box. /// </param> public override void RenderLegend(IRenderContext rc, OxyRect legendBox) { double y0 = (legendBox.Top * 0.2) + (legendBox.Bottom * 0.8); double y1 = (legendBox.Top * 0.4) + (legendBox.Bottom * 0.6); double y2 = (legendBox.Top * 0.8) + (legendBox.Bottom * 0.2); var pts0 = new[] { new ScreenPoint(legendBox.Left, y0), new ScreenPoint(legendBox.Right, y0) }; var pts1 = new[] { new ScreenPoint(legendBox.Right, y2), new ScreenPoint(legendBox.Left, y1) }; var pts = new List <ScreenPoint>(); pts.AddRange(pts0); pts.AddRange(pts1); var color = this.GetSelectableColor(this.ActualColor); rc.DrawLine(pts0, color, this.StrokeThickness, LineStyleHelper.GetDashArray(this.ActualLineStyle)); rc.DrawLine(pts1, color, this.StrokeThickness, LineStyleHelper.GetDashArray(this.ActualLineStyle)); rc.DrawPolygon(pts, this.GetSelectableFillColor(this.Fill), null); }
/// <summary> /// Renders the legend symbol for the series on the specified rendering context. /// </summary> /// <param name="rc"> /// The rendering context. /// </param> /// <param name="legendBox"> /// The bounding rectangle of the legend box. /// </param> public override void RenderLegend(IRenderContext rc, OxyRect legendBox) { double xmid = (legendBox.Left + legendBox.Right) / 2; double yopen = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.7); double yclose = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.3); double[] dashArray = LineStyleHelper.GetDashArray(this.LineStyle); rc.DrawLine( new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, legendBox.Bottom) }, this.GetSelectableColor(this.ActualColor), this.StrokeThickness, dashArray, OxyPenLineJoin.Miter, true); rc.DrawRectangleAsPolygon( new OxyRect(xmid - (this.CandleWidth * 0.5), yclose, this.CandleWidth, yopen - yclose), this.GetSelectableFillColor(this.ActualColor), this.GetSelectableColor(this.ActualColor), this.StrokeThickness); }
/// <summary> /// Renders the legend symbol on the specified rendering context. /// </summary> /// <param name="rc"> /// The rendering context. /// </param> /// <param name="legendBox"> /// The legend rectangle. /// </param> public override void RenderLegend(IRenderContext rc, OxyRect legendBox) { double xmid = (legendBox.Left + legendBox.Right) / 2; double ybottom = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.7); double ytop = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.3); double ymid = (ybottom + ytop) * 0.5; var halfBoxWidth = legendBox.Width * 0.24; var halfWhiskerWidth = halfBoxWidth * this.WhiskerWidth; double strokeThickness = 1; var strokeColor = this.GetSelectableColor(this.Stroke); var fillColor = this.GetSelectableFillColor(this.Fill); rc.DrawLine( new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, ytop) }, strokeColor, strokeThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); rc.DrawLine( new[] { new ScreenPoint(xmid, ybottom), new ScreenPoint(xmid, legendBox.Bottom) }, strokeColor, strokeThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); if (this.WhiskerWidth > 0) { // top whisker rc.DrawLine( new[] { new ScreenPoint(xmid - halfWhiskerWidth - 1, legendBox.Bottom), new ScreenPoint(xmid + halfWhiskerWidth, legendBox.Bottom) }, strokeColor, strokeThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); // bottom whisker rc.DrawLine( new[] { new ScreenPoint(xmid - halfWhiskerWidth - 1, legendBox.Top), new ScreenPoint(xmid + halfWhiskerWidth, legendBox.Top) }, strokeColor, strokeThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); } if (this.ShowBox) { // box rc.DrawRectangleAsPolygon( new OxyRect(xmid - halfBoxWidth, ytop, 2 * halfBoxWidth, ybottom - ytop), fillColor, strokeColor, strokeThickness); } // median if (!this.ShowMedianAsDot) { rc.DrawLine( new[] { new ScreenPoint(xmid - halfBoxWidth, ymid), new ScreenPoint(xmid + halfBoxWidth, ymid) }, strokeColor, strokeThickness * this.MedianThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); } else { var ellipseRect = new OxyRect( xmid - this.MedianPointSize, ymid - this.MedianPointSize, this.MedianPointSize * 2, this.MedianPointSize * 2); rc.DrawEllipse(ellipseRect, fillColor, null); } }
/// <summary> /// Draws the clipped line. /// </summary> /// <param name="rc">The render context.</param> /// <param name="points">The points.</param> /// <param name="clippingRectangle">The clipping rectangle.</param> /// <param name="minDistSquared">The min dist squared.</param> /// <param name="stroke">The stroke.</param> /// <param name="strokeThickness">The stroke thickness.</param> /// <param name="lineStyle">The line style.</param> /// <param name="lineJoin">The line join.</param> /// <param name="aliased">if set to <c>true</c> [aliased].</param> /// <param name="pointsRendered">The points rendered callback.</param> public static void DrawClippedLine( this IRenderContext rc, IList <ScreenPoint> points, OxyRect clippingRectangle, double minDistSquared, OxyColor stroke, double strokeThickness, LineStyle lineStyle, OxyPenLineJoin lineJoin, bool aliased, Action <IList <ScreenPoint> > pointsRendered = null) { var clipping = new CohenSutherlandClipping( clippingRectangle.Left, clippingRectangle.Right, clippingRectangle.Top, clippingRectangle.Bottom); var pts = new List <ScreenPoint>(); int n = points.Count; if (n > 0) { if (n == 1) { pts.Add(points[0]); } var last = points[0]; for (int i = 1; i < n; i++) { var s0 = points[i - 1]; var s1 = points[i]; // Clipped version of this and next point. var s0c = s0; var s1c = s1; bool isInside = clipping.ClipLine(ref s0c, ref s1c); s0 = s1; if (!isInside) { // keep the previous coordinate continue; } // render from s0c-s1c double dx = s1c.x - last.x; double dy = s1c.y - last.y; if (dx * dx + dy * dy > minDistSquared || i == 1 || i == n - 1) { if (!s0c.Equals(last) || i == 1) { pts.Add(s0c); } pts.Add(s1c); last = s1c; } // render the line if we are leaving the clipping region);); if (!clipping.IsInside(s1)) { if (pts.Count > 0) { rc.DrawLine( pts, stroke, strokeThickness, LineStyleHelper.GetDashArray(lineStyle), lineJoin, aliased); if (pointsRendered != null) { pointsRendered(pts); } pts = new List <ScreenPoint>(); } } } // Check if the line contains two points and they are at the same point if (pts.Count == 2) { if (pts[0].DistanceTo(pts[1]) < 1) { // Modify to a small horizontal line to make sure it is being rendered pts[1] = new ScreenPoint(pts[0].X + 1, pts[0].Y); pts[0] = new ScreenPoint(pts[0].X - 1, pts[0].Y); } } // Check if the line contains a single point if (pts.Count == 1) { // Add a second point to make sure the line is being rendered as a small dot pts.Add(new ScreenPoint(pts[0].X + 1, pts[0].Y)); pts[0] = new ScreenPoint(pts[0].X - 1, pts[0].Y); } if (pts.Count > 0) { rc.DrawLine(pts, stroke, strokeThickness, LineStyleHelper.GetDashArray(lineStyle), lineJoin, aliased); // Execute the 'callback'. if (pointsRendered != null) { pointsRendered(pts); } } } }
/// <summary> /// Renders the legend symbol for the line series on the /// specified rendering context. /// </summary> /// <param name="rc"> /// The rendering context. /// </param> /// <param name="legendBox"> /// The bounding rectangle of the legend box. /// </param> public override void RenderLegend(IRenderContext rc, OxyRect legendBox) { double xmid = (legendBox.Left + legendBox.Right) / 2; double ymid = (legendBox.Top + legendBox.Bottom) / 2; var pts = new[] { new ScreenPoint(legendBox.Left, ymid), new ScreenPoint(legendBox.Right, ymid) }; rc.DrawLine(pts, this.GetSelectableColor(this.ActualColor), this.StrokeThickness, LineStyleHelper.GetDashArray(this.ActualLineStyle)); var midpt = new ScreenPoint(xmid, ymid); rc.DrawMarker( midpt, legendBox, this.MarkerType, this.MarkerOutline, this.MarkerSize, this.MarkerFill, this.MarkerStroke, this.MarkerStrokeThickness); }