public override void SetupPen(Pen pen, LineBase line, PointPair dataValue)
 {
     if(callback(dataValue))
         DefaultSetup(line, pen);
     else
         pen.DashStyle = DashStyle.Solid;
 }
        public void Page_Load(object sender, EventArgs e)
        {
            Double donnéeDeCourbe = 6.5;

            double[] x        = new double[100];
            double[] maximum  = new double[100];
            double[] minimum  = new double[100];
            double[] moyenne  = new double[100];
            double[] variable = new double[100];

            for (int i = 0; i < x.Length; i++)
            {
                x[i] = i;
                maximum[i] = 9;
                minimum[i] = 3;
                moyenne[i] = 6;
                variable[i] = donnéeDeCourbe;
            }

            // This is to remove all plots
            zedGraphControl1.GraphPane.CurveList.Clear();

            GraphPane myPane = zedGraphControl1.GraphPane;

            // Définis la liste des points
            PointPairList spl1 = new PointPairList(x, maximum);
            PointPairList spl2 = new PointPairList(x, minimum);
            PointPairList spl3 = new PointPairList(x, moyenne);
            PointPairList spl4 = new PointPairList(x, variable);
            PointPairList Ppl = new PointPairList();
            int y =0;
            foreach (Ech_Resultat Er in Ech_ResultatDB.List())
            {
                y++;
                PointPair Pp = new PointPair(y, Er.Resultat, EchantillonDB.Get(Er.ID_Echantillon).NumLot);
                Ppl.Add(Pp);
            }

            // Ajouter les lignes a mon graphique
            LineItem myCurve1 = myPane.AddCurve("", spl1, Color.DarkBlue, SymbolType.None);
            LineItem myCurve2 = myPane.AddCurve("Minimum Maximum", spl2, Color.DarkBlue, SymbolType.None);
            LineItem myCurve3 = myPane.AddCurve("moyenne", spl3, Color.Black, SymbolType.None);
            LineItem myCurve4 = myPane.AddCurve("Resultat", Ppl, Color.ForestGreen, SymbolType.Diamond);

            myCurve1.Line.Width = 2.0F;
            myCurve2.Line.Width = 2.0F;
            myCurve3.Line.Width = 2.0F;
            myCurve4.Line.Width = 2.0F;

            myPane.Title.Text = "Graphique épaisseur peinture";
            myPane.XAxis.Title.Text = "Test";
            myPane.YAxis.Title.Text = "Epaisseur peinture";
            myPane.Legend.Position = ZedGraph.LegendPos.Bottom;

            // I add all three functions just to be sure it refeshes the plot.
            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
            zedGraphControl1.Refresh();
        }
Example #3
0
        public void UpdateGraph()
        {
            zedGraphControl.GraphPane.GraphObjList.Clear();
            zedGraphControl.GraphPane.CurveList.Clear();
            var currentRow = bindingSource.Current as DataRow;
            var target = comboTarget.SelectedItem;
            if (currentRow != null)
            {
                var refinedPoints = new PointPairList();
                var outliers = new PointPairList();
                var regression = currentRow.Refined ?? currentRow.Unrefined;
                if (regression != null && regression.OriginalTimes.Count > 0)
                {
                    var outlierIndexes = regression.OutlierIndexes;
                    for (int i = 0; i < regression.TotalCount; i++)
                    {
                        var point = new PointPair(regression.OriginalTimes[i], regression.TargetTimes[i], currentRow.RegressedPeptides[i]);
                        if (outlierIndexes.Contains(i))
                        {
                            outliers.Add(point);
                        }
                        else
                        {
                            refinedPoints.Add(point);
                        }
                    }
                    var refinedScatter = zedGraphControl.GraphPane.AddCurve("Refined Points", refinedPoints, Color.Black, SymbolType.Diamond);
                    refinedScatter.Symbol.Size = 8f;
                    refinedScatter.Line.IsVisible = false;
                    refinedScatter.Symbol.Border.IsVisible = false;
                    refinedScatter.Symbol.Fill = new Fill(Color.DarkBlue);
                    if (outliers.Count > 0)
                    {
                        var outlierScatter = zedGraphControl.GraphPane.AddCurve("Outliers", outliers, Color.Black,
                                                                                   SymbolType.Diamond);
                        outlierScatter.Symbol.Size = 8f;
                        outlierScatter.Line.IsVisible = false;
                        outlierScatter.Symbol.Border.IsVisible = false;
                        outlierScatter.Symbol.Fill = new Fill(Color.BlueViolet);
                    }
                    double xMin = regression.OriginalTimes.Min();
                    double xMax = regression.OriginalTimes.Max();
                    var regressionLine = zedGraphControl.GraphPane
                        .AddCurve("Regression line", new[] { xMin, xMax },
                            new[] { xMin * regression.Slope + regression.Intercept,xMax * regression.Slope + regression.Intercept},
                            Color.Black);
                    regressionLine.Symbol.IsVisible = false;
                    zedGraphControl.GraphPane.Title.Text = string.Format("Alignment of {0} to {1}",
                        currentRow.MsDataFile,
                        target);
                    zedGraphControl.GraphPane.XAxis.Title.Text
                        = string.Format("Time from {0}", currentRow.DataFile);
                    zedGraphControl.GraphPane.YAxis.Title.Text = "Aligned time";
                    zedGraphControl.GraphPane.AxisChange();
                    zedGraphControl.Invalidate();

                }
            }
        }
 public void addPoint(PointPair p)
 {
     if (points.Count >= 3)
     {
         throw new BarierIsFull("Введены все точки препятствия");
     }
     p.Y = interval.profile.getY(p.X);
     points.Add(p);
     points.Sort();
 }
        public void editPoint(int index, PointPair p, PointPair oldP)
        {
            if (!interval.isPointOnInterval(p))
            {
                points[index] = oldP;
                throw new InvalidPointPositon(p.ToString());
            }

            p.Y = interval.profile.getY(p.X);
            points[index] = p;
            points.Sort();
        }
        public void RenderTimeTaken()
        {
            ClearSeries();

            var parser = new ResultsParser();
            var times = parser.TimeLineDataForIndividualRequest(Results,Url);

            var pane = Chart.GraphPane;

            pane.Title.Text = "Time taken per request for\r\n" + Url;
            pane.Title.FontSpec.FontColor = Color.DarkBlue;
            pane.Title.FontSpec.Size = 14.25F;
            pane.Title.FontSpec.IsBold = true;

            pane.LineType = LineType.Normal;
            pane.XAxis.Title.Text = "Request number";
            pane.YAxis.Title.Text = "milli-seconds";
            pane.Chart.Fill = new Fill(Color.LightYellow, Color.PaleGoldenrod, 45.0F);
            Chart.IsShowPointValues = true;

            PointPairList series = new PointPairList();

            foreach (var req in times.Where( t=> !t.IsError ))
            {
                var pt = new PointPair(req.RequestNo, req.TimeTaken,req.TimeTaken.ToString());
                series.Add(pt);
            }

            var curve = pane.AddCurve("Success", series, Color.Green, SymbolType.Circle);
            curve.Line.Width = 2.0F;
            curve.Line.IsAntiAlias = true;
            curve.Symbol.Fill = new Fill(Color.LightYellow);
            curve.Symbol.Size = 4;

            PointPairList series2 = new PointPairList();

            foreach (var req in times.Where( t=> t.IsError ))
            {
                var point = new PointPair(req.TimeTaken,req.RequestNo);
                series2.Add(point);
            }

            var curve2 = pane.AddCurve("Errors", series2, Color.Red);
            curve2.Line.Width = 2.0F;
            curve2.Line.IsAntiAlias = true;
            curve2.Symbol.Fill = new Fill(Color.White);
            curve2.Symbol.Size = 4;

            // Force refresh of chart
            pane.AxisChange();
        }
        // Indexer: get the Sample instance at the specified ordinal position in the list
        public PointPair this[int index]
        {
            get
            {
                PointPair pt = new PointPair();
                DateTimePlotPoint aPoint = aList[index];
                pt.X = GetValue(aPoint, XType);
                pt.Y = GetValue(aPoint, YType);
                pt.Tag = aPoint.Tag;
                return pt;
            }
            set
            {

            }
        }
Example #8
0
		/// <summary> 
		/// Indexer to access the specified <see cref="PointPair"/> object by 
		/// its ordinal position in the list. 
		/// </summary> 
		/// <param name="index">The ordinal position (zero-based) of the 
		/// <see cref="PointPair"/> object to be accessed.</param> 
		/// <value>A <see cref="PointPair"/> object reference.</value> 
		public PointPair this[int index] {
			get {
				if (index < 0 || index >= _bindingSource.Count)
					throw new System.ArgumentOutOfRangeException("Error: Index out of range");

				object row = _bindingSource[index];

				double x = GetDouble(row, _xDataMember, index);
				double y = GetDouble(row, _yDataMember, index);
				double z = GetDouble(row, _zDataMember, index);
				object tag = GetObject(row, _tagDataMember);

				PointPair pt = new PointPair(x, y, z);
				pt.Tag = tag;
				return pt;
			}
		}
