/// <summary> /// Draws the polygon from the specified points. The polygon can have stroke and/or fill. /// </summary> /// <param name="points">The points.</param> /// <param name="fill">The fill color.</param> /// <param name="stroke">The stroke color.</param> /// <param name="thickness">The stroke thickness.</param> /// <param name="dashArray">The dash array.</param> /// <param name="lineJoin">The line join type.</param> /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param> public override void DrawPolygon( IList <ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, OxyPlot.LineJoin lineJoin, bool aliased) { if (points.Count < 2) { return; } this.g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality; var pts = this.ToPoints(points); if (fill.IsVisible()) { this.g.FillPolygon(this.GetCachedBrush(fill), pts); } if (stroke.IsInvisible() || thickness <= 0) { return; } var pen = this.GetCachedPen(stroke, thickness, dashArray, lineJoin); this.g.DrawPolygon(pen, pts); }
/// <summary> /// Draws the polygon from the specified points. The polygon can have stroke and/or fill. /// </summary> /// <param name="points">The points.</param> /// <param name="fill">The fill color.</param> /// <param name="stroke">The stroke color.</param> /// <param name="thickness">The stroke thickness.</param> /// <param name="dashArray">The dash array.</param> /// <param name="lineJoin">The line join type.</param> /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param> public override void DrawPolygon( IList <ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, OxyPlot.LineJoin lineJoin, bool aliased) { if (points.Count < 2) { return; } this.g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality; var pts = this.ToPoints(points); if (fill.IsVisible() || stroke.IsVisible()) { float minX = pts.Min(p => p.X); float minY = pts.Min(p => p.Y); float maxX = pts.Max(p => p.X); float maxY = pts.Max(p => p.Y); this.GroundTruth[KeyPolygon].Add(new RectangleF(minX, minY, maxX - minX, maxY - minY)); } if (fill.IsVisible()) { this.g.FillPolygon(this.GetCachedBrush(fill), pts); } if (stroke.IsInvisible() || thickness <= 0) { return; } using (var pen = this.CreatePen(stroke, thickness)) { if (dashArray != null) { pen.DashPattern = this.ToFloatArray(dashArray); } switch (lineJoin) { case OxyPlot.LineJoin.Round: pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; break; case OxyPlot.LineJoin.Bevel: pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; break; // The default LineJoin is Miter } this.g.DrawPolygon(pen, pts); } }
/// <summary> /// Draws the polyline from the specified points. /// </summary> /// <param name="points">The points.</param> /// <param name="stroke">The stroke color.</param> /// <param name="thickness">The stroke thickness.</param> /// <param name="dashArray">The dash array.</param> /// <param name="lineJoin">The line join type.</param> /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param> public override void DrawLine( IList <ScreenPoint> points, OxyColor stroke, double thickness, double[] dashArray, OxyPlot.LineJoin lineJoin, bool aliased) { if (stroke.IsInvisible() || thickness <= 0 || points.Count < 2) { return; } this.g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality; using (var pen = this.CreatePen(stroke, thickness, dashArray, lineJoin)) { var pointFs = this.ToPoints(points); float minX = pointFs.Min(p => p.X); float minY = pointFs.Min(p => p.Y); float maxX = pointFs.Max(p => p.X); float maxY = pointFs.Max(p => p.Y); this.GroundTruth[KeyLine].Add(new RectangleF(minX, minY, maxX - minX, maxY - minY)); this.g.DrawLines(pen, pointFs); } }
/// <inheritdoc/> public override void DrawPolygon( IList <ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode, double[] dashArray, OxyPlot.LineJoin lineJoin) { if (points.Count < 2) { return; } this.SetSmoothingMode(this.ShouldUseAntiAliasingForLine(edgeRenderingMode, points)); var pts = this.ToPoints(points); if (fill.IsVisible()) { this.g.FillPolygon(this.GetCachedBrush(fill), pts); } if (stroke.IsInvisible() || thickness <= 0) { return; } var pen = this.GetCachedPen(stroke, thickness, dashArray, lineJoin); this.g.DrawPolygon(pen, pts); }
/// <summary> /// Draws the polygon from the specified points. The polygon can have stroke and/or fill. /// </summary> /// <param name="points">The points.</param> /// <param name="fill">The fill color.</param> /// <param name="stroke">The stroke color.</param> /// <param name="thickness">The stroke thickness.</param> /// <param name="dashArray">The dash array.</param> /// <param name="lineJoin">The line join type.</param> /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param> public override void DrawPolygon( IList <ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, OxyPlot.LineJoin lineJoin, bool aliased) { if (points.Count < 2) { return; } this.g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality; var pts = this.ToPoints(points); if (fill.IsVisible()) { this.g.FillPolygon(fill.ToBrush(), pts); } if (stroke.IsInvisible() || thickness <= 0) { return; } using (var pen = this.CreatePen(stroke, thickness)) { if (dashArray != null) { pen.DashPattern = this.ToFloatArray(dashArray); } switch (lineJoin) { case OxyPlot.LineJoin.Round: pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; break; case OxyPlot.LineJoin.Bevel: pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; break; // The default LineJoin is Miter } this.g.DrawPolygon(pen, pts); } }
/// <summary> /// Draws the polyline from the specified points. /// </summary> /// <param name="points">The points.</param> /// <param name="stroke">The stroke color.</param> /// <param name="thickness">The stroke thickness.</param> /// <param name="dashArray">The dash array.</param> /// <param name="lineJoin">The line join type.</param> /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param> public override void DrawLine( IList <ScreenPoint> points, OxyColor stroke, double thickness, double[] dashArray, OxyPlot.LineJoin lineJoin, bool aliased) { if (stroke.IsInvisible() || thickness <= 0 || points.Count < 2) { return; } this.g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality; var pen = this.GetCachedPen(stroke, thickness, dashArray, lineJoin); this.g.DrawLines(pen, this.ToPoints(points)); }
/// <inheritdoc/> public override void DrawLine( IList <ScreenPoint> points, OxyColor stroke, double thickness, EdgeRenderingMode edgeRenderingMode, double[] dashArray, OxyPlot.LineJoin lineJoin) { if (stroke.IsInvisible() || thickness <= 0 || points.Count < 2) { return; } this.SetSmoothingMode(this.ShouldUseAntiAliasingForLine(edgeRenderingMode, points)); var pen = this.GetCachedPen(stroke, thickness, dashArray, lineJoin); this.g.DrawLines(pen, this.ToPoints(points)); }
/// <summary> /// Gets a cached pen. /// </summary> /// <param name="stroke">The stroke.</param> /// <param name="thickness">The thickness.</param> /// <param name="dashArray">The dash array.</param> /// <param name="lineJoin">The line join.</param> /// <returns>A <see cref="Pen" />.</returns> private Pen CreatePen(OxyColor stroke, double thickness, double[] dashArray = null, OxyPlot.LineJoin lineJoin = OxyPlot.LineJoin.Miter) { var pen = new Pen(stroke.ToColor(), (float)thickness); if (dashArray != null) { pen.DashPattern = this.ToFloatArray(dashArray); } switch (lineJoin) { case OxyPlot.LineJoin.Round: pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Round; break; case OxyPlot.LineJoin.Bevel: pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; break; //// The default LineJoin is Miter } return(pen); }
/// <summary> /// Gets the cached pen. /// </summary> /// <param name="stroke">The stroke color.</param> /// <param name="thickness">The thickness.</param> /// <param name="dashArray">The dash array.</param> /// <param name="lineJoin">The line join.</param> /// <returns>A <see cref="Pen" />.</returns> private Pen GetCachedPen(OxyColor stroke, double thickness, double[] dashArray = null, OxyPlot.LineJoin lineJoin = OxyPlot.LineJoin.Miter) { GraphicsPenDescription description = new GraphicsPenDescription(stroke, thickness, dashArray, lineJoin); Pen pen; if (this.pens.TryGetValue(description, out pen)) { return(pen); } return(this.pens[description] = CreatePen(stroke, thickness, dashArray, lineJoin)); }