Esempio n. 1
0
 /// <summary>
 /// Renders the axis on the specified render context.
 /// </summary>
 /// <param name="rc">The render context.</param>
 /// <param name="model">The model.</param>
 /// <param name="axisLayer">The rendering order.</param>
 /// <param name="pass">The pass.</param>
 public virtual void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass)
 {
     var r = new HorizontalAndVerticalAxisRenderer(rc, model);
     r.Render(this, pass);
 }
Esempio n. 2
0
File: Axis.cs Progetto: Keyabob/MMG
 /// <summary>
 /// Renders the axis on the specified render context.
 /// </summary>
 /// <param name="rc">The render context.</param>
 /// <param name="pass">The pass.</param>
 public virtual void Render(IRenderContext rc, int pass)
 {
     var r = new HorizontalAndVerticalAxisRenderer(rc, this.PlotModel);
     r.Render(this, pass);
 }
Esempio n. 3
0
        /// <summary>
        /// Renders the axis on the specified render context.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="pass">The render pass.</param>
        public override void Render(IRenderContext rc, int pass)
        {
            if (this.Position == AxisPosition.None)
            {
                return;
            }

            if (pass == 0)
            {
                double distance = this.AxisDistance;
                double left     = this.PlotModel.PlotArea.Left;
                double top      = this.PlotModel.PlotArea.Top;
                double width    = this.MajorTickSize - 2;
                double height   = this.MajorTickSize - 2;

                const int TierShift = 0;

                switch (this.Position)
                {
                case AxisPosition.Left:
                    left = this.PlotModel.PlotArea.Left - TierShift - width - distance;
                    top  = this.PlotModel.PlotArea.Top;
                    break;

                case AxisPosition.Right:
                    left = this.PlotModel.PlotArea.Right + TierShift + distance;
                    top  = this.PlotModel.PlotArea.Top;
                    break;

                case AxisPosition.Top:
                    left = this.PlotModel.PlotArea.Left;
                    top  = this.PlotModel.PlotArea.Top - TierShift - height - distance;
                    break;

                case AxisPosition.Bottom:
                    left = this.PlotModel.PlotArea.Left;
                    top  = this.PlotModel.PlotArea.Bottom + TierShift + distance;
                    break;
                }

                Action <double, double, OxyColor> drawColorRect = (ylow, yhigh, color) =>
                {
                    double ymin = Math.Min(ylow, yhigh);
                    double ymax = Math.Max(ylow, yhigh);
                    rc.DrawRectangle(
                        this.IsHorizontal()
                            ? new OxyRect(ymin, top, ymax - ymin, height)
                            : new OxyRect(left, ymin, width, ymax - ymin),
                        color,
                        OxyColors.Undefined);
                };

                // if the axis is reversed then the min and max values need to be swapped.
                double effectiveMaxY = this.Transform(this.IsReversed ? this.ActualMinimum : this.ActualMaximum);
                double effectiveMinY = this.Transform(this.IsReversed ? this.ActualMaximum : this.ActualMinimum);

                foreach (ColorRange range in this.ranges)
                {
                    double ylow  = this.Transform(range.LowerBound);
                    double yhigh = this.Transform(range.UpperBound);

                    if (this.IsHorizontal())
                    {
                        if (ylow < effectiveMinY)
                        {
                            ylow = effectiveMinY;
                        }

                        if (yhigh > effectiveMaxY)
                        {
                            yhigh = effectiveMaxY;
                        }
                    }
                    else
                    {
                        if (ylow > effectiveMinY)
                        {
                            ylow = effectiveMinY;
                        }

                        if (yhigh < effectiveMaxY)
                        {
                            yhigh = effectiveMaxY;
                        }
                    }

                    drawColorRect(ylow, yhigh, range.Color);
                }

                double highLowLength = 10;
                if (this.IsHorizontal())
                {
                    highLowLength *= -1;
                }

                if (!this.LowColor.IsUndefined())
                {
                    double ylow = this.Transform(this.ActualMinimum);
                    drawColorRect(ylow, ylow + highLowLength, this.LowColor);
                }

                if (!this.HighColor.IsUndefined())
                {
                    double yhigh = this.Transform(this.ActualMaximum);
                    drawColorRect(yhigh, yhigh - highLowLength, this.HighColor);
                }
            }

            var r = new HorizontalAndVerticalAxisRenderer(rc, this.PlotModel);

            r.Render(this, pass);
        }
Esempio n. 4
0
        /// <summary>
        /// Renders the axis on the specified render context.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="pass">The render pass.</param>
        public override void Render(IRenderContext rc, int pass)
        {
            if (this.Position == AxisPosition.None)
            {
                return;
            }

            if (pass == 0)
            {
                double distance = this.AxisDistance;
                double left = this.PlotModel.PlotArea.Left;
                double top = this.PlotModel.PlotArea.Top;
                double width = this.MajorTickSize - 2;
                double height = this.MajorTickSize - 2;

                const int TierShift = 0;

                switch (this.Position)
                {
                    case AxisPosition.Left:
                        left = this.PlotModel.PlotArea.Left - TierShift - width - distance;
                        top = this.PlotModel.PlotArea.Top;
                        break;
                    case AxisPosition.Right:
                        left = this.PlotModel.PlotArea.Right + TierShift + distance;
                        top = this.PlotModel.PlotArea.Top;
                        break;
                    case AxisPosition.Top:
                        left = this.PlotModel.PlotArea.Left;
                        top = this.PlotModel.PlotArea.Top - TierShift - height - distance;
                        break;
                    case AxisPosition.Bottom:
                        left = this.PlotModel.PlotArea.Left;
                        top = this.PlotModel.PlotArea.Bottom + TierShift + distance;
                        break;
                }

                Action<double, double, OxyColor> drawColorRect = (ylow, yhigh, color) =>
                {
                    double ymin = Math.Min(ylow, yhigh);
                    double ymax = Math.Max(ylow, yhigh);
                    rc.DrawRectangle(
                        this.IsHorizontal()
                            ? new OxyRect(ymin, top, ymax - ymin, height)
                            : new OxyRect(left, ymin, width, ymax - ymin),
                        color,
                        OxyColors.Undefined);
                };

                foreach (ColorRange range in this.ranges)
                {
                    double ylow = this.Transform(range.LowerBound);
                    double yhigh = this.Transform(range.UpperBound);

                    double ymax = this.Transform(this.ActualMaximum);
                    double ymin = this.Transform(this.ActualMinimum);

                    if (this.IsHorizontal())
                    {
                        if (ylow < ymin)
                        {
                            ylow = ymin;
                        }

                        if (yhigh > ymax)
                        {
                            yhigh = ymax;
                        }
                    }
                    else
                    {
                        if (ylow > ymin)
                        {
                            ylow = ymin;
                        }

                        if (yhigh < ymax)
                        {
                            yhigh = ymax;
                        }
                    }

                    drawColorRect(ylow, yhigh, range.Color);
                }

                double highLowLength = 10;
                if (this.IsHorizontal())
                {
                    highLowLength *= -1;
                }

                if (!this.LowColor.IsUndefined())
                {
                    double ylow = this.Transform(this.ActualMinimum);
                    drawColorRect(ylow, ylow + highLowLength, this.LowColor);
                }

                if (!this.HighColor.IsUndefined())
                {
                    double yhigh = this.Transform(this.ActualMaximum);
                    drawColorRect(yhigh, yhigh - highLowLength, this.HighColor);
                }
            }

            var r = new HorizontalAndVerticalAxisRenderer(rc, this.PlotModel);
            r.Render(this, pass);
        }