Example #9
0
        private void addPaneToMaster(MasterPane master, List <double> degree, List <string> labels, string titlePrefix)
        {
            GraphPane myPane = new GraphPane();

            myPane.Title.Text       = titlePrefix;
            myPane.XAxis.Title.Text = "site";
            myPane.YAxis.Title.Text = titlePrefix + "Visible neighbourhood";
            myPane.XAxis.Scale.Max  = 27;
            myPane.Border.IsVisible = false;
            LineItem myLine = myPane.AddCurve("", null, degree.ToArray(), Color.Red, SymbolType.Circle);

            myLine.Symbol.Fill.IsVisible = true;
            myLine.Symbol.Fill           = new Fill(Color.Red);
            for (int s = 0; s < myLine.Points.Count; s++)
            {
                ZedGraph.PointPair pt   = myLine.Points[s];
                ZedGraph.TextObj   text = new ZedGraph.TextObj(labels[s], pt.X, pt.Y,
                                                               ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center);
                text.FontSpec.FontColor = Color.Black;
                text.ZOrder             = ZedGraph.ZOrder.A_InFront;
                // Hide the border and the fill
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible   = false;
                text.FontSpec.Size             = 15f;
                text.FontSpec.Angle            = 90;

                string lblString = "name";

                Link lblLink = new Link(lblString, "#", "");
                text.Link = lblLink;
                myPane.GraphObjList.Add(text);
            }

            myLine.Line.IsVisible = false;
            myLine.Symbol.Size    = 5f;
            master.Add(myPane);
        }
Example #10
0
 /// <summary>
 /// Return the zero-based position index of the specified
 /// <see cref="PointPair"/> in the collection.
 /// </summary>
 /// <param name="pt">The <see cref="PointPair"/> object that is to be found.
 /// </param>
 /// <returns>The zero-based index of the specified <see cref="PointPair"/>, or -1 if the <see cref="PointPair"/>
 /// is not in the list</returns>
 /// <seealso cref="IList.IndexOf"/>
 public int IndexOf(PointPair pt)
 {
     return(List.IndexOf(pt));
 }
Example #11
0
		/// <summary>
		/// Draw the <see cref="ErrorBar"/> to the specified <see cref="Graphics"/>
		/// device at the specified location.
		/// </summary>
		/// <param name="g">
		/// A graphic device object to be drawn into.  This is normally e.Graphics from the
		/// PaintEventArgs argument to the Paint() method.
		/// </param>
		/// <param name="pane">
		/// A reference to the <see cref="GraphPane"/> object that is the parent or
		/// owner of this object.
		/// </param>
		/// <param name="isXBase">boolean value that indicates if the "base" axis for this
		/// <see cref="ErrorBar"/> is the X axis.  True for an <see cref="XAxis"/> base,
		/// false for a <see cref="YAxis"/> or <see cref="Y2Axis"/> base.</param>
		/// <param name="pixBase">The independent axis position of the center of the error bar in
		/// pixel units</param>
		/// <param name="pixValue">The dependent axis position of the top of the error bar in
		/// pixel units</param>
		/// <param name="pixLowValue">The dependent axis position of the bottom of the error bar in
		/// pixel units</param>
		/// <param name="scaleFactor">
		/// The scaling factor for the features of the graph based on the <see cref="PaneBase.BaseDimension"/>.  This
		/// scaling factor is calculated by the <see cref="PaneBase.CalcScaleFactor"/> method.  The scale factor
		/// represents a linear multiple to be applied to font sizes, symbol sizes, etc.</param>
		/// <param name="pen">A pen with attributes of <see cref="Color"/> and
		/// <see cref="PenWidth"/> for this <see cref="ErrorBar"/></param>
		/// <param name="dataValue">The data value to be used for a value-based
		/// color gradient.  This is only applicable for <see cref="FillType.GradientByX"/>,
		/// <see cref="FillType.GradientByY"/> or <see cref="FillType.GradientByZ"/>.</param>
		/// <param name="isSelected">Indicates that the <see cref="ErrorBar" /> should be drawn
		/// with attributes from the <see cref="Selection" /> class.
		/// </param>
		public void Draw( Graphics g, GraphPane pane, bool isXBase,
								float pixBase, float pixValue,
								float pixLowValue, float scaleFactor, Pen pen, bool isSelected,
								PointPair dataValue )
		{
			if ( isXBase )
			{
				g.DrawLine( pen, pixBase, pixValue, pixBase, pixLowValue );
				_symbol.DrawSymbol( g, pane, (int)pixBase, (int)pixValue,
							scaleFactor, isSelected, dataValue );
				_symbol.DrawSymbol( g, pane, (int)pixBase, (int)pixLowValue,
							scaleFactor, isSelected, dataValue );
			}
			else
			{
				g.DrawLine( pen, pixValue, pixBase, pixLowValue, pixBase );
				_symbol.DrawSymbol( g, pane, (int)pixValue, (int)pixBase,
							scaleFactor, isSelected, dataValue );
				_symbol.DrawSymbol( g, pane, (int)pixLowValue, (int)pixBase,
							scaleFactor, isSelected, dataValue );
			}
		}
Example #12
0
        /// <summary>
        /// Create a fill brush using current properties.  This method will construct a brush based on the
        /// settings of <see cref="ZedGraph.Fill.Type"/>, <see cref="ZedGraph.Fill.Color"/>
        /// and <see cref="ZedGraph.Fill.Brush"/>.  If
        /// <see cref="ZedGraph.Fill.Type"/> is set to <see cref="ZedGraph.FillType.Brush"/> and
        /// <see cref="ZedGraph.Fill.Brush"/>
        /// is null, then a <see cref="LinearGradientBrush"/> will be created between the colors of
        /// <see cref="System.Drawing.Color.White"/> and <see cref="ZedGraph.Fill.Color"/>.
        /// </summary>
        /// <param name="rect">A rectangle that bounds the object to be filled.  This determines
        /// the start and end of the gradient fill.</param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable for <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/> or <see cref="FillType.GradientByZ"/>.</param>
        /// <returns>A <see cref="System.Drawing.Brush"/> class representing the fill brush</returns>
        public Brush MakeBrush(RectangleF rect, PointPair dataValue)
        {
            // get a brush
            if (IsVisible && (!_color.IsEmpty || _brush != null))
            {
                if (rect.Height < 1.0F)
                {
                    rect.Height = 1.0F;
                }
                if (rect.Width < 1.0F)
                {
                    rect.Width = 1.0F;
                }

                //Brush	brush;
                if (_type == FillType.Brush)
                {
                    return(ScaleBrush(rect, _brush, _isScaled));
                }
                else if (IsGradientValueType)
                {
                    if (dataValue != null)
                    {
                        if (!_secondaryValueGradientColor.IsEmpty)
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            var tmpFill = new Fill(_secondaryValueGradientColor,
                                                   GetGradientColor(dataValue), _angle);
                            return(tmpFill.MakeBrush(rect));
                        }
                        else
                        {
                            return(new SolidBrush(GetGradientColor(dataValue)));
                        }
                    }
                    else if (_rangeDefault != double.MaxValue)
                    {
                        if (!_secondaryValueGradientColor.IsEmpty)
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            var tmpFill = new Fill(_secondaryValueGradientColor,
                                                   GetGradientColor(_rangeDefault), _angle);
                            return(tmpFill.MakeBrush(rect));
                        }
                        else
                        {
                            return(new SolidBrush(GetGradientColor(_rangeDefault)));
                        }
                    }
                    else
                    {
                        return(ScaleBrush(rect, _brush, true));
                    }
                }
                else
                {
                    return(new SolidBrush(_color));
                }
            }

            // Always return a suitable default
            return(new SolidBrush(Color.White));
        }
Example #13
0
        string zedGraphControl1_PointValueEvent(ZedGraphControl sender, GraphPane pane, CurveItem curve, int iPt)
        {

            if (curve[iPt] != ppHover)
            {
                ppHover = curve[iPt];
                if (pictureBox1.Visible)
                {
                    pictureBox1.Visible = false;
                }
                if (curve.Label.Text == "photos")
                {
                    PointF pf = pane.GeneralTransform(curve[iPt].X, curve[iPt].Y, CoordType.AxisXYScale);
                    string[] split = curve[iPt].Tag.ToString().Split(',');
                    pictureBox1.Image = Image.FromFile(split[1]);
                    pictureBox1.Location = new Point(Convert.ToInt32(pf.X), Convert.ToInt32(pf.Y) - pictureBox1.Height);
                    pictureBox1.BringToFront();
                    pictureBox1.Visible = true;
                    return split[0];
                }
                else if (curve.Label.Text.StartsWith("Anno"))
                {
                    HighlightGraphs(curve[iPt].Z, curve[iPt].X - curve[iPt].Z);
                }

            }
            else if (curve.Label.Text == "photos")
            {
                string[] split = curve[iPt].Tag.ToString().Split(',');
                return split[0];
            }

            if (curve[iPt].Tag != null)
                return curve[iPt].Tag.ToString();
            else return curve[iPt].ToString();
        }
