Beispiel #1
0
        /// <summary>
        /// Renders the point labels.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="clippingRect">The clipping rectangle.</param>
        protected void RenderPointLabels(IRenderContext rc, OxyRect clippingRect)
        {
            int index = -1;
            foreach (var point in this.ActualPoints)
            {
                index++;

                if (!this.IsValidPoint(point))
                {
                    continue;
                }

                var pt = this.Transform(point) + new ScreenVector(0, -this.LabelMargin);

                if (!clippingRect.Contains(pt))
                {
                    continue;
                }

                var item = this.GetItem(index);
                var s = StringHelper.Format(this.ActualCulture, this.LabelFormatString, item, point.X, point.Y);

            #if SUPPORTLABELPLACEMENT
                    switch (this.LabelPlacement)
                    {
                        case LabelPlacement.Inside:
                            pt = new ScreenPoint(rect.Right - this.LabelMargin, (rect.Top + rect.Bottom) / 2);
                            ha = HorizontalAlignment.Right;
                            break;
                        case LabelPlacement.Middle:
                            pt = new ScreenPoint((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2);
                            ha = HorizontalAlignment.Center;
                            break;
                        case LabelPlacement.Base:
                            pt = new ScreenPoint(rect.Left + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
                            ha = HorizontalAlignment.Left;
                            break;
                        default: // Outside
                            pt = new ScreenPoint(rect.Right + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
                            ha = HorizontalAlignment.Left;
                            break;
                    }
            #endif

                rc.DrawClippedText(
                    clippingRect,
                    pt,
                    s,
                    this.ActualTextColor,
                    this.ActualFont,
                    this.ActualFontSize,
                    this.ActualFontWeight,
                    0,
                    HorizontalAlignment.Center,
                    VerticalAlignment.Bottom);
            }
        }
Beispiel #2
0
        public override void Render(IRenderContext rc,PlotModel modle1)
        {
            PlotModel model = this.PlotModel;
            Axis axis = ((MapPlotModel)model).GetAxis(this.YKey);
            rc.ResetClip();

            if (!SeriesVisible || !((IAxis)axis).AxisVisible)
                return;

            if (_points.Count > 0)
            {
                if (!_performed)
                {
                    double tip_font_size = 20;
                    string tip = this.Title;
                    OxySize size = rc.MeasureText(tip, this.ActualFont, tip_font_size);
                    OxyRect bound = ((IAxis)axis).Bound;
                    double y = bound.Top + (bound.Height-size.Height) / 2;
                    double x = (bound.Width - size.Width) / 2 + bound.Left;
                    rc.DrawText(new ScreenPoint(x, y), tip, this.Color, this.ActualFont, tip_font_size);
                }
            }

            if (_iso_line.LineStrings.Count == 0 )
                return;

            OxyColor average_color = OxyColors.Green;
            OxyColor limit_color = OxyColors.Red;
            if (Theme != null)
            {
                LineSeriesStyle style = Theme.GetStyle(ThemeMode) as LineSeriesStyle;
                this.Color = Helper.ConvertColorToOxyColor(style.LineColor);
                average_color = Helper.ConvertColorToOxyColor(style.AverageColor);
                limit_color = Helper.ConvertColorToOxyColor(style.AlarmColor);
            }          

            OxyRect clippingRect = model.PlotArea;
            for (int i = 0; i < _iso_line.LineStrings.Count; i++)
            {
                LineString line = _iso_line.LineStrings[i];
                bool invalid = false;
                if (line.VPoints.Count > 0)
                {
                    for (int j = 0; j < line.VPoints.Count; j++)
                    {
                        double x = this.XAxis.Transform(line.VPoints[j].X);
                        double y = axis.Transform(line.VPoints[j].Y);

                        if (clippingRect.Contains(x, y))
                        {
                            invalid = true;
                        }
                    }
                }
                else
                    invalid = true;
                if (!invalid)
                    continue;

                if (line.Points.Count > 0)
                {
                    IList<ScreenPoint> sps = new List<ScreenPoint>();
                    for (int j = 0; j < line.Points.Count; j++)
                    {
                        double x = this.XAxis.Transform(line.Points[j].X);
                        double y = axis.Transform(line.Points[j].Y);
                        sps.Add(new ScreenPoint(x, y));
                    }

                    if (line.Value >= 99999 || line.Value<-99999)
                    {
                        continue;
                    }
                    if (line.Value > DashLimit)
                        base.RenderLine(rc, clippingRect, sps, Color, this.LineWidth,this.LineStyle);
                    else
                    {
                        base.RenderLine(rc, clippingRect, sps, Color, this.LineWidth, LineStyle.Dash);
                    }
                }
                
                if (line.VPoints.Count > 0)
                {
                    for (int j = 0; j < line.VPoints.Count; j++)
                    {
                        double x = this.XAxis.Transform(line.VPoints[j].X);
                        double y = axis.Transform(line.VPoints[j].Y);

                        if (clippingRect.Contains(x, y))
                        {
                            rc.DrawText(new ScreenPoint(x, y), line.Value.ToString("f1"), this.Color);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// The add contour labels.
        /// </summary>
        /// <param name="contour">The contour.</param>
        /// <param name="pts">The points of the contour.</param>
        /// <param name="clippingRect">The clipping rectangle.</param>
        /// <param name="contourLabels">The contour labels.</param>
        private void AddContourLabels(Contour contour, ScreenPoint[] pts, OxyRect clippingRect, ICollection<ContourLabel> contourLabels)
        {
            // todo: support label spacing and label step
            if (pts.Length < 2)
            {
                return;
            }

            // Calculate position and angle of the label
            double i = (pts.Length - 1) * 0.5;
            var i0 = (int)i;
            int i1 = i0 + 1;
            double dx = pts[i1].X - pts[i0].X;
            double dy = pts[i1].Y - pts[i0].Y;
            double x = pts[i0].X + (dx * (i - i0));
            double y = pts[i0].Y + (dy * (i - i0));
            if (!clippingRect.Contains(x, y))
            {
                return;
            }

            var pos = new ScreenPoint(x, y);
            double angle = Math.Atan2(dy, dx) * 180 / Math.PI;
            if (angle > 90)
            {
                angle -= 180;
            }

            if (angle < -90)
            {
                angle += 180;
            }

            var formatString = string.Concat("{0:", this.LabelFormatString, "}");
            string text = string.Format(this.ActualCulture, formatString, contour.ContourLevel);
            contourLabels.Add(new ContourLabel { Position = pos, Angle = angle, Text = text });
        }
Beispiel #4
0
        /// <summary>
        /// Renders the point labels.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="clippingRect">The clipping rectangle.</param>
        protected void RenderPointLabels(IRenderContext rc, OxyRect clippingRect)
        {
            int index = -1;

            foreach (var point in this.ActualPoints)
            {
                index++;

                if (!this.IsValidPoint(point))
                {
                    continue;
                }

                var pt = this.Transform(point) + new ScreenVector(0, -this.LabelMargin);

                if (!clippingRect.Contains(pt))
                {
                    continue;
                }

                var item = this.GetItem(index);
                var s    = this.Format(this.LabelFormatString, item, point.X, point.Y);

#if SUPPORTLABELPLACEMENT
                switch (this.LabelPlacement)
                {
                case LabelPlacement.Inside:
                    pt = new ScreenPoint(rect.Right - this.LabelMargin, (rect.Top + rect.Bottom) / 2);
                    ha = HorizontalAlignment.Right;
                    break;

                case LabelPlacement.Middle:
                    pt = new ScreenPoint((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2);
                    ha = HorizontalAlignment.Center;
                    break;

                case LabelPlacement.Base:
                    pt = new ScreenPoint(rect.Left + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
                    ha = HorizontalAlignment.Left;
                    break;

                default:         // Outside
                    pt = new ScreenPoint(rect.Right + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
                    ha = HorizontalAlignment.Left;
                    break;
                }
#endif

                rc.DrawClippedText(
                    clippingRect,
                    pt,
                    s,
                    this.ActualTextColor,
                    this.ActualFont,
                    this.ActualFontSize,
                    this.ActualFontWeight,
                    0,
                    HorizontalAlignment.Center,
                    VerticalAlignment.Bottom);
            }
        }