Ejemplo n.º 1
0
        public PlottableHLine(double position, Color color, double lineWidth, string label,
                              bool draggable, double dragLimitLower, double dragLimitUpper, LineStyle lineStyle)
        {
            this.position  = position;
            this.color     = color;
            this.label     = label;
            this.lineStyle = lineStyle;

            pen = GDI.Pen(color, (float)lineWidth, lineStyle, true);

            DragEnabled = draggable;

            SetLimits(x1: double.NegativeInfinity, x2: double.PositiveInfinity, y1: dragLimitLower, y2: dragLimitUpper);
        }
        public PlottableSignalOld(double[] ys, double sampleRate, double xOffset, double yOffset, Color color,
                                  double lineWidth, double markerSize, string label, Color[] colorByDensity,
                                  int minRenderIndex, int maxRenderIndex, LineStyle lineStyle, bool useParallel)
        {
            if (ys == null)
            {
                throw new Exception("Y data cannot be null");
            }

            this.ys           = ys;
            this.sampleRate   = sampleRate;
            this.samplePeriod = 1.0 / sampleRate;
            this.markerSize   = (float)markerSize;
            this.xOffset      = xOffset;
            this.label        = label;
            this.color        = color;
            this.lineWidth    = lineWidth;
            this.yOffset      = yOffset;
            if (minRenderIndex < 0 || minRenderIndex > maxRenderIndex)
            {
                throw new ArgumentException("minRenderIndex must be between 0 and maxRenderIndex");
            }
            this.minRenderIndex = minRenderIndex;
            if ((maxRenderIndex > ys.Length - 1) || maxRenderIndex < 0)
            {
                throw new ArgumentException("maxRenderIndex must be a valid index for ys[]");
            }
            this.maxRenderIndex = maxRenderIndex;
            this.lineStyle      = lineStyle;
            this.useParallel    = useParallel;
            brush = new SolidBrush(color);
            penLD = GDI.Pen(color, (float)lineWidth, lineStyle, true);
            penHD = GDI.Pen(color, (float)lineWidth, LineStyle.Solid, true);

            if (colorByDensity != null)
            {
                // turn the ramp into a pen triangle
                densityLevelCount = colorByDensity.Length * 2 - 1;
                penByDensity      = new Pen[densityLevelCount];
                for (int i = 0; i < colorByDensity.Length; i++)
                {
                    penByDensity[i] = new Pen(colorByDensity[i]);
                    penByDensity[densityLevelCount - 1 - i] = new Pen(colorByDensity[i]);
                }
            }
        }
Ejemplo n.º 3
0
        public void Render(Settings settings)
        {
            if ((Visible == false) || (LineWidth == 0))
            {
                return;
            }

            using (Pen pen = GDI.Pen(Colour, LineWidth, LineStyle))
            {
                if (Orientation == Orientation.Horizontal)
                {
                    RenderHorizontalLines(pen, settings);
                }
                else
                {
                    RenderVerticalLines(pen, settings);
                }
            }
        }
        public static void Distribution(Settings settings, Population pop, Random rand, double popLeft, double popWidth, Color color, Position position, LineStyle lineStyle)
        {
            // adjust edges to accomodate special positions
            if (position == Position.Hide)
            {
                return;
            }
            if (position == Position.Left || position == Position.Right)
            {
                popWidth /= 2;
            }
            if (position == Position.Right)
            {
                popLeft += popWidth;
            }

            // contract edges slightly to encourage padding between elements
            double edgePaddingFrac = 0.2;

            popLeft  += popWidth * edgePaddingFrac;
            popWidth -= (popWidth * edgePaddingFrac) * 2;

            Pen pen = GDI.Pen(color, 1, lineStyle, true);

            double[] ys     = DataGen.Range(pop.minus3stDev, pop.plus3stDev, settings.yAxisUnitsPerPixel);
            double[] ysFrac = pop.GetDistribution(ys);

            PointF[] points = new PointF[ys.Length];
            for (int i = 0; i < ys.Length; i++)
            {
                float x = (float)settings.GetPixelX(popLeft + popWidth * ysFrac[i]);
                float y = (float)settings.GetPixelY(ys[i]);
                points[i] = new PointF(x, y);
            }

            if (points.Length > 1)
            {
                settings.gfxData.DrawLines(pen, points);
            }
        }
Ejemplo n.º 5
0
        public PlottableErrorBars(double[] xs, double[] ys, double[] xPositiveError, double[] xNegativeError,
                                  double[] yPositiveError, double[] yNegativeError, Color color, double lineWidth, double capSize, string label)
        {
            //check input
            if (xs.Length != ys.Length)
            {
                throw new ArgumentException("X and Y arrays must have the same length");
            }

            //save properties
            this.xs             = xs;
            this.ys             = ys;
            this.xPositiveError = SanitizeErrors(xPositiveError, xs.Length);
            this.xNegativeError = SanitizeErrors(xNegativeError, xs.Length);
            this.yPositiveError = SanitizeErrors(yPositiveError, xs.Length);
            this.yNegativeError = SanitizeErrors(yNegativeError, xs.Length);
            this.capSize        = (float)capSize;
            this.color          = color;
            this.label          = label;

            penLine = GDI.Pen(this.color, (float)lineWidth, lineStyle, true);
        }
        public PlottableScatter(double[] xs, double[] ys, Color color, double lineWidth, double markerSize, string label,
                                double[] errorX, double[] errorY, double errorLineWidth, double errorCapSize, bool stepDisplay, MarkerShape markerShape, LineStyle lineStyle)
        {
            if ((xs == null) || (ys == null))
            {
                throw new ArgumentException("X and Y data cannot be null");
            }

            if ((xs.Length == 0) || (ys.Length == 0))
            {
                throw new ArgumentException("xs and ys must have at least one element");
            }

            if (xs.Length != ys.Length)
            {
                throw new ArgumentException("Xs and Ys must have same length");
            }

            if (errorY != null)
            {
                for (int i = 0; i < errorY.Length; i++)
                {
                    if (errorY[i] < 0)
                    {
                        errorY[i] = -errorY[i];
                    }
                }
            }

            if (errorX != null)
            {
                for (int i = 0; i < errorX.Length; i++)
                {
                    if (errorX[i] < 0)
                    {
                        errorX[i] = -errorX[i];
                    }
                }
            }

            this.xs             = xs;
            this.ys             = ys;
            this.color          = color;
            this.lineWidth      = lineWidth;
            this.markerSize     = (float)markerSize;
            this.label          = label;
            this.errorX         = errorX;
            this.errorY         = errorY;
            this.errorLineWidth = (float)errorLineWidth;
            this.errorCapSize   = (float)errorCapSize;
            this.stepDisplay    = stepDisplay;
            this.markerShape    = markerShape;
            this.lineStyle      = lineStyle;

            if (xs.Length != ys.Length)
            {
                throw new ArgumentException("X and Y arrays must have the same length");
            }

            if ((errorX != null) && (xs.Length != errorX.Length))
            {
                throw new ArgumentException("errorX must be the same length as the original data");
            }

            if ((errorY != null) && (xs.Length != errorY.Length))
            {
                throw new ArgumentException("errorY must be the same length as the original data");
            }

            penLine      = GDI.Pen(color, lineWidth, lineStyle, true);
            penLineError = GDI.Pen(color, errorLineWidth, LineStyle.Solid, true);
        }