Example #14
0
 /// <summary>
 /// Add a <see cref="PointPair"/> object to the collection at the end of the list.
 /// </summary>
 /// <param name="point">The <see cref="PointPair"/> object to
 /// be added</param>
 /// <returns>The zero-based ordinal index where the point was added in the list.</returns>
 /// <seealso cref="IList.Add"/>
 public int Add(PointPair point)
 {
     sorted = false;
     return(List.Add(new PointPair(point)));
 }
Example #15
0
        /// <summary>
        /// Handle a MouseDown event in the <see cref="ZedGraphControl" />
        /// </summary>
        /// <param name="sender">A reference to the <see cref="ZedGraphControl" /></param>
        /// <param name="e">A <see cref="MouseEventArgs" /> instance</param>
        protected void ZedGraphControl_MouseDown(object sender, MouseEventArgs e)
        {
            _isPanning = false;
            _isZooming = false;
            _isEditing = false;
            _isSelecting = false;
            _dragPane = null;

            Point mousePt = new Point(e.X, e.Y);

            // Callback for doubleclick events
            if (_masterPane != null && e.Clicks > 1 && this.DoubleClickEvent != null) {
                if (this.DoubleClickEvent(this, e))
                    return;
            }

            // Provide Callback for MouseDown events
            if (_masterPane != null && this.MouseDownEvent != null) {
                if (this.MouseDownEvent(this, e))
                    return;
            }

            if (e.Clicks > 1 || _masterPane == null)
                return;

            // First, see if the click is within a Linkable object within any GraphPane
            GraphPane pane = this.MasterPane.FindPane(mousePt);
            if (pane != null &&
                e.Button == _linkButtons && Control.ModifierKeys == _linkModifierKeys) {
                object source;
                Link link;
                int index;
                using (Graphics g = this.CreateGraphics()) {
                    float scaleFactor = pane.CalcScaleFactor();
                    if (pane.FindLinkableObject(mousePt, g, scaleFactor, out source, out link, out index)) {
                        if (LinkEvent != null && LinkEvent(this, pane, source, link, index))
                            return;

                        string url;
                        CurveItem curve = source as CurveItem;

                        if (curve != null)
                            url = link.MakeCurveItemUrl(pane, curve, index);
                        else
                            url = link._url;

                        if (url != string.Empty) {
                            System.Diagnostics.Process.Start(url);
                            // linkable objects override any other actions with mouse
                            return;
                        }
                    }
                    //g.Dispose();
                }
            }

            // Second, Check to see if it's within a Chart Rect
            pane = this.MasterPane.FindChartRect(mousePt);
            //Rectangle rect = new Rectangle( mousePt, new Size( 1, 1 ) );

            if (pane != null &&
                (_isEnableHPan || _isEnableVPan) &&
                ((e.Button == _panButtons && Control.ModifierKeys == _panModifierKeys) ||
                 (e.Button == _panButtons2 && Control.ModifierKeys == _panModifierKeys2))) {
                _isPanning = true;
                _dragStartPt = mousePt;
                _dragPane = pane;
                //_zoomState = new ZoomState( _dragPane, ZoomState.StateType.Pan );
                ZoomStateSave(_dragPane, ZoomState.StateType.Pan);
            }
            else if (pane != null && (_isEnableHZoom || _isEnableVZoom) &&
                     ((e.Button == _zoomButtons && Control.ModifierKeys == _zoomModifierKeys) ||
                      (e.Button == _zoomButtons2 && Control.ModifierKeys == _zoomModifierKeys2))) {
                _isZooming = true;
                _dragStartPt = mousePt;
                _dragEndPt = mousePt;
                _dragEndPt.Offset(1, 1);
                _dragPane = pane;
                ZoomStateSave(_dragPane, ZoomState.StateType.Zoom);
            }
            //Revision: JCarpenter 10/06
            else if (pane != null && _isEnableSelection && e.Button == _selectButtons &&
                     (Control.ModifierKeys == _selectModifierKeys ||
                      Control.ModifierKeys == _selectAppendModifierKeys)) {
                _isSelecting = true;
                _dragStartPt = mousePt;
                _dragEndPt = mousePt;
                _dragEndPt.Offset(1, 1);
                _dragPane = pane;
            }
            else if (pane != null && (_isEnableHEdit || _isEnableVEdit) &&
                     (e.Button == EditButtons && Control.ModifierKeys == EditModifierKeys)) {
                CurveItem tempDragCurve;
                int tempDragIndex;
                // find the point that was clicked, and make sure the point list is editable
                // and that it's a primary Y axis (the first Y or Y2 axis)
                if (pane.FindNearestPoint(mousePt, out tempDragCurve, out tempDragIndex) &&
                    tempDragCurve.Points is IPointListEdit) {
                    DragCurve = tempDragCurve;
                    DragIndex = tempDragIndex;
                    _isEditing = true;
                    _dragPane = pane;
                    _dragStartPt = mousePt;
                    // save a reference to the *actual* point that we're editing, and save a copy
                    // for the start pair (which won't get changed), to be used as backup and for calcs
                    DragEditingPair = DragCurve[DragIndex];
                    DragStartPair = new PointPair(DragCurve[DragIndex]);
                }
            }
        }
Example #16
0
        /// <summary>
        /// Create a fill brush using current properties.  This method will construct a brush based on the
        /// settings of <see cref="ZedGraph.Fill.Type"/>, <see cref="ZedGraph.Fill.Color"/>
        /// and <see cref="ZedGraph.Fill.Brush"/>.  If
        /// <see cref="ZedGraph.Fill.Type"/> is set to <see cref="ZedGraph.FillType.Brush"/> and
        /// <see cref="ZedGraph.Fill.Brush"/>
        /// is null, then a <see cref="LinearGradientBrush"/> will be created between the colors of
        /// <see cref="System.Drawing.Color.White"/> and <see cref="ZedGraph.Fill.Color"/>.
        /// </summary>
        /// <param name="rect">A rectangle that bounds the object to be filled.  This determines
        /// the start and end of the gradient fill.</param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable for <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/> or <see cref="FillType.GradientByZ"/>.</param>
        /// <returns>A <see cref="System.Drawing.Brush"/> class representing the fill brush</returns>
        public Brush MakeBrush( RectangleF rect, PointPair dataValue )
        {
            // get a brush
            if ( this.IsVisible && ( !_color.IsEmpty || _brush != null ) )
            {
                if ( rect.Height < 1.0F )
                    rect.Height = 1.0F;
                if ( rect.Width < 1.0F )
                    rect.Width = 1.0F;

                //Brush	brush;
                if ( _type == FillType.Brush )
                {
                    return ScaleBrush( rect, _brush, _isScaled );
                }
                else if ( IsGradientValueType )
                {
                    if ( dataValue != null )
                    {
                        if ( !_secondaryValueGradientColor.IsEmpty )
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            Fill tmpFill = new Fill( _secondaryValueGradientColor,
                                    GetGradientColor( dataValue ), _angle );
                            return tmpFill.MakeBrush( rect );
                        }
                        else
                            return new SolidBrush( GetGradientColor( dataValue ) );
                    }
                    else if ( _rangeDefault != double.MaxValue )
                    {
                        if ( !_secondaryValueGradientColor.IsEmpty )
                        {
                            // Go ahead and create a new Fill so we can do all the scaling, etc.,
                            // that is associated with a gradient
                            Fill tmpFill = new Fill( _secondaryValueGradientColor,
                                    GetGradientColor( _rangeDefault ), _angle );
                            return tmpFill.MakeBrush( rect );
                        }
                        else
                            return new SolidBrush( GetGradientColor( _rangeDefault ) );
                    }
                    else
                        return ScaleBrush( rect, _brush, true );
                }
                else
                    return new SolidBrush( _color );
            }

            // Always return a suitable default
            return new SolidBrush( Color.White );
        }
        /// <summary>
        /// Add a set of points to the <see cref="RollingPointPairList"/> from
        /// three arrays of type double.
        /// If the X or Y array is null, then a set of ordinal values is automatically
        /// generated in its place (see <see cref="AxisType.Ordinal"/>.
        /// If the <see paramref="z"/> value
        /// is null, then it is set to zero.
        /// If the arrays are of different size, then the larger array prevails and the
        /// smaller array is padded with <see cref="PointPairBase.Missing"/> values.
        /// </summary>
        /// <param name="x">A double[] array of X values</param>
        /// <param name="y">A double[] array of Y values</param>
        /// <param name="z">A double[] array of Z values</param>
        public void Add(double[] x, double[] y, double[] z)
        {
            int len = 0;

            if (x != null)
            {
                len = x.Length;
            }
            if (y != null && y.Length > len)
            {
                len = y.Length;
            }
            if (z != null && z.Length > len)
            {
                len = z.Length;
            }

            for (int i = 0; i < len; i++)
            {
                PointPair point = new PointPair();

                if (x == null)
                {
                    point.X = (double)i + 1.0;
                }
                else if (i < x.Length)
                {
                    point.X = x[i];
                }
                else
                {
                    point.X = PointPair.Missing;
                }

                if (y == null)
                {
                    point.Y = (double)i + 1.0;
                }
                else if (i < y.Length)
                {
                    point.Y = y[i];
                }
                else
                {
                    point.Y = PointPair.Missing;
                }

                if (z == null)
                {
                    point.Z = (double)i + 1.0;
                }
                else if (i < z.Length)
                {
                    point.Z = z[i];
                }
                else
                {
                    point.Z = PointPair.Missing;
                }

                Add(point);
            }
        }
