protected override RadRect ArrangeCore(RadRect rect)
        {
            IChartView view = this.GetChartArea().view;

            RadRect  plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight);
            RadPoint point1, point2;

            double panOffsetX = view.PlotOriginX * rect.Width;
            double panOffsetY = view.PlotOriginY * rect.Height;

            if (this.axis.type == AxisType.First)
            {
                point1 = new RadPoint(panOffsetX + this.plotInfo.CenterX(plotAreaVirtualSize), plotAreaVirtualSize.Y + panOffsetY);
                point2 = new RadPoint(point1.X, plotAreaVirtualSize.Bottom + panOffsetY);
            }
            else
            {
                point1 = new RadPoint(plotAreaVirtualSize.X + panOffsetX, panOffsetY + this.plotInfo.CenterY(plotAreaVirtualSize));
                point2 = new RadPoint(plotAreaVirtualSize.Right + panOffsetX, point1.Y);
            }

            this.line = new RadLine(point1, point2);
            this.originalLayoutSlot = new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2));
            this.line = AnnotationHelper.ClipGridLine(this.line, rect, this.StrokeThickness * 2, this.DashPatternLength * this.StrokeThickness);
            this.line = RadLine.Round(this.line);

            return(new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2)));
        }
        protected override RadRect ArrangeCore(RadRect rect)
        {
            IChartView view = this.GetChartArea().view;
            RadRect    plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight);
            RadPoint   point1, point2;

            double panOffsetX = view.PlotOriginX * rect.Width;
            double panOffsetY = view.PlotOriginY * rect.Height;

            if (this.axis.type == AxisType.First)
            {
                point1 = new RadPoint(panOffsetX + this.firstPlotInfo.CenterX(plotAreaVirtualSize), plotAreaVirtualSize.Y + panOffsetY);
                point2 = new RadPoint(panOffsetX + this.secondPlotInfo.CenterX(plotAreaVirtualSize), plotAreaVirtualSize.Bottom + panOffsetY);
            }
            else
            {
                point1 = new RadPoint(plotAreaVirtualSize.X + panOffsetX, panOffsetY + this.firstPlotInfo.CenterY(plotAreaVirtualSize));
                point2 = new RadPoint(plotAreaVirtualSize.Right + panOffsetX, panOffsetY + this.secondPlotInfo.CenterY(plotAreaVirtualSize));
            }

            var arrangeRect = new RadRect(point1, point2);

            this.originalLayoutSlot = arrangeRect;
            return(AnnotationHelper.ClipRectangle(arrangeRect, rect, this.StrokeThickness * 2, this.DashPatternLength * this.StrokeThickness));
        }
Пример #3
0
        protected override RadRect ArrangeCore(RadRect rect)
        {
            IChartView view = this.GetChartArea().view;

            RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight);

            double panOffsetX = view.PlotOriginX * rect.Width;
            double panOffsetY = view.PlotOriginY * rect.Height;

            RadPoint point1 = new RadPoint(panOffsetX + this.horizontalFromPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.verticalFromPlotInfo.CenterY(plotAreaVirtualSize));
            RadPoint point2 = new RadPoint(panOffsetX + this.horizontalToPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.verticalToPlotInfo.CenterY(plotAreaVirtualSize));

            var arrangeRect = new RadRect(point1, point2);

            this.originalLayoutSlot = arrangeRect;
            return(AnnotationHelper.ClipRectangle(arrangeRect, rect, this.StrokeThickness * 2, this.DashPatternLength * this.StrokeThickness));
        }
Пример #4
0
        /// <summary>
        /// Clips the <paramref name="line"/> to the <paramref name="container"/>.
        /// </summary>
        /// <param name="line">The line to be clipped.</param>
        /// <param name="container">The container.</param>
        /// <param name="borderOverflow">The border (stroke thickness) of the <paramref name="line"/>.</param>
        /// <param name="dashPatternLength">The length of the dash pattern of the line stroke.</param>
        /// <returns>The clipped line.</returns>
        internal static RadLine ClipLine(RadLine line, RadRect container, double borderOverflow, double dashPatternLength)
        {
            // extend the container with the element border
            container.X      -= borderOverflow;
            container.Y      -= borderOverflow;
            container.Width  += 2 * borderOverflow;
            container.Height += 2 * borderOverflow;

            bool firstPointInside  = container.Contains(line.X1, line.Y1);
            bool secondPointInside = container.Contains(line.X2, line.Y2);

            if (firstPointInside && secondPointInside)
            {
                return(line);
            }

            if (dashPatternLength == 0 || double.IsNaN(dashPatternLength) || double.IsInfinity(dashPatternLength))
            {
                dashPatternLength = 1;
            }

            // find intersectionns of the line with the sides of the container
            double topIntersectionX    = RadMath.CalculateIntersectionX(line.X1, line.Y1, line.X2, line.Y2, container.Y);
            double bottomIntersectionX = RadMath.CalculateIntersectionX(line.X1, line.Y1, line.X2, line.Y2, container.Bottom);
            double leftIntersectionY   = RadMath.CalculateIntersectionY(line.X1, line.Y1, line.X2, line.Y2, container.X);
            double rightIntersectionY  = RadMath.CalculateIntersectionY(line.X1, line.Y1, line.X2, line.Y2, container.Right);

            // slope of the line: angle between the line ant the horizon (-pi/2, pi/2)
            var angle = Math.Atan((line.Y1 - line.Y2) / (line.X2 - line.X1));

            bool intersectsWithRect = false;

            // clip to container sides
            intersectsWithRect |= AnnotationHelper.TryClipToContainerTop(ref line, container, topIntersectionX, dashPatternLength, angle > 0 ? angle : Math.PI + angle);
            intersectsWithRect |= AnnotationHelper.TryClipToContainerBottom(ref line, container, bottomIntersectionX, dashPatternLength, angle > 0 ? angle : Math.PI + angle);
            intersectsWithRect |= AnnotationHelper.TryClipToContainerLeft(ref line, container, leftIntersectionY, dashPatternLength, angle);
            intersectsWithRect |= AnnotationHelper.TryClipToContainerRight(ref line, container, rightIntersectionY, dashPatternLength, angle);

            if (!intersectsWithRect)
            {
                line = new RadLine();
            }

            return(line);
        }
Пример #5
0
        protected override RadRect ArrangeCore(RadRect rect)
        {
            IChartView view = this.GetChartArea().view;

            RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight);

            double panOffsetX = view.PlotOriginX * rect.Width;
            double panOffsetY = view.PlotOriginY * rect.Height;

            RadPoint point1 = new RadPoint(panOffsetX + this.horizontalFromPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.verticalFromPlotInfo.CenterY(plotAreaVirtualSize));
            RadPoint point2 = new RadPoint(panOffsetX + this.horizontalToPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.verticalToPlotInfo.CenterY(plotAreaVirtualSize));

            this.line = new RadLine(point1, point2);
            this.originalLayoutSlot = new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2));
            this.line = AnnotationHelper.ClipLine(this.line, rect, 2 * this.StrokeThickness, this.DashPatternLength * this.StrokeThickness);
            this.line = RadLine.Round(this.line);

            return(new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2)));
        }