Example #18
0
        /// <summary>
        /// Draw all the <see cref="OHLCBar"/>'s to the specified <see cref="Graphics"/>
        /// device as a candlestick at each defined point.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">A <see cref="OHLCBarItem"/> object representing the
        /// <see cref="OHLCBar"/>'s to be drawn.</param>
        /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent)
        /// axis for the <see cref="OHLCBar"/></param>
        /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent)
        /// axis for the <see cref="OHLCBar"/></param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, GraphPane pane, OHLCBarItem curve,
                         Axis baseAxis, Axis valueAxis, float scaleFactor)
        {
            //ValueHandler valueHandler = new ValueHandler( pane, false );

            float pixBase, pixHigh, pixLow, pixOpen, pixClose;

            if (curve.Points != null)
            {
                //float halfSize = _size * scaleFactor;
                float halfSize = Math.Max(1, GetBarWidth(pane, baseAxis, scaleFactor));

                int minX = int.MinValue;
                int maxX = int.MaxValue;
                int minY = int.MinValue;
                int maxY = int.MaxValue;
                if (pane != null)
                {
                    minX = (int)pane.Chart.Rect.Left;
                    maxX = (int)pane.Chart.Rect.Right;
                    minY = (int)pane.Chart.Rect.Top;
                    maxY = (int)pane.Chart.Rect.Bottom;
                }

                if (isOptDraw)
                {
                    if (isPixelDrawn == null)
                    {
                        isPixelDrawn = new Dictionary <long, bool>();
                    }
                    else
                    {
                        isPixelDrawn.Clear();
                    }
                }

                using (Pen pen = !curve.IsSelected ? new Pen(_color, _width) :
                                 new Pen(Selection.Border.Color, Selection.Border.Width))
//				using ( Pen pen = new Pen( _color, _penWidth ) )
                {
                    double  date;
                    double  high;
                    double  low;
                    double  open;
                    double  close;
                    StockPt pt;
                    int     minOrdinal = 0;
                    int     maxOrdinal = int.MaxValue;
                    double  minScale   = baseAxis.Scale.Min;
                    double  maxScale   = baseAxis.Scale.Max;
                    var     increment  = 1;
                    if (baseAxis.Scale.IsAnyOrdinal && !curve.IsOverrideOrdinal)
                    {
                        minOrdinal = (int)baseAxis.Scale.Min;
                        maxOrdinal = (int)baseAxis.Scale.Max;
                        var ordinalWidth = maxOrdinal - minOrdinal + 1;
                        var pixelWidth   = maxX - minX + 1;
                        var quotient     = ordinalWidth / pixelWidth;
                        if (quotient > 1)
                        {
                            increment = quotient;
                        }
                    }
                    else if (curve.Points.Count > 100000)
                    {
                        pt = curve.Points[0] as StockPt;
                        if (pt != null)
                        {
                            double firstDate = pt.X;
                            pt = curve.Points[curve.Points.Count - 1] as StockPt;
                            if (pt != null)
                            {
                                double lastDate        = pt.X;
                                double scalePerOrdinal = (lastDate - firstDate) / curve.Points.Count;
                                minOrdinal = (int)Math.Max(0, (minScale - firstDate) / scalePerOrdinal);
                                maxOrdinal = (int)((maxScale - firstDate) / scalePerOrdinal);
                                int estimateWidth = Math.Max(100000, maxOrdinal - minOrdinal);
                                minOrdinal  = Math.Max(0, minOrdinal - estimateWidth);
                                maxOrdinal += estimateWidth;
                            }
                        }
                    }
                    // Loop over each defined point
                    var limit = Math.Min(curve.Points.Count, maxOrdinal);
                    for (int i = Math.Max(minOrdinal, 0); i < limit; i++)
                    {
                        pt = curve.Points[i] as StockPt;
                        if (pt == null)
                        {
                            continue;
                        }
                        date = pt.X;
                        if (!baseAxis.Scale.IsAnyOrdinal || curve.IsOverrideOrdinal)
                        {
                            if (date < minScale || date > maxScale)
                            {
                                continue;
                            }
                        }
                        open    = (pt as StockPt).Open;
                        close   = (pt as StockPt).Close;
                        pixBase = (int)(baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date) + 0.5);
                        if (pixBase < minX || pixBase > maxX)
                        {
                            // Skip this one, it's outside the visible scroll range.
                            continue;
                        }
                        if (PointPair.IsValueInvalid(close))
                        {
                            pixClose = Single.MaxValue;
                        }
                        else
                        {
                            pixClose = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close);
                        }

                        high = pt.Y;
                        low  = pt.Z;

                        // Any value set to double max is invalid and should be skipped
                        // This is used for calculated values that are out of range, divide
                        //   by zero, etc.
                        // Also, any value <= zero on a log scale is invalid

                        if (!curve.Points[i].IsInvalid3D &&
                            (date > 0 || !baseAxis._scale.IsLog) &&
                            ((high > 0 && low > 0) || !valueAxis._scale.IsLog))
                        {
                            pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high);
                            pixLow  = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low);
                            if (PointPair.IsValueInvalid(open))
                            {
                                pixOpen = Single.MaxValue;
                            }
                            else
                            {
                                pixOpen = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open);
                            }

                            // Don't try to draw where we already drew.
                            // This is a huge optimization when there are
                            // many more draw items than pixels in the rectangle.
                            int  xOpt = (int)(maxX - pixBase);
                            int  yOptHigh = (int)(maxY - pixHigh);
                            int  yOptLow = (int)(maxY - pixLow);
                            int  yOpt = yOptLow <0 || yOptLow> maxY ? yOptHigh : yOptLow;
                            bool value;
                            if (isOptDraw)
                            {
                                if (xOpt > maxX || yOpt > maxY ||
                                    xOpt < 0 || yOpt < 0 ||
                                    isPixelDrawn.TryGetValue(GetHashCode(xOpt, yOpt), out value))
                                {
                                    continue;
                                }
                                else
                                {
                                    isPixelDrawn.Add(GetHashCode(xOpt, yOpt), true);
                                }
                            }

                            if (!curve.IsSelected && this._gradientFill.IsGradientValueType)
                            {
                                using (Pen tPen = GetPen(pane, scaleFactor, pt))
                                    Draw(g, pane, baseAxis is XAxis || baseAxis is X2Axis,
                                         pixBase, pixHigh, pixLow, pixOpen,
                                         pixClose, halfSize, tPen);
                            }
                            else
                            {
                                Draw(g, pane, baseAxis is XAxis || baseAxis is X2Axis,
                                     pixBase, pixHigh, pixLow, pixOpen,
                                     pixClose, halfSize, pen);
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Draw all the <see cref="OHLCBar"/>'s to the specified <see cref="Graphics"/>
        /// device as a candlestick at each defined point.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">A <see cref="OHLCBarItem"/> object representing the
        /// <see cref="OHLCBar"/>'s to be drawn.</param>
        /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent)
        /// axis for the <see cref="OHLCBar"/></param>
        /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent)
        /// axis for the <see cref="OHLCBar"/></param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, GraphPane pane, OHLCBarItem curve,
                         Axis baseAxis, Axis valueAxis, float scaleFactor)
        {
            //ValueHandler valueHandler = new ValueHandler( pane, false );

            float pixBase, pixHigh, pixLow, pixOpen, pixClose;

            if (curve.Points != null)
            {
                //float halfSize = _size * scaleFactor;
                float halfSize = GetBarWidth(pane, baseAxis, scaleFactor);

                using (Pen pen = !curve.IsSelected ? new Pen(_color, _width) :
                                 new Pen(Selection.Border.Color, Selection.Border.Width))
//				using ( Pen pen = new Pen( _color, _penWidth ) )
                {
                    // Loop over each defined point
                    for (int i = 0; i < curve.Points.Count; i++)
                    {
                        PointPair pt    = curve.Points[i];
                        double    date  = pt.X;
                        double    high  = pt.Y;
                        double    low   = pt.Z;
                        double    open  = PointPair.Missing;
                        double    close = PointPair.Missing;
                        if (pt is StockPt)
                        {
                            open  = (pt as StockPt).Open;
                            close = (pt as StockPt).Close;
                        }

                        // Any value set to double max is invalid and should be skipped
                        // This is used for calculated values that are out of range, divide
                        //   by zero, etc.
                        // Also, any value <= zero on a log scale is invalid

                        if (!curve.Points[i].IsInvalid3D &&
                            (date > 0 || !baseAxis._scale.IsLog) &&
                            ((high > 0 && low > 0) || !valueAxis._scale.IsLog))
                        {
                            pixBase = (int)(baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date) + 0.5);
                            //pixBase = baseAxis.Scale.Transform( curve.IsOverrideOrdinal, i, date );
                            pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high);
                            pixLow  = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low);
                            if (PointPair.IsValueInvalid(open))
                            {
                                pixOpen = Single.MaxValue;
                            }
                            else
                            {
                                pixOpen = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open);
                            }

                            if (PointPair.IsValueInvalid(close))
                            {
                                pixClose = Single.MaxValue;
                            }
                            else
                            {
                                pixClose = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close);
                            }

                            if (!curve.IsSelected && this._gradientFill.IsGradientValueType)
                            {
                                using (Pen tPen = GetPen(pane, scaleFactor, pt))
                                    Draw(g, pane, baseAxis is XAxis || baseAxis is X2Axis,
                                         pixBase, pixHigh, pixLow, pixOpen,
                                         pixClose, halfSize, tPen);
                            }
                            else
                            {
                                Draw(g, pane, baseAxis is XAxis || baseAxis is X2Axis,
                                     pixBase, pixHigh, pixLow, pixOpen,
                                     pixClose, halfSize, pen);
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Add a <see cref="PointPair"/> onto the head of the queue,
 /// overwriting old values if the buffer is full.
 /// </summary>
 /// <param name="item">The <see cref="PointPair" /> to be added.</param>
 public void Add(PointPair item)
 {
     _mBuffer[GetNextIndex()] = item;
 }
Example #21
0
        /// <summary>
        /// Compare two <see cref="PointPair"/> objects for equality.  To be equal, X, Y, and Z
        /// must be exactly the same between the two objects.
        /// </summary>
        /// <param name="obj">The <see cref="PointPair"/> object to be compared with.</param>
        /// <returns>true if the <see cref="PointPair"/> objects are equal, false otherwise</returns>
        public override bool Equals(object obj)
        {
            PointPair rhs = obj as PointPair;

            return(this.X == rhs.X && this.Y == rhs.Y && this.Z == rhs.Z);
        }
        internal void SetDateFormat(GraphPane pane)
        {
            if (_formatAuto)
            {
                double range = 10;

                if (pane.CurveList.Count > 0 && pane.CurveList[0].Points.Count > 1)
                {
                    double val1, val2;

                    PointPair pt1 = pane.CurveList[0].Points[0];
                    PointPair pt2 = pane.CurveList[0].Points[pane.CurveList[0].Points.Count - 1];
                    int       p1  = 1;
                    int       p2  = pane.CurveList[0].Points.Count;
                    if (pane.IsBoundedRanges)
                    {
                        p1 = (int)Math.Floor(_ownerAxis.Scale.Min);
                        p2 = (int)Math.Ceiling(_ownerAxis.Scale.Max);
                        p1 = Math.Min(Math.Max(p1, 1), pane.CurveList[0].Points.Count);
                        p2 = Math.Min(Math.Max(p2, 1), pane.CurveList[0].Points.Count);
                        if (p2 > p1)
                        {
                            pt1 = pane.CurveList[0].Points[p1 - 1];
                            pt2 = pane.CurveList[0].Points[p2 - 1];
                        }
                    }
                    if (_ownerAxis is XAxis || _ownerAxis is X2Axis)
                    {
                        val1 = pt1.X;
                        val2 = pt2.X;
                    }
                    else
                    {
                        val1 = pt1.Y;
                        val2 = pt2.Y;
                    }

                    if (val1 != PointPair.Missing &&
                        val2 != PointPair.Missing &&
                        !Double.IsNaN(val1) &&
                        !Double.IsNaN(val2) &&
                        !Double.IsInfinity(val1) &&
                        !Double.IsInfinity(val2) &&
                        Math.Abs(val2 - val1) > 1e-10)
                    {
                        range = Math.Abs(val2 - val1);
                    }
                }

                if (range > Default.RangeYearYear)
                {
                    _format = Default.FormatYearYear;
                }
                else if (range > Default.RangeYearMonth)
                {
                    _format = Default.FormatYearMonth;
                }
                else if (range > Default.RangeMonthMonth)
                {
                    _format = Default.FormatMonthMonth;
                }
                else if (range > Default.RangeDayDay)
                {
                    _format = Default.FormatDayDay;
                }
                else if (range > Default.RangeDayHour)
                {
                    _format = Default.FormatDayHour;
                }
                else if (range > Default.RangeHourHour)
                {
                    _format = Default.FormatHourHour;
                }
                else if (range > Default.RangeHourMinute)
                {
                    _format = Default.FormatHourMinute;
                }
                else if (range > Default.RangeMinuteMinute)
                {
                    _format = Default.FormatMinuteMinute;
                }
                else if (range > Default.RangeMinuteSecond)
                {
                    _format = Default.FormatMinuteSecond;
                }
                else if (range > Default.RangeSecondSecond)
                {
                    _format = Default.FormatSecondSecond;
                }
                else                 // MilliSecond
                {
                    _format = Default.FormatMillisecond;
                }
            }
        }
Example #23
0
        /// <summary>
        /// Render the <see cref="Legend"/> to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphPane"/> object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, PaneBase pane, float scaleFactor)
        {
            // if the legend is not visible, do nothing
            if (!_isVisible)
            {
                return;
            }

            // Fill the background with the specified color if required
            _fill.Draw(g, _rect);

            PaneList paneList = GetPaneList(pane);

            float halfGap = _tmpSize / 2.0F;

            // Check for bad data values
            if (_hStack <= 0)
            {
                _hStack = 1;
            }
            if (_legendItemWidth <= 0)
            {
                _legendItemWidth = 100;
            }
            if (_legendItemHeight <= 0)
            {
                _legendItemHeight = _tmpSize;
            }

            //float gap = pane.ScaledGap( scaleFactor );

            int   iEntry = 0;
            float x, y;

            // Get a brush for the legend label text
            using (SolidBrush brushB = new SolidBrush(Color.Black))
            {
                foreach (GraphPane tmpPane in paneList)
                {
                    // Loop for each curve in the CurveList collection
                    if (!string.IsNullOrEmpty(HeaderString))//»­±êÌâ
                    {
                        x = _rect.Left + halfGap / 2.0F +
                            (iEntry % _hStack) * _legendItemWidth;
                        y = _rect.Top + (int)(iEntry / _hStack) * _legendItemHeight;
                        this.FontSpec.Draw(g, pane, HeaderString,
                                           x + 0.0F * _tmpSize, y + _legendItemHeight / 2.0F,
                                           AlignH.Left, AlignV.Center, scaleFactor);
                        iEntry++;
                    }
                    int count = tmpPane.CurveList.Count;
                    for (int i = 0; i < count; i++)
                    {
                        CurveItem curve = tmpPane.CurveList[_isReverse ? count - i - 1 : i];

                        if (curve._label._text != "" && curve._label._isVisible)
                        {
                            // Calculate the x,y (TopLeft) location of the current
                            // curve legend label
                            // assuming:
                            //  charHeight/2 for the left margin, plus legendWidth for each
                            //    horizontal column
                            //  legendHeight is the line spacing, with no extra margin above

                            x = _rect.Left + halfGap / 2.0F +
                                (iEntry % _hStack) * _legendItemWidth;
                            y = _rect.Top + (int)(iEntry / _hStack) * _legendItemHeight;

                            // Draw the legend label for the current curve
                            FontSpec tmpFont = (curve._label._fontSpec != null) ?
                                               curve._label._fontSpec : this.FontSpec;

                            // This is required because, for long labels, the centering can affect the
                            // position in GDI+.
                            tmpFont.StringAlignment = StringAlignment.Near;

                            string labelText = "";
                            if (IsShowCurveMaxValue)
                            {
                                PointPair pp = curve.GetMaxYPointPair();
                                labelText = string.Format("{0}  {1}   {2}", curve._label._text, pp.ValueFormat(pp.X), pp.ValueFormat(pp.Y));
                            }
                            else
                            {
                                labelText = curve._label._text;
                            }

                            if (_isShowLegendSymbols)
                            {
                                tmpFont.Draw(g, pane, labelText,
                                             x + 2.5F * _tmpSize, y + _legendItemHeight / 2.0F,
                                             AlignH.Left, AlignV.Center, scaleFactor);

                                RectangleF rect = new RectangleF(x, y + _legendItemHeight / 4.0F,
                                                                 2 * _tmpSize, _legendItemHeight / 2.0F);
                                curve.DrawLegendKey(g, tmpPane, rect, scaleFactor);
                            }
                            else
                            {
                                if (curve._label._fontSpec == null)
                                {
                                    tmpFont.FontColor = curve.Color;
                                }

                                tmpFont.Draw(g, pane, labelText,
                                             x + 0.0F * _tmpSize, y + _legendItemHeight / 2.0F,
                                             AlignH.Left, AlignV.Center, scaleFactor);
                            }

                            // maintain a curve count for positioning
                            iEntry++;
                        }
                    }
                    if (pane is MasterPane && ((MasterPane)pane).IsUniformLegendEntries)
                    {
                        break;
                    }
                }

                // Draw a border around the legend if required
                if (iEntry > 0)
                {
                    this.Border.Draw(g, pane, scaleFactor, _rect);
                }
            }
        }
Example #24
0
 /// <summary>
 /// Add a <see cref="PointPair"/> object to the collection at the specified,
 /// zero-based, index location.
 /// </summary>
 /// <param name="index">
 /// The zero-based ordinal index where the point is to be added in the list.
 /// </param>
 /// <param name="point">
 /// The <see cref="PointPair"/> object to be added.
 /// </param>
 public void Insert(int index, PointPair point)
 {
     sorted = false;
     List.Insert(index, point);
 }
Example #25
0
 /// <summary>
 /// Add a <see cref="PointPair"/> object to the collection at the end of the list.
 /// </summary>
 /// <param name="point">The <see cref="PointPair"/> object to be added</param>
 public void Add(PointPair point)
 {
     //			throw new ArgumentException( "Error: Only the StockPt type can be added to StockPointList" +
     //				".  An ordinary PointPair is not allowed" );
     base.Add(new StockPt(point));
 }
Example #26
0
        /// <summary>
        /// Add a set of points to the <see cref="PointPairList"/> from three arrays of type double.
        /// If the X or Y array is null, then a set of ordinal values is automatically
        /// generated in its place (see <see cref="AxisType.Ordinal"/>.  If the <see paramref="baseVal"/>
        /// is null, then it is set to zero.
        /// If the arrays are of different size, then the larger array prevails and the
        /// smaller array is padded with <see cref="PointPair.Missing"/> values.
        /// </summary>
        /// <param name="x">A double[] array of X values</param>
        /// <param name="y">A double[] array of Y values</param>
        /// <param name="z">A double[] array of Z or lower-dependent axis values</param>
        /// <returns>The zero-based ordinal index where the last point was added in the list,
        /// or -1 if no points were added.</returns>
        /// <seealso cref="IList.Add"/>
        public int Add(double[] x, double[] y, double[] z)
        {
            int len = 0,
                rv  = -1;

            if (x != null)
            {
                len = x.Length;
            }
            if (y != null && y.Length > len)
            {
                len = y.Length;
            }
            if (z != null && z.Length > len)
            {
                len = z.Length;
            }

            for (int i = 0; i < len; i++)
            {
                PointPair point = new PointPair();

                if (x == null)
                {
                    point.X = (double)i + 1.0;
                }
                else if (i < x.Length)
                {
                    point.X = x[i];
                }
                else
                {
                    point.X = PointPair.Missing;
                }

                if (y == null)
                {
                    point.Y = (double)i + 1.0;
                }
                else if (i < y.Length)
                {
                    point.Y = y[i];
                }
                else
                {
                    point.Y = PointPair.Missing;
                }

                if (z == null)
                {
                    point.Z = (double)i + 1.0;
                }
                else if (i < z.Length)
                {
                    point.Z = z[i];
                }
                else
                {
                    point.Z = PointPair.Missing;
                }

                rv = List.Add(point);
            }

            sorted = false;
            return(rv);
        }
Example #27
0
 public override PointAnnotation AnnotatePoint(PointPair point)
 {
     return null;
 }
Example #28
0
 /// <summary>
 /// Fill the background of the <see cref="RectangleF"/> area, using the
 /// fill type from this <see cref="Fill"/>.
 /// </summary>
 /// <param name="g">
 /// A graphic device object to be drawn into.  This is normally e.Graphics from the
 /// PaintEventArgs argument to the Paint() method.
 /// </param>
 /// <param name="rect">The <see cref="RectangleF"/> struct specifying the area
 /// to be filled</param>
 /// <param name="pt">The data value to be used in case it's a
 /// <see cref="FillType.GradientByX" />, <see cref="FillType.GradientByY" />, or
 /// <see cref="FillType.GradientByZ" /> <see cref="FillType" />.</param>
 public void Draw( Graphics g, RectangleF rect, PointPair pt )
 {
     if ( this.IsVisible )
     {
         using ( Brush brush = this.MakeBrush( rect, pt ) )
         {
             g.FillRectangle( brush, rect );
         }
     }
 }
Example #29
0
 /// <summary>
 /// Remove the specified <see cref="PointPair"/> object from the collection based
 /// the point values (must match exactly).
 /// </summary>
 /// <param name="pt">
 /// A <see cref="PointPair"/> that is to be removed by value.
 /// </param>
 /// <seealso cref="IList.Remove"/>
 public void Remove(PointPair pt)
 {
     List.Remove(pt);
 }
Example #30
0
        internal Color GetGradientColor( PointPair dataValue )
        {
            double val;

            if ( dataValue == null )
                val = _rangeDefault;
            else if ( _type == FillType.GradientByColorValue )
                val = dataValue.ColorValue;
            else if ( _type == FillType.GradientByZ )
                val = dataValue.Z;
            else if ( _type == FillType.GradientByY )
                val = dataValue.Y;
            else
                val = dataValue.X;

            return GetGradientColor( val );
        }
        /// <summary>
        /// Constructs a buffer with a copy of the items within the provided
        /// <see cref="IPointList" />.
        /// The <see cref="Capacity" /> is set to the length of the provided list.
        /// </summary>
        /// <param name="rhs">The <see cref="IPointList" /> to be copied.</param>
        public RollingPointPairList( IPointList rhs )
        {
            _mBuffer = new PointPair[rhs.Count];

            for ( int i = 0; i < rhs.Count; i++ )
            {
                _mBuffer[i] = new PointPair( rhs[i] );
            }

            _headIdx = rhs.Count - 1;
            _tailIdx = 0;
        }
        private void RenderRequestsPerSecond()
        {
            ClearSeries();

            var parser = new ResultsParser();
            var reqs = parser.RequestsPerSecond(Results);

            var pane = Chart.GraphPane;

            pane.Title.Text = "Requests per Second";
            pane.Title.FontSpec.FontColor = Color.DarkBlue;
            pane.Title.FontSpec.Size = 14.25F;
            pane.Title.FontSpec.IsBold = true;

            pane.LineType = LineType.Normal;
            pane.XAxis.Title.Text = "second of test";
            pane.YAxis.Title.Text = "requests / second";
            pane.Chart.Fill = new Fill(Color.LightYellow, Color.PaleGoldenrod, 45.0F);
            Chart.IsShowPointValues = true;
            Chart.GraphPane.LineType = LineType.Normal;
            PointPairList series = new PointPairList();

            foreach (var req in reqs)
            {
                var point = new PointPair(req.Second, req.Requests);
                series.Add(point);
            }

            var curve = pane.AddCurve("",series,Color.Green);

            curve.Line.Width = 4.0F;
            curve.Line.IsAntiAlias = true;
            curve.Line.Fill = new Fill(Color.White, Color.Green, 45F);
            curve.Symbol.Fill = new Fill(Color.LightYellow);
            curve.Symbol.Size = 4;

            // activate the cardinal spline smoothing
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.5F;

            // Force refresh of chart
            pane.AxisChange();
        }
        /// <summary>
        /// Add a set of values onto the head of the queue,
        /// overwriting old values if the buffer is full.
        /// </summary>
        /// <remarks>
        /// This method is much more efficient that the <see cref="Add(PointPair)">Add(PointPair)</see>
        /// method, since it does not require that a new PointPair instance be provided.
        /// If the buffer already contains a <see cref="PointPair"/> at the head position,
        /// then the x, y, z, and tag values will be copied into the existing PointPair.
        /// Otherwise, a new PointPair instance must be created.
        /// In this way, each PointPair position in the rolling list will only be allocated one time.
        /// To truly be memory efficient, the <see cref="Remove" />, <see cref="RemoveAt" />,
        /// and <see cref="Pop" /> methods should be avoided.  Also, the <paramref name="tag"/> property
        /// for this method should be null, since it is a reference type.
        /// </remarks>
        /// <param name="x">The X value</param>
        /// <param name="y">The Y value</param>
        /// <param name="z">The Z value</param>
        /// <param name="tag">The Tag value for the PointPair</param>
        public void Add( double x, double y, double z, object tag )
        {
            // advance the rolling list
            GetNextIndex();

            if ( _mBuffer[_headIdx] == null )
                _mBuffer[_headIdx] = new PointPair( x, y, z, tag );
            else
            {
                _mBuffer[_headIdx].X = x;
                _mBuffer[_headIdx].Y = y;
                _mBuffer[_headIdx].Z = z;
                _mBuffer[_headIdx].Tag = tag;
            }
        }
Example #34
0
        /// <summary>
        /// Create a <see cref="Pen" /> object based on the properties of this
        /// <see cref="LineBase" />.
        /// </summary>
        /// <param name="pane">The owner <see cref="GraphPane" /> of this
        /// <see cref="LineBase" />.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable if <see cref="Fill.Type">GradientFill.Type</see>
        /// is one of <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/>, <see cref="FillType.GradientByZ"/>,
        /// or <see cref="FillType.GradientByColorValue" />.
        /// </param>
        /// <returns>A <see cref="Pen" /> object with the properties of this <see cref="LineBase" />
        /// </returns>
        public Pen GetPen( PaneBase pane, float scaleFactor, PointPair dataValue )
        {
            Color color = _color;
            if ( _gradientFill.IsGradientValueType )
                color = _gradientFill.GetGradientColor( dataValue );

            Pen pen = new Pen( color,
                        pane.ScaledPenWidth( _width, scaleFactor ) );

            pen.DashStyle = _style;

            if ( _style == DashStyle.Custom )
            {
                CustomDashes.SetupPen(pen, this, dataValue);
            }

            return pen;
        }
Example #35
0
        /// <summary>
        /// Draw all the <see cref="JapaneseCandleStick"/>'s to the specified <see cref="Graphics"/>
        /// device as a candlestick at each defined point.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">A <see cref="JapaneseCandleStickItem"/> object representing the
        /// <see cref="JapaneseCandleStick"/>'s to be drawn.</param>
        /// <param name="baseAxis">The <see cref="Axis"/> class instance that defines the base (independent)
        /// axis for the <see cref="JapaneseCandleStick"/></param>
        /// <param name="valueAxis">The <see cref="Axis"/> class instance that defines the value (dependent)
        /// axis for the <see cref="JapaneseCandleStick"/></param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void Draw(Graphics g, GraphPane pane, JapaneseCandleStickItem curve,
                         Axis baseAxis, Axis valueAxis, float scaleFactor)
        {
            //ValueHandler valueHandler = new ValueHandler( pane, false );

            float pixBase, pixHigh, pixLow, pixOpen, pixClose;

            if (curve.Points != null)
            {
                //float halfSize = _size * scaleFactor;
                float halfSize = GetBarWidth(pane, baseAxis, scaleFactor);

                using (var risingPen = new Pen(_color, _penWidth))
                    using (var fallingPen = new Pen(_fallingColor, _penWidth))
                    {
                        // Loop over each defined point
                        for (int i = 0; i < curve.Points.Count; i++)
                        {
                            PointPair pt    = curve.Points[i];
                            double    date  = pt.X;
                            double    high  = pt.Y;
                            double    low   = pt.Z;
                            double    open  = PointPair.Missing;
                            double    close = PointPair.Missing;
                            if (pt is StockPt)
                            {
                                open  = (pt as StockPt).Open;
                                close = (pt as StockPt).Close;
                            }

                            // Any value set to double max is invalid and should be skipped
                            // This is used for calculated values that are out of range, divide
                            //   by zero, etc.
                            // Also, any value <= zero on a log scale is invalid

                            if (!curve.Points[i].IsInvalid3D &&
                                (date > 0 || !baseAxis._scale.IsLog) &&
                                ((high > 0 && low > 0) || !valueAxis._scale.IsLog))
                            {
                                pixBase = baseAxis.Scale.Transform(curve.IsOverrideOrdinal, i, date);
                                pixHigh = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, high);
                                pixLow  = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, low);
                                if (PointPair.IsValueInvalid(open))
                                {
                                    pixOpen = Single.MaxValue;
                                }
                                else
                                {
                                    pixOpen = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, open);
                                }

                                if (PointPair.IsValueInvalid(close))
                                {
                                    pixClose = Single.MaxValue;
                                }
                                else
                                {
                                    pixClose = valueAxis.Scale.Transform(curve.IsOverrideOrdinal, i, close);
                                }

                                Draw(g, pane, baseAxis is XAxis, pixBase, pixHigh, pixLow, pixOpen,
                                     pixClose, halfSize, scaleFactor,
                                     (close > open ? risingPen : fallingPen),
                                     (close > open ? _risingFill : _fallingFill),
                                     (close > open ? _risingBorder : _fallingBorder), pt);
                            }
                        }
                    }
            }
        }
 public void Add(PointPair ppData)
 {
     Add(DateTime.FromOADate(ppData.X), ppData.Y, 0, "");
 }
Example #37
0
 public SyntheticBarier(Interval interval, PointPair p)
 {
     points = new PointPairList();
     this.interval = interval;
     Symbol.Default.FillType = FillType.Solid;
     curve = new LineItem("", points, Color.Sienna, SymbolType.Square);
     Symbol.Default.FillType = FillType.Brush;
     interval.graphPane.CurveList.Add(curve);
     curve.IsVisible = true;  // Видимы только точки, без линий
     barierType = "Лес";
 }
Example #38
0
        /// <summary>
        /// The PointPair copy constructor.
        /// </summary>
        /// <param name="rhs">The basis for the copy.</param>
        public PointPair( PointPair rhs )
            : base(rhs)
        {
            this.Z = rhs.Z;

            if ( rhs.Tag is ICloneable )
                this.Tag = ((ICloneable) rhs.Tag).Clone();
            else
                this.Tag = rhs.Tag;
        }
Example #39
0
        /// <summary>
        /// Draw the <see cref="Bar"/> to the specified <see cref="Graphics"/> device
        /// at the specified location.  This routine draws a single bar.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="left">The x position of the left side of the bar in
        /// pixel units</param>
        /// <param name="right">The x position of the right side of the bar in
        /// pixel units</param>
        /// <param name="top">The y position of the top of the bar in
        /// pixel units</param>
        /// <param name="bottom">The y position of the bottom of the bar in
        /// pixel units</param>
        /// <param name="scaleFactor">
        /// The scaling factor for the features of the graph based on the <see cref="PaneBase.BaseDimension"/>.  This
        /// scaling factor is calculated by the <see cref="PaneBase.CalcScaleFactor"/> method.  The scale factor
        /// represents a linear multiple to be applied to font sizes, symbol sizes, etc.
        /// </param>
        /// <param name="fullFrame">true to draw the bottom portion of the border around the
        /// bar (this is for legend entries)</param>
        /// <param name="dataValue">The data value to be used for a value-based
        /// color gradient.  This is only applicable for <see cref="FillType.GradientByX"/>,
        /// <see cref="FillType.GradientByY"/> or <see cref="FillType.GradientByZ"/>.</param>
        /// <param name="isSelected">Indicates that the <see cref="Bar" /> should be drawn
        /// with attributes from the <see cref="Selection" /> class.
        /// </param>
        public void Draw(
            Graphics g,
            GraphPane pane,
            float left,
            float right,
            float top,
            float bottom,
            float scaleFactor,
            bool fullFrame,
            bool isSelected,
            PointPair dataValue)
        {
            // Do a sanity check to make sure the top < bottom.  If not, reverse them
            if (top > bottom)
            {
                var junk = top;
                top    = bottom;
                bottom = junk;
            }

            // Do a sanity check to make sure the left < right.  If not, reverse them
            if (left > right)
            {
                var junk = right;
                right = left;
                left  = junk;
            }

            if (top < -10000)
            {
                top = -10000;
            }
            else if (top > 10000)
            {
                top = 10000;
            }
            if (left < -10000)
            {
                left = -10000;
            }
            else if (left > 10000)
            {
                left = 10000;
            }
            if (right < -10000)
            {
                right = -10000;
            }
            else if (right > 10000)
            {
                right = 10000;
            }
            if (bottom < -10000)
            {
                bottom = -10000;
            }
            else if (bottom > 10000)
            {
                bottom = 10000;
            }

            // Make a rectangle for the bar and draw it
            var rect = new RectangleF(left, top, right - left, bottom - top);

            Draw(g, pane, rect, scaleFactor, fullFrame, isSelected, dataValue);
        }
Example #40
0
        /// <summary>
        /// Provides binding between <see cref="DataSource"/> and the specified pane.  Extracts the
        /// data from <see cref="DataSource"/> and copies it into the appropriate
        /// <see cref="ZedGraph.IPointList"/> for each <see cref="ZedGraph.CurveItem"/> in the
        /// specified <see cref="ZedGraph.GraphPane"/>.
        /// </summary>
        /// <param name="g">The <see cref="Graphics"/> object to be used for rendering the data.</param>
        /// <param name="pane">The <see cref="ZedGraph.GraphPane"/> object which will receive the data.</param>
        protected void PopulateByDataSource( Graphics g, GraphPane pane )
        {
            if ( this.CurveList.Count == 0 )
                return;

            //If the Datasource column names are available we can bind them
            // correctly to their corresponding DataMember.
            if ( this.DataMember != null && this.DataMember != String.Empty
                && this.DataSource != null
                && this.DataSource is ITypedList
                && this.DataSource is IListSource
                )
            {
                ITypedList tlist = this.DataSource as ITypedList;
                IListSource listSource = this.DataSource as IListSource;
                IList list = listSource.GetList();
                PropertyDescriptorCollection pdc = tlist.GetItemProperties( null );
                bool bListContainsList = listSource.ContainsListCollection;

                //Get the DataMember and Type of the base axis in the DataSource
                string baseDataMember = this.DataMember;
                PropertyDescriptor basePd = pdc.Find( baseDataMember, true );
                if ( basePd == null )
                    throw new System.Exception( "Can't find DataMember '" + baseDataMember + "' in DataSource for the base axis." );
                baseDataMember = basePd.Name;
                Type baseDataType = basePd.PropertyType;
                int indexBaseColumn = pdc.IndexOf( basePd );

                //Foreach bar/curve
                //  Get its DataMember and Type in the DataSource
                //	Add the curve to the pane
                //  Add all corresponding points(baseAxis,valueAxis,0)
                //Note: Z axis is not supported
                foreach ( ZedGraphWebCurveItem curveItem in this.CurveList )
                {
                    //Axis valueAxis = curveItem.ValueAxis;
                    PropertyDescriptorCollection pdcValue = pdc;
                    IList valueList = list;
                    bool bValueListContainsList = bListContainsList;

                    //If present, use DataSource of Curve instead of main DataSource
                    if ( curveItem.DataSource != null
                        && curveItem.DataSource is ITypedList
                        && curveItem.DataSource is IListSource )
                    {
                        ITypedList valueTlist = curveItem.DataSource as ITypedList;
                        pdcValue = valueTlist.GetItemProperties( null );
                        IListSource valueListSource = curveItem.DataSource as IListSource;
                        valueList = valueListSource.GetList();
                        bValueListContainsList = valueListSource.ContainsListCollection;
                    }

                    string valueDataMember = curveItem.DataMember;
                    PropertyDescriptor pd = pdcValue.Find( valueDataMember, true );
                    if ( pd == null )
                        throw new System.Exception( "Can't find DataMember '" + valueDataMember + "' in DataSource for the " + curveItem.Label + " axis." );
                    valueDataMember = pd.Name; //Get the exact case-dependent name
                    Type valueDataType = pd.PropertyType;
                    int indexValueColumn = pdcValue.IndexOf( pd );

                    //Add points
                    PointPairList points = new PointPairList();
                    PointPair pair = new PointPair();
                    object oColumnValue;

                    try
                    {
                        int nRow = 0;
                        foreach ( object row in list )
                        {
                            //
                            // Value axis binding (Y axis)
                            //
                            object valueRow = valueList[nRow];

                            //Get item value in 'row'
                            if ( bValueListContainsList )
                            {
                                if ( !( valueRow is IList ) )
                                    throw new System.InvalidCastException( "The DataSource contains a list which declares its items as lists, but these don't support the IList interface." );
                                oColumnValue = ( valueRow as IList )[indexValueColumn];
                            }
                            else
                            {
                                oColumnValue = pd.GetValue( valueRow );
                            }

                            //Convert value to double (always double)
                            double v = 0;
                            switch ( oColumnValue.GetType().ToString() )
                            {
                                case "System.DateTime":
                                    v = new XDate( Convert.ToDateTime( oColumnValue ) ).XLDate;
                                    break;
                                default:
                                    try
                                    {
                                        v = Convert.ToDouble( oColumnValue );
                                    }
                                    catch
                                    {
                                        throw new NotImplementedException( "Conversion from " + oColumnValue.GetType() + " to double not implemented." );
                                    }
                                    break;
                            }

                            //
                            // Base axis binding (X axis)
                            //
                            pair.Tag = oColumnValue; //Original typed value
                            pair.Y = v;
                            if ( this.XAxis.Type == AxisType.DateAsOrdinal
                                || this.XAxis.Type == AxisType.Date )
                            {
                                pair.X = new XDate( Convert.ToDateTime( basePd.GetValue( row ) ) ).XLDate;
                            }
                            else
                                pair.X = Convert.ToDouble( basePd.GetValue( row ) );

                            points.Add( pair );

                            nRow++;
                        }
                    }
                    catch ( System.ArgumentOutOfRangeException )
                    {
                        //A local datasource was set on this curve but it has fewer rows than the axis datasource.
                        //So we stop feeding this curve.
                    }

                    //Create curve in pane with its points
                    curveItem.CreateInPane( pane, points );
                }
            }
            else
            {
                //Add curves and values set in designer
                ZedGraphWebCurveItem curve;
                for ( int i = 0; i < CurveList.Count; i++ )
                {
                    curve = CurveList[i];

                    PointPairList points = new PointPairList();
                    PointPair pair = new PointPair();
                    for ( int j = 0; j < curve.Points.Count; j++ )
                    {
                        curve.Points[j].CopyTo( pair );
                        points.Add( pair );
                    }

                    curve.CreateInPane( pane, points );
                }
            }

            //NOTE: ZedGraphWeb.DataMember = base axis
            //NOTE: ZedGraphCurveItem.DataMember = Y
            //NOTE: Z values are only supported via the callback (???)
            //TODO: cache the data-map table before processing rows (???)
        }
Example #41
0
 public Profile(PointPair begin, PointPair end, Interval interval)
 {
     points = new PointPairList();
     points.Add(begin);
     points.Add(end);
     this.interval = interval;
     curve = new LineItem("Профиль интервала", points, Color.Black, SymbolType.Circle);
     interval.graphPane.CurveList.Add(curve);
 }
        /// <summary>
        /// Constructs an empty buffer with the specified capacity.  Pre-allocates space
        /// for all PointPair's in the list if <paramref name="preLoad"/> is true.
        /// </summary>
        /// <param name="capacity">Number of elements in the rolling list.  This number
        /// cannot be changed once the RollingPointPairList is constructed.</param>
        /// <param name="preLoad">true to pre-allocate all PointPair instances in
        /// the list, false otherwise.  Note that in order to be memory efficient,
        /// the <see cref="Add(double,double,double)"/> method should be used to add
        /// data.  Avoid the <see cref="Add(PointPair)"/> method.
        /// </param>
        /// <seealso cref="Add(double,double,double)"/>
        public RollingPointPairList( int capacity, bool preLoad )
        {
            _mBuffer = new PointPair[capacity];
            _headIdx = _tailIdx = -1;

            if ( preLoad )
                for ( int i = 0; i < capacity; i++ )
                    _mBuffer[i] = new PointPair();
        }
Example #43
0
        public void addPoint(PointPair p)
        {
            if (!interval.isPointOnInterval(p))
            {
                throw new InvalidPointPositon(p.ToString());
            }

            int i = findPointIndexOnProfile(p);

            // Первая или последняя точка интервала
            if (i <= 0 || i >= points.Count)
            {
                throw new InvalidPointPositon(p.ToString());
            }
            points.Insert(i, p);
        }
 /// <summary>
 /// Add a <see cref="PointPair"/> onto the head of the queue,
 /// overwriting old values if the buffer is full.
 /// </summary>
 /// <param name="item">The <see cref="PointPair" /> to be added.</param>
 public void Add( PointPair item )
 {
     _mBuffer[ GetNextIndex() ] = item;
 }
Example #45
0
 // Редактирование позиции точки на профиле интервала
 public void editPoint(int index, PointPair p, PointPair oldP)
 {
     if (!interval.isPointOnInterval(p))
     {
         points[index] = oldP;
         throw new InvalidPointPositon(p.ToString());
     }
     int i = findPointIndexOnProfile(p);
     if (i - 1  != index)
     {
         points[index] = oldP;
         throw new InvalidPointPositon("Невозможно изменить позицию узла профиля интервала");
     }
     points[index] = p;
     if (index == 0)
     {
         interval.earthCurve.Points[0].Y = p.Y;
     }
     if (index == points.Count - 1)
     {
         interval.earthCurve.Points[1].Y = p.Y;
     }
 }
        /// <summary>
        /// Add a set of points to the <see cref="RollingPointPairList"/> from
        /// three arrays of type double.
        /// If the X or Y array is null, then a set of ordinal values is automatically
        /// generated in its place (see <see cref="AxisType.Ordinal"/>.
        /// If the <see paramref="z"/> value
        /// is null, then it is set to zero.
        /// If the arrays are of different size, then the larger array prevails and the
        /// smaller array is padded with <see cref="PointPairBase.Missing"/> values.
        /// </summary>
        /// <param name="x">A double[] array of X values</param>
        /// <param name="y">A double[] array of Y values</param>
        /// <param name="z">A double[] array of Z values</param>
        public void Add( double[] x, double[] y, double[] z )
        {
            int len = 0;

            if ( x != null )
                len = x.Length;
            if ( y != null && y.Length > len )
                len = y.Length;
            if ( z != null && z.Length > len )
                len = z.Length;

            for ( int i = 0; i < len; i++ )
            {
                PointPair point = new PointPair();

                if ( x == null )
                    point.X = (double)i + 1.0;
                else if ( i < x.Length )
                    point.X = x[i];
                else
                    point.X = PointPair.Missing;

                if ( y == null )
                    point.Y = (double)i + 1.0;
                else if ( i < y.Length )
                    point.Y = y[i];
                else
                    point.Y = PointPair.Missing;

                if ( z == null )
                    point.Z = (double)i + 1.0;
                else if ( i < z.Length )
                    point.Z = z[i];
                else
                    point.Z = PointPair.Missing;

                Add( point );
            }
        }
Example #47
0
 // Перед каким узлом джна стоять точка с координатой p.x
 private int findPointIndexOnProfile(PointPair p)
 {
     int i = points.FindIndex(a => a.X > p.X);
     if (i == -1)
     {
         i = points.Count;
     }
     return i;
 }