コード例 #1
0
ファイル: Form1.cs プロジェクト: xeywv/Shares
 private void AddMarker(ZedGraphControl gc, DateTime date, Color color, GraphMarkerType markerType)
 {
     var ymax = gc.GraphPane.YAxis.Scale.Max;
     LineObj line = new LineObj(color, (double)new XDate(date), (double)0, (double)new XDate(date), ymax);
     line.Tag = markerType;
     line.ZOrder = ZOrder.E_BehindCurves;
     gc.GraphPane.GraphObjList.Add(line);
 }
コード例 #2
0
ファイル: Service.cs プロジェクト: deathlust/flavor-ms
        public static void AddLabel(this GraphPane pane, double x, int n)
        {
            var yScale = pane.YAxis.Scale;
            double yMin = yScale.Min;
            double yMax = yScale.Max;

            var line = new LineObj(x, yMin, x, yMax) { IsClippedToChartRect = true };
            //line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            line.Line.Color = Color.DarkGreen;
            pane.GraphObjList.Add(line);

            if (n > 0) {
                var text = new TextObj(n.ToString(), x, yMax - 0.02 * (yMax - yMin)) { IsClippedToChartRect = true };
                text.FontSpec.Border.IsVisible = true;
                pane.GraphObjList.Add(text);
            }
        }
コード例 #3
0
ファイル: ChartBuilder.cs プロジェクト: fdore/jmeter-toolkit
        /// <summary>
        /// Render legend
        /// </summary>
        /// <param name="gp"></param>
        /// <param name="dataResults"></param>
        protected override void RenderLegend(GraphPane gp, IEnumerable<RequestDataResults> dataResults)
        {
            int fontSize = 6;
            int offset = 0;
            int unit = (int) gp.YAxis.Scale.Max/10;
            // Average time
            var avgLegendBox = new BoxObj(-4, unit, 1, unit)
            {
                Fill = new Fill(Color.FromArgb(75, Color.YellowGreen))
            };
            gp.GraphObjList.Add(avgLegendBox);

            var avgLegendText = new TextObj("125", -3.5, (double)unit / 2).Style(Color.Black, fontSize);
            gp.GraphObjList.Add(avgLegendText);

            var avgLegendLabel = new TextObj("Average time", -4, (double)unit / 2).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(avgLegendLabel);

            offset += unit*2;

            // Min/Max
            var minMaxLine = new LineObj(Color.Black, -3.5, offset, -3.5, offset + 2*unit);
            gp.GraphObjList.Add(minMaxLine);

            var minMaxLabel = new TextObj("Min/Max", -4, offset + unit).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(minMaxLabel);

            offset += 3*unit;

            // Min/Max excluding extreme deciles
            var minMaxExclLine = new LineObj(Color.Black, -3.5, offset, -3.5, offset + 2*unit);
            minMaxExclLine.Line.Width = 3;
            minMaxExclLine.Line.Color = Color.DarkGray;
            gp.GraphObjList.Add(minMaxExclLine);

            var avgExclLine = new LineObj(Color.Black, -3.8, offset + unit, -3.2, offset + unit);
            avgExclLine.Line.Width = 3;
            avgExclLine.Line.Color = Color.DarkGray;
            gp.GraphObjList.Add(avgExclLine);

            var avgExclLabel1 = new TextObj("Min/Max/Avg", -4, offset + 1.2 *unit).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(avgExclLabel1);
            var avgExclLabel2 = new TextObj("excluding extremes", -4, offset + 0.8 * unit).Style(Color.Black, fontSize, AlignH.Right);
            gp.GraphObjList.Add(avgExclLabel2);
        }
コード例 #4
0
ファイル: GraphInfo.cs プロジェクト: Zordonia/AdvisIXAccel
 public CurveItemTypePair(CurveItem curve, CurveType type, String name, int nC)
 {
     Curve = curve;
     Type = type;
     Scale = GlobalVars.DEFAULTSCALE(type);
     CurrCoordinates = new CurveItemTypePair.CurrentCoordinates();
     DrawCursorDot = true;
     DrawCursorLines = true;
     HorizontalCursorLine = new LineObj();
     VerticalCursorLine = new LineObj();
     SymbolsOn = true;
     Name = name;
     ComputeInterestingValues();
     CurveObj = new CurveObject((PointPairList)curve.Points, nC);
     CurveObj.XMAX = this.XMax;
     CurveObj.YMAX = this.YMax;
     NCurves = nC;
 }
コード例 #5
0
ファイル: RssiAnalyserForm.cs プロジェクト: JamesH001/SX1231
 private void CreateThreshold()
 {
     GraphPane pane = this.graph.PaneList[0];
     double num = 0.0;
     LineObj item = new LineObj(Color.Green, 0.0, num, 1.0, num);
     item.Location.CoordinateFrame = CoordType.XChartFractionYScale;
     item.IsVisible = true;
     pane.GraphObjList.Add(item);
     pane.AxisChange();
     this.graph.Invalidate();
 }
コード例 #6
0
ファイル: Form1.cs プロジェクト: Jungwon/ZedGraph
        private void CreateGraph_RadarPlot( ZedGraphControl z1 )
        {
            GraphPane myPane = z1.GraphPane;

            RadarPointList rpl = new RadarPointList();

            Random rand = new Random();

            for ( int i = 0; i < 10; i++ )
            {
                double r = rand.NextDouble() * 10.0 + 10.0;
                PointPair pt = new PointPair( PointPair.Missing, r, "r = " + r.ToString( "f1" ) );
                rpl.Add( pt );
            }
            LineItem curve = myPane.AddCurve( "test", rpl, Color.Blue, SymbolType.Default );

            for ( int i = 0; i < 10; i++ )
            {
                LineObj line = new LineObj( 0, 0, (float) rpl[i].X, (float) rpl[i].Y );
                line.Line.Color = Color.LightBlue;
                line.ZOrder = ZOrder.E_BehindCurves;
                myPane.GraphObjList.Add( line );
            }

            myPane.XAxis.MajorTic.IsAllTics = true;
            myPane.XAxis.MinorTic.IsAllTics = true;
            myPane.XAxis.Title.IsTitleAtCross = false;
            myPane.XAxis.Cross = 0;
            myPane.XAxis.Scale.IsSkipFirstLabel = true;
            myPane.XAxis.Scale.IsSkipLastLabel = true;
            myPane.XAxis.Scale.IsSkipCrossLabel = true;

            myPane.YAxis.MajorTic.IsAllTics = true;
            myPane.YAxis.MinorTic.IsAllTics = true;
            myPane.YAxis.Title.IsTitleAtCross = false;
            myPane.YAxis.Cross = 0;
            myPane.YAxis.Scale.IsSkipFirstLabel = true;
            myPane.YAxis.Scale.IsSkipLastLabel = true;
            myPane.YAxis.Scale.IsSkipCrossLabel = true;
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: Jungwon/ZedGraph
        // Build the Chart
        private void CreateGraph_ImageObj( ZedGraphControl zg1 )
        {
            // get a reference to the GraphPane
            GraphPane myPane = zg1.GraphPane;

            // Set the Titles
            myPane.Title.Text = "My Test Bar Graph";
            myPane.XAxis.Title.Text = "Label";
            myPane.YAxis.Title.Text = "My Y Axis";
            myPane.X2Axis.Title.Text = "The Top X Axis";
            myPane.Y2Axis.Title.Text = "Y2 Axis";

            myPane.X2Axis.IsVisible = true;
            myPane.X2Axis.Scale.IsReverse = true;
            myPane.Y2Axis.IsVisible = true;

            // Make up some random data points
            string[] labels = { "Panther", "Lion", "Cheetah",
                      "Cougar", "Tiger", "Leopard" };
            double[] x = { 1, 2, 3, 4, 5, 6 };
            double[] y = { 100, 115, 75, 22, 98, 40 };
            double[] y2 = { 90, 100, 95, 35, 80, 35 };
            double[] y3 = { 80, 110, 65, 15, 54, 67 };
            double[] y4 = { 120, 125, 100, 40, 105, 75 };

            // Generate a red bar with "Curve 1" in the legend
            //BarItem myBar = myPane.AddBar( "Curve 1 label is long\nsecond line", null, y, Color.Red );
            BarItem myBar = myPane.AddBar( "Curve 1", null, y, Color.Red );
            myBar.Bar.Fill = new Fill( Color.Red, Color.White, Color.Red );

            // Generate a blue bar with "Curve 2" in the legend
            myBar = myPane.AddBar( "Curve 2", null, y2, Color.Blue );
            myBar.Bar.Fill = new Fill( Color.Blue, Color.White, Color.Blue );

            // Generate a green bar with "Curve 3" in the legend
            //myBar = myPane.AddBar( "Curve 3\ntwo lines", null, y3, Color.Green );
            myBar = myPane.AddBar( "Curve 3", null, y3, Color.Green );
            myBar.Bar.Fill = new Fill( Color.Green, Color.White, Color.Green );

            // Generate a black line with "Curve 4" in the legend
            LineItem myCurve = myPane.AddCurve( "Curve 4",
                    x, y4, Color.Black, SymbolType.Circle );
            myCurve.IsX2Axis = true;

            myCurve.Line.Fill = new Fill( Color.White,
                                         Color.LightSkyBlue, -45F );

            // Fix up the curve attributes a little
            myCurve.Symbol.Size = 8.0F;
            myCurve.Symbol.Fill = new Fill( Color.White );
            myCurve.Line.Width = 2.0F;

            // Draw the X tics between the labels instead of
            // at the labels
            myPane.XAxis.MajorTic.IsBetweenLabels = true;

            // Set the XAxis labels
            myPane.XAxis.Scale.TextLabels = labels;
            // Set the XAxis to Text type
            myPane.XAxis.Type = AxisType.Text;

            // Fill the Axis and Pane backgrounds
            myPane.Chart.Fill = new Fill( Color.White,
                    Color.FromArgb( 255, 255, 166 ), 90F );
            myPane.Fill = new Fill( Color.FromArgb( 250, 250, 255 ) );

            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            LineObj line = new LineObj( Color.Black, 2.3, 0, 2.3, 1 );
            line.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
            line.Line.Width = 2.0f;
            myPane.GraphObjList.Add( line );

            //Image image = Image.FromFile( @"c:\temp\vtx1330.jpg" );
            Image image = Bitmap.FromFile( @"c:\temp\vtx1300crop.jpg" );

            ImageObj imageObj = new ImageObj( image, new RectangleF( 3, 120, 2, 100 ) );
            imageObj.IsScaled = false;
            //			imageObj.IsVisible = true;
            imageObj.ZOrder = ZOrder.E_BehindCurves;
            //			imageObj.Location.CoordinateFrame = CoordType.ChartFraction;
            myPane.GraphObjList.Add( imageObj );

            //			myPane.Chart.Fill = new Fill( image, WrapMode.Tile );

            //            myPane.Title.Text = null;

            //          GraphPane newOne = myPane.Clone();

            // Tell ZedGraph to refigure the
            // axes since the data have changed
            zg1.AxisChange();
        }
コード例 #8
0
ファイル: LineObj.cs プロジェクト: apravdivy/MagistrSolution
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="LineObj"/> object from which to copy</param>
 public LineObj(LineObj rhs)
     : base(rhs)
 {
     _color = rhs.Color;
     _penWidth = rhs.PenWidth;
     _style = rhs._style;
 }
コード例 #9
0
        private void GoToSample(int SampleID, bool movemap, bool movegraph, bool movegrid)
        {
            bool zoomgraph = false;

            m_currSampleID = SampleID;

            markeroverlay.Markers.Clear();

            PointLatLng pt1;
            if (GetGPSFromRow(SampleID, out pt1))
            {
                MissionPlanner.Utilities.PointLatLngAlt pt3 = new MissionPlanner.Utilities.PointLatLngAlt(pt1);
                GMapMarker pos3 = new GMarkerGoogle(pt3, GMarkerGoogleType.pink_dot);
                markeroverlay.Markers.Add(pos3);
            }

            if (movemap)
            {
                myGMAP1.Position = pt1;
            }

            //move the graph "cursor"
            if (m_cursorLine != null)
            {
                zg1.GraphPane.GraphObjList.Remove(m_cursorLine);
            }
            m_cursorLine = new LineObj(Color.Black, SampleID, 0, SampleID, 1);

            m_cursorLine.Location.CoordinateFrame = CoordType.XScaleYChartFraction; // This do the trick !
            m_cursorLine.IsClippedToChartRect = true;
            m_cursorLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            m_cursorLine.Line.Width = 2f;
            m_cursorLine.Line.Color = Color.LightGray;
            m_cursorLine.ZOrder = ZOrder.E_BehindCurves;
            zg1.GraphPane.GraphObjList.Add(m_cursorLine);
            

            if (movegraph)
            {
                double delta = zg1.GraphPane.XAxis.Scale.Max - zg1.GraphPane.XAxis.Scale.Min;
                if (zoomgraph)
                {
                    delta = 2 * 60.0 / 20;
                    delta = Math.Max(100, delta);
                }
                zg1.GraphPane.XAxis.Scale.Min = SampleID - delta / 2;
                zg1.GraphPane.XAxis.Scale.Max = SampleID + delta / 2;
                zg1.AxisChange();                
            }
            zg1.Invalidate();


            if (movegrid)
            {
                try
                {
                    scrollGrid(dataGridView1, SampleID);
                    dataGridView1.CurrentCell = dataGridView1.Rows[SampleID].Cells[1];

                    dataGridView1.ClearSelection();
                    dataGridView1.Rows[(int)SampleID].Selected = true;
                    dataGridView1.Rows[(int)SampleID].Cells[1].Selected = true;
                }
                catch { }
            }


            
        }
コード例 #10
0
ファイル: Annotation.cs プロジェクト: lgatto/proteowizard
        ///<summary>Adds user requested ion series to the fragmentation summary.</summary>
        private void addFragmentationSummary (GraphObjList list, pwiz.MSGraph.MSPointList points, Peptide peptide, Fragmentation fragmentation, string topSeries, string bottomSeries)
        {
            int ionSeriesChargeState = min;
            string sequence = peptide.sequence;
            ModificationMap modifications = peptide.modifications();

            // Select the color for the ion series.
            Color topSeriesColor;
            Color bottomSeriesColor;
            switch (topSeries)
            {
                default: topSeriesColor = Color.Gray; break;
                case "a": topSeriesColor = Color.YellowGreen; break;
                case "b": topSeriesColor = Color.BlueViolet; break;
                case "c": topSeriesColor = Color.Orange; break;
            }

            switch (bottomSeries)
            {
                default: bottomSeriesColor = Color.Gray; break;
                case "x": bottomSeriesColor = Color.Green; break;
                case "y": bottomSeriesColor = Color.Blue; break;
                case "z": bottomSeriesColor = Color.OrangeRed; break;
                case "z*": bottomSeriesColor = Color.Crimson; break;
            }

            // Ion series offsets. These offsets control where on the chart a particular ion series get displayed
            double seriesTopLeftOffset = 0.2;

            // Set the constants for starting the label paint
            double topSeriesLeftPoint = 0.025;
            double residueWidth = 0.5 / ((double) sequence.Length);
            double topSeriesRightPoint = topSeriesLeftPoint + 0.5 - residueWidth;
            double tickStart = residueWidth / 2.0;

            // Process all the series except c and x
            for (int i = 1; i <= sequence.Length; ++i)
            {
                double topSeriesFragmentMZ = 0.0;
                double bottomSeriesFragmentMZ = 0.0;
                switch (topSeries)
                {
                    case "a": topSeriesFragmentMZ = fragmentation.a(i, ionSeriesChargeState); break;
                    case "b": topSeriesFragmentMZ = fragmentation.b(i, ionSeriesChargeState); break;
                    case "c": if (i < sequence.Length) topSeriesFragmentMZ = fragmentation.c(i, ionSeriesChargeState); break;
                    default: continue;
                }
                switch (bottomSeries)
                {
                    case "x": if (i < sequence.Length) bottomSeriesFragmentMZ = fragmentation.x(i, ionSeriesChargeState); break;
                    case "y": bottomSeriesFragmentMZ = fragmentation.y(i, ionSeriesChargeState); break;
                    case "z": bottomSeriesFragmentMZ = fragmentation.z(i, ionSeriesChargeState); break;
                    case "z*": bottomSeriesFragmentMZ = fragmentation.zRadical(i, ionSeriesChargeState); break;
                    default: continue;
                }

                // Check if the top and bottom fragments have evidence
                bool topSeriesHasMatch = false;
                bool bottomSeriesHasMatch = false;
                if (points != null)
                {
                    topSeriesHasMatch = topSeriesFragmentMZ > 0 && findPointWithTolerance(points, topSeriesFragmentMZ, tolerance) > -1;
                    bottomSeriesHasMatch = bottomSeriesFragmentMZ > 0 && findPointWithTolerance(points, bottomSeriesFragmentMZ, tolerance) > -1;
                }

                // Build the label for the amino acid
                // Add a text box in the middle of the left and right mz boundaries
                StringBuilder label = new StringBuilder(sequence[i - 1].ToString());

                // Figure out if any mods are there on this amino acid
                double deltaMass = modifications[i - 1].monoisotopicDeltaMass();

                // Round the mod mass and append it to the amino acid as a string
                if (deltaMass > 0.0)
                {
                    label.Append("+" + Math.Round(deltaMass));
                }
                else if (deltaMass < 0.0)
                {
                    label.Append(Math.Round(deltaMass));
                }

                TextObj text = new TextObj(label.ToString(), topSeriesLeftPoint, seriesTopLeftOffset, CoordType.ChartFraction, AlignH.Center, AlignV.Center);
                text.ZOrder = ZOrder.A_InFront;
                text.FontSpec = new FontSpec("Arial", 13, Color.Black, true, false, false);
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.Color = Color.White;
                text.IsClippedToChartRect = false;
                list.Add(text);

                if (topSeriesHasMatch)
                {
                    // Paint the tick in the middle
                    LineObj tick = new LineObj(topSeriesColor, topSeriesLeftPoint + tickStart, (seriesTopLeftOffset - 0.05), topSeriesLeftPoint + tickStart, seriesTopLeftOffset);
                    tick.Location.CoordinateFrame = CoordType.ChartFraction;
                    tick.Line.Width = 2;
                    tick.IsClippedToChartRect = true;
                    list.Add(tick);
                    // Paint the hook
                    LineObj hook = new LineObj(topSeriesColor, topSeriesLeftPoint, (seriesTopLeftOffset - 0.08), topSeriesLeftPoint + tickStart, seriesTopLeftOffset - 0.05);
                    hook.Location.CoordinateFrame = CoordType.ChartFraction;
                    hook.Line.Width = 2;
                    hook.IsClippedToChartRect = true;
                    list.Add(hook);
                }

                if (bottomSeriesHasMatch)
                {
                    // Paint the tick in the middle
                    LineObj tick = new LineObj(bottomSeriesColor, topSeriesRightPoint + tickStart, seriesTopLeftOffset, topSeriesRightPoint + tickStart, seriesTopLeftOffset + 0.05);
                    tick.Location.CoordinateFrame = CoordType.ChartFraction;
                    tick.Line.Width = 2;
                    tick.IsClippedToChartRect = true;
                    list.Add(tick);
                    // Paint the hook
                    LineObj hook = new LineObj(bottomSeriesColor, topSeriesRightPoint + tickStart, seriesTopLeftOffset + 0.05, topSeriesRightPoint + 2.0 * tickStart, seriesTopLeftOffset + 0.08);
                    hook.Location.CoordinateFrame = CoordType.ChartFraction;
                    hook.Line.Width = 2;
                    hook.IsClippedToChartRect = true;
                    list.Add(hook);
                }
                // Update the next paint point
                topSeriesLeftPoint += residueWidth;
                topSeriesRightPoint -= residueWidth;
            }
        }
コード例 #11
0
ファイル: ChartFormEx.cs プロジェクト: partyz0ne/MicroClimat
        public void MakeWindRose(List<int> nValues)
        {
            _nValues = nValues;
            GraphPane pane = mainChart.GraphPane;
            pane.Title.Text = "Роза ветров";
            pane.IsFontsScaled = false;

            pane.CurveList.Clear();

            pane.XAxis.IsVisible = false;
            pane.YAxis.IsVisible = false;

            pane.XAxis.MajorGrid.IsVisible = false;
            pane.YAxis.MajorGrid.IsVisible = false;

            pane.YAxis.MajorGrid.IsZeroLine = false;

            // Создаем список точек
            var points = new RadarPointList {Clockwise = true};

            var text = new TextObj[8];
            var axText = new TextObj[8];
            for (int i = 0; i < 8; i++)
                points.Add(_nValues[i], 1);

            int nMax = _nValues.Concat(new[] {0}).Max();
            nMax += 1;

            for (int i = 0; i < points.Count - 1; i++)
            {
                text[i] = new TextObj(_nValues[i].ToString(), points[i].X, points[i].Y);
                text[i].FontSpec.Border.IsVisible = false;
                Color color;
                if (_nValues[i] < nMax / 3)
                    color = Color.GreenYellow;
                else
                    if (_nValues[i] < (nMax / 3) * 2)
                        color = Color.Yellow;
                    else
                        color = Color.OrangeRed;
                text[i].FontSpec.Fill = new Fill(color);
                text[i].FontSpec.IsBold = true;
                pane.GraphObjList.Add(text[i]);
            }

            // Добавляем кривую по этим четырем точкам
            LineItem myCurve = pane.AddCurve("", points, Color.Blue, SymbolType.Triangle);
            myCurve.Line.Width = 2.5F;

            // Для наглядности нарисуем расстояния от начала координат до каждой из точек
            var arrow = new LineObj[8];
            arrow[0] = new LineObj(0, 0, 0, nMax);
            arrow[1] = new LineObj(0, 0, -nMax, 0);
            arrow[2] = new LineObj(0, 0, 0, -nMax);
            arrow[3] = new LineObj(0, 0, nMax, 0);
            arrow[4] = new LineObj(0, 0, nMax, nMax);
            arrow[5] = new LineObj(0, 0, -nMax, nMax);
            arrow[6] = new LineObj(0, 0, nMax, -nMax);
            arrow[7] = new LineObj(0, 0, -nMax, -nMax);

            axText[0] = new TextObj("с", 0, nMax);
            axText[1] = new TextObj("з", -nMax, 0);
            axText[2] = new TextObj("ю", 0, -nMax);
            axText[3] = new TextObj("в", nMax, 0);
            axText[4] = new TextObj("с/в", nMax, nMax);
            axText[5] = new TextObj("с/з", -nMax, nMax);
            axText[6] = new TextObj("ю/в", nMax, -nMax);
            axText[7] = new TextObj("ю/з", -nMax, -nMax);

            for (int i = 0; i < 8; i++)
            {
                pane.GraphObjList.Add(axText[i]);
                pane.GraphObjList.Add(arrow[i]);
            }

            // Отметим начало координат черным квадратиком
            var box = new BoxObj(-0.05, 0.05, 0.1, 0.1, Color.Black, Color.Black);
            pane.GraphObjList.Add(box);

            // Устанавливаем интересующий нас интервал по оси X
            pane.XAxis.Scale.Min = -nMax;
            pane.XAxis.Scale.Max = nMax;

            // Устанавливаем интересующий нас интервал по оси Y
            pane.YAxis.Scale.Min = -nMax;
            pane.YAxis.Scale.Max = nMax;

            mainChart.AxisChange();
            mainChart.Invalidate();
        }
コード例 #12
0
        private void UpdateGraph(List<Pair> PairList)
        {
            if (PairList.Count < hScrollBar.Value) return;

            list.Clear();

            double StartScan = 0;
            double StartMask = 0;
            double StartRetrigger = 0;
            double StartAWin = 0.0;
            double MaxReading = 0;

            zedGraphControl.GraphPane.GraphObjList.Clear();
            for (int i = hScrollBar.Value; i < hScrollBar.Value + WindowsSize; i++)
            {
                list.Add(PairList[i].X, PairList[i].Y);

                if (StartAWin == 0 && PairList[i].AWindow > 0)
                {
                    StartAWin = PairList[i].X;
                }

                if (StartAWin > 0 && (PairList[i].AWindow == 0 || i == hScrollBar.Value + WindowsSize - 1))
                {
                    ZedGraph.BoxObj box = new BoxObj(StartAWin, 50, PairList[i].X - StartAWin, 50.0, Color.Black, Color.FromArgb(64, Color.Black));
                    box.ZOrder = ZOrder.D_BehindAxis;
                    box.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(box);
                    StartAWin = 0;
                }

                if (PairList[i].AWindow == 2)
                {
                    ZedGraph.LineObj line = new LineObj(Color.Green, PairList[i].X, 1023, PairList[i].X, 0);
                    line.ZOrder = ZOrder.D_BehindAxis;
                    line.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(line);
                }

                if (StartScan == 0 && PairList[i].Status == 1)
                {
                    StartScan = PairList[i].X;
                }
                if (StartScan > 0 && PairList[i].Y > MaxReading) MaxReading = PairList[i].Y;
                if (StartScan > 0 && (PairList[i].Status != 1 || i == hScrollBar.Value + WindowsSize - 1))
                {
                    ZedGraph.BoxObj box = new BoxObj(StartScan, /*PairList[i - 1].*/MaxReading, PairList[i].X - StartScan, MaxReading, Color.Black, Color.FromArgb(64, Color.Yellow));
                    box.ZOrder = ZOrder.D_BehindAxis;
                    box.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(box);
                    StartScan = 0;
                    MaxReading = 0;
                }
                if (StartMask == 0 && PairList[i].Status == 2)
                {
                    StartMask = PairList[i].X;
                }

                if (StartMask > 0 && (PairList[i].Status != 2 || i == hScrollBar.Value + WindowsSize - 1))
                {
                    ZedGraph.BoxObj box = new BoxObj(StartMask, 100, PairList[i].X - StartMask, 100.0, Color.Black, Color.FromArgb(64, Color.Red));
                    box.ZOrder = ZOrder.D_BehindAxis;
                    box.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(box);
                    StartMask = 0;
                }

                if (StartRetrigger == 0 && PairList[i].Status == 3)
                {
                    StartRetrigger = PairList[i].X;
                }

                if (StartRetrigger > 0 && (PairList[i].Status != 3 || i == hScrollBar.Value + WindowsSize - 1))
                {
                    ZedGraph.BoxObj box = new BoxObj(StartRetrigger, 100, PairList[i].X - StartRetrigger, 100.0, Color.Black, Color.FromArgb(64, Color.Blue));
                    box.ZOrder = ZOrder.D_BehindAxis;
                    box.IsClippedToChartRect = true;
                    zedGraphControl.GraphPane.GraphObjList.Add(box);
                    StartRetrigger = 0;
                }
            }
            if ((hScrollBar.Value + WindowsSize) < PairList.Count)
            {
                zedGraphControl.GraphPane.XAxis.Scale.Max = PairList[hScrollBar.Value + WindowsSize].X;
                zedGraphControl.GraphPane.XAxis.Scale.Min = PairList[hScrollBar.Value].X;

                zedGraphControl.Invoke(new EventHandler(delegate { zedGraphControl.AxisChange(); zedGraphControl.Refresh(); }));

            }
        }
コード例 #13
0
 private ScaledRetentionTime FindAnnotatedSpectrumRetentionTime(LineObj line)
 {
     foreach (var graphItem in GraphItems)
     {
         var spectrumRT = graphItem.FindSpectrumRetentionTime(line);
         if (!spectrumRT.IsZero)
         {
             return spectrumRT;
         }
     }
     return ScaledRetentionTime.ZERO;
 }
コード例 #14
0
        public override void AddAnnotations(MSGraphPane graphPane, Graphics g, MSPointList pointList, GraphObjList annotations)
        {
            // ReSharper disable UseObjectOrCollectionInitializer
            foreach (var rmi in SpectrumInfo.PeaksMatched)
            {
                if (!IsVisibleIon(rmi))
                    continue;

                IonType type = IsVisibleIon(rmi.IonType, rmi.Ordinal, rmi.Charge) ?
                                                                                      rmi.IonType : rmi.IonType2;

                Color color;
                switch (type)
                {
                    default: color = COLOR_NONE; break;
                    case IonType.a: color = COLOR_A; break;
                    case IonType.x: color = COLOR_X; break;
                    case IonType.b: color = COLOR_B; break;
                    case IonType.y: color = COLOR_Y; break;
                    case IonType.c: color = COLOR_C; break;
                    case IonType.z: color = COLOR_Z; break;
                    // FUTURE: Add custom ions when LibraryRankedSpectrumInfo can support them
                    case IonType.precursor: color = COLOR_PRECURSOR; break;
                }

                if (IsMatch(rmi.PredictedMz))
                {
                    color = COLOR_SELECTED;
                }

                double mz = rmi.ObservedMz;
                var stick = new LineObj(color, mz, rmi.Intensity, mz, 0);
                stick.IsClippedToChartRect = true;
                stick.Location.CoordinateFrame = CoordType.AxisXYScale;
                stick.Line.Width = LineWidth + 1;
                annotations.Add(stick);
            }
            //ReSharper restore UseObjectOrCollectionInitializer
        }
コード例 #15
0
ファイル: Annotation.cs プロジェクト: lgatto/proteowizard
        private void addFragment( GraphObjList list, pwiz.MSGraph.MSPointList points, string series, int length, int charge, double mz )
        {
            string label = String.Format("{0}{1}{2}", series, length, (charge > 1 ? "+" + charge.ToString() : ""));

            Color color;
            double offset;
            switch( series )
            {
                default: color = Color.Gray; offset = 0.1;  break;
                case "a": color = Color.YellowGreen; offset = 0.1; break;
                case "x": color = Color.Green; offset = 0.12; break;
                case "b": color = Color.BlueViolet; offset = 0.14; break;
                case "y": color = Color.Blue; offset = 0.16; break;
                case "c": color = Color.Orange; offset = 0.18; break;
                case "z": color = Color.OrangeRed; offset = 0.2; break;
                case "z*": color = Color.Crimson; offset = 0.4; break;
            }

            numFragmentsPredicted[series+(charge > 1 ? "+" + charge.ToString() : "")].Add(mz);

            int index = -1;
            if( points != null )
                index = points.LowerBound( mz - 0.5 );

            if( index == -1 || points.ScaledList[index].X > ( mz + 0.5 ) )
            // no matching point: present a "missed" fragment annotation
            {
                if( !showMisses )
                    return;

                color = Color.FromArgb( 115, color ); // transparent to emphasize miss

                LineObj stick = new LineObj( color, mz, offset, mz, 1 );
                stick.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                stick.Line.Width = 2;
                stick.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                list.Add( stick );

                if( showLabels )
                {
                    TextObj text = new TextObj( label, mz, offset, CoordType.XScaleYChartFraction,
                                                AlignH.Center, AlignV.Bottom );
                    text.ZOrder = ZOrder.A_InFront;
                    text.FontSpec = new FontSpec( "Arial", 12, color, false, false, false );
                    text.FontSpec.Border.IsVisible = false;
                    //text.IsClippedToChartRect = true;
                    list.Add( text );
                }
            } else
            // matching point found: present the point as the fragment
            {
                numFragmentsMatched[series + (charge > 1 ? "+" + charge.ToString() : "")].Add(mz);
                LineObj stick = new LineObj( color, mz, points.ScaledList[index].Y, mz, 0 );
                stick.Location.CoordinateFrame = CoordType.AxisXYScale;
                stick.Line.Width = 2;
                list.Add( stick );

                if( showLabels )
                {
                    // use an existing text point annotation if possible
                    TextObj text = null;
                    foreach( GraphObj obj in list )
                    {
                        if( obj is TextObj &&
                            ( obj.Location.CoordinateFrame == CoordType.AxisXYScale ||
                              obj.Location.CoordinateFrame == CoordType.XScaleYChartFraction ) &&
                            Math.Abs( obj.Location.X - mz ) < 0.5 )
                        {
                            text = obj as TextObj;
                            text.Text = String.Format( "{0}\n{1}", label, text.Text );
                            break;
                        }
                    }

                    if( text == null )
                    {
                        text = new TextObj( label, mz, points.ScaledList[index].Y, CoordType.AxisXYScale,
                                            AlignH.Center, AlignV.Bottom );
                        list.Add( text );
                    }

                    text.ZOrder = ZOrder.A_InFront;
                    text.FontSpec = new FontSpec( "Arial", 12, color, false, false, false );
                    text.FontSpec.Border.IsVisible = false;
                    //text.IsClippedToChartRect = true;
                }
            }
        }
コード例 #16
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="LineObj"/> object from which to copy</param>
 public LineObj(LineObj rhs) : base(rhs)
 {
     _color    = rhs.Color;
     _penWidth = rhs.PenWidth;
     _style    = rhs._style;
 }
コード例 #17
0
ファイル: Annotation.cs プロジェクト: lgatto/proteowizard
        private void addFragment (GraphObjList list, pwiz.MSGraph.MSPointList points, string series, int length, int charge, double mz)
        {
            string label = String.Format("{0}{1}{2}",
                                         series,
                                         (length > 0 ? length.ToString() : ""),
                                         (charge > 1 ? "+" + charge.ToString() : ""));

            Color color;
            double offset;
            switch (series)
            {
                default:
                    color = series.StartsWith("immonium") ? Color.Black : Color.Gray;
                    offset = 0.1;
                    break;
                case "a": color = Color.YellowGreen; offset = 0.1; break;
                case "x": color = Color.Green; offset = 0.12; break;
                case "b": color = Color.BlueViolet; offset = 0.14; break;
                case "y": color = Color.Blue; offset = 0.16; break;
                case "c": color = Color.Orange; offset = 0.18; break;
                case "z": color = Color.OrangeRed; offset = 0.2; break;
                case "z*": color = Color.Crimson; offset = 0.4; break;
            }


            int index = -1;
            if (points != null)
                index = findPointWithTolerance(points, mz, tolerance);

            if (index == -1)
            // no matching point: present a "missed" fragment annotation
            {
                if (!showMisses)
                    return;

                color = Color.FromArgb(115, color); // transparent to emphasize miss

                if (list.Count(o => o.Location.X == mz) == 0)
                {
                    LineObj stick = new LineObj(color, mz, offset, mz, 1);
                    stick.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                    stick.Line.Width = 2;
                    stick.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                    stick.IsClippedToChartRect = true;
                    list.Add(stick);

                    if (showLabels)
                    {
                        TextObj text = new TextObj(label, mz, offset, CoordType.XScaleYChartFraction,
                                                   AlignH.Center, AlignV.Bottom);
                        text.ZOrder = ZOrder.A_InFront;
                        text.FontSpec = new FontSpec("Arial", 12, color, false, false, false);
                        text.FontSpec.Border.IsVisible = false;
                        //text.IsClippedToChartRect = true;
                        list.Add(text);
                    }
                }
            }
            else
            // matching point found: present the point as the fragment
            {
                if (list.Count(o => o.Location.X == mz) == 0)
                {
                    LineObj stick = new LineObj(color, mz, points.FullList[index].Y, mz, 0);
                    stick.Location.CoordinateFrame = CoordType.AxisXYScale;
                    stick.Line.Width = 2;
                    stick.IsClippedToChartRect = true;
                    list.Add(stick);
                }

                if (showLabels)
                {
                    // use an existing text point annotation if possible
                    TextObj text = null;
                    double minError = Double.MaxValue;
                    foreach (GraphObj obj in list)
                    {
                        if (obj is TextObj &&
                            (obj.Location.CoordinateFrame == CoordType.AxisXYScale ||
                             obj.Location.CoordinateFrame == CoordType.XScaleYChartFraction))
                        {
                            double curError = Math.Abs(obj.Location.X - points.FullList[index].X);
                            if (curError < 1e-4 && curError < minError)
                            {
                                minError = curError;
                                text = obj as TextObj;
                                if (!text.Text.Contains(label))
                                    text.Text = String.Format("{0}\n{1}", label, text.Text);
                            }
                        }
                    }

                    if (text == null)
                    {
                        text = new TextObj(label, mz, points.FullList[index].Y, CoordType.AxisXYScale,
                                            AlignH.Center, AlignV.Bottom);
                        list.Add(text);
                    }

                    text.ZOrder = ZOrder.A_InFront;
                    text.FontSpec = new FontSpec("Arial", 12, color, false, false, false);
                    text.FontSpec.Border.IsVisible = false;
                    //text.IsClippedToChartRect = true;
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Update vertical line the marks current import time for progressively loaded files.
        /// </summary>
        private void UpdateProgressLine(double time)
        {
            // Remove old progressive loading indicators.
            if (_unfinishedBox != null)
            {
                _graphPane.GraphObjList.Remove(_unfinishedBox);
                _graphPane.GraphObjList.Remove(_unfinishedLine);
                _unfinishedBox = null;
            }

            // If we're still loading, create a white rectangle which blocks the fill background, indicating data yet to be loaded.
            if (time < _status.Transitions.MaxRetentionTime)
            {
                _graphPane.Chart.Fill = new Fill(_backgroundGradientColor1, _backgroundGradientColor2, 45.0f);
                _unfinishedBox = new BoxObj(
                    time,
                    _graphPane.YAxis.Scale.Max,
                    _graphPane.XAxis.Scale.Max - time,
                    _graphPane.YAxis.Scale.Max - _graphPane.YAxis.Scale.Min,
                    Color.White, Color.White)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    ZOrder = ZOrder.F_BehindGrid
                };
                _graphPane.GraphObjList.Add(_unfinishedBox);

                // Place a vertical line after the last loaded data.
                _unfinishedLine = new LineObj(
                    _unfinishedLineColor,
                    time,
                    _graphPane.YAxis.Scale.Max,
                    time,
                    _graphPane.YAxis.Scale.Min)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    Line = { Width = PROGRESS_LINE_WIDTH },
                    ZOrder = ZOrder.D_BehindAxis
                };
                _graphPane.GraphObjList.Add(_unfinishedLine);
            }
        }
コード例 #19
0
ファイル: Annotation.cs プロジェクト: lgatto/proteowizard
        ///<summary>Adds user requested ion series on top of the chart.</summary>
        private void addIonSeries (GraphObjList list, pwiz.MSGraph.MSPointList points, Peptide peptide, Fragmentation fragmentation, string topSeries, string bottomSeries)
        {
            int ionSeriesChargeState = min;
            string sequence = peptide.sequence;
            ModificationMap modifications = peptide.modifications();

            // Select the color for the ion series.
            Color topSeriesColor;
            Color bottomSeriesColor;
            switch (topSeries)
            {
                default: topSeriesColor = Color.Gray; break;
                case "a": topSeriesColor = Color.YellowGreen; break;
                case "b": topSeriesColor = Color.BlueViolet; break;
                case "c": topSeriesColor = Color.Orange; break;
            }

            switch (bottomSeries)
            {
                default: bottomSeriesColor = Color.Gray; break;
                case "x": bottomSeriesColor = Color.Green; break;
                case "y": bottomSeriesColor = Color.Blue; break;
                case "z": bottomSeriesColor = Color.OrangeRed; break;
                case "z*": bottomSeriesColor = Color.Crimson; break;
            }
            // Ion series offsets. These offsets control where on the chart a particular ion series
            // get displayed
            double topSeriesOffset = 0.025;
            double bottomSeriesOffset = 0.1;
            if (topSeries.Length == 0)
                bottomSeriesOffset = topSeriesOffset;

            double topSeriesLeftPoint = 0.0;
            double bottomSeriesLeftPoint = 0.0;

            // Step through each fragmentation site
            for (int i = 1; i <= sequence.Length; ++i)
            {
                // Paint the top series first
                double rightPoint = 0.0;
                // Figure out the right mz for this fragmentaion site
                switch (topSeries)
                {
                    case "a": rightPoint = fragmentation.a(i, ionSeriesChargeState); break;
                    case "b": rightPoint = fragmentation.b(i, ionSeriesChargeState); break;
                    case "c": if (i < sequence.Length) rightPoint = fragmentation.c(i, ionSeriesChargeState); break;
                    default: continue;
                }

                // If the left mz and right mz are different
                if (rightPoint > 0 && topSeriesLeftPoint != rightPoint)
                {
                    LineObj line;
                    // Use a dashed line format if there are fragment ions supporting this
                    // amino acid
                    if (!aminoAcidHasFragmentEvidence(points, topSeriesLeftPoint, rightPoint))
                    {
                        // Draw the line from previous mz to site to this mz in trasparent color.
                        line = new LineObj(Color.FromArgb(115, topSeriesColor), topSeriesLeftPoint, topSeriesOffset, rightPoint, topSeriesOffset);
                        line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
                    }
                    else
                    {
                        // Draw the line from previous mz to site to this mz in solid color.
                        line = new LineObj(topSeriesColor, topSeriesLeftPoint, topSeriesOffset, rightPoint, topSeriesOffset);
                    }
                    line.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                    line.Line.Width = 2;
                    line.ZOrder = ZOrder.F_BehindGrid;
                    line.IsClippedToChartRect = true;
                    list.Add(line);
                    // Add a tick demarking the fragmentation site.
                    LineObj tick = new LineObj(topSeriesColor, rightPoint, (topSeriesOffset - 0.015), rightPoint, (topSeriesOffset + 0.015));
                    tick.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                    tick.Line.Width = 2;
                    tick.IsClippedToChartRect = true;
                    list.Add(tick);
                    // Add a text box in the middle of the left and right mz boundaries
                    StringBuilder label = new StringBuilder(sequence[i - 1].ToString());
                    // Figure out if any mods are there on this amino acid
                    double deltaMass = modifications[i - 1].monoisotopicDeltaMass();
                    // Round the mod mass and append it to the amino acid as a string
                    if (deltaMass > 0.0)
                    {
                        label.Append("+" + Math.Round(deltaMass));
                    }
                    else if (deltaMass < 0.0)
                    {
                        label.Append(Math.Round(deltaMass));
                    }
                    TextObj text = new TextObj(label.ToString(), (topSeriesLeftPoint + rightPoint) / 2.0,
                        topSeriesOffset, CoordType.XScaleYChartFraction, AlignH.Center, AlignV.Center);
                    text.ZOrder = ZOrder.A_InFront;
                    text.FontSpec = new FontSpec("Arial", 13, Color.Black, true, false, false);
                    text.FontSpec.Border.IsVisible = false;
                    text.FontSpec.Fill.Color = Color.White;
                    text.IsClippedToChartRect = true;
                    list.Add(text);
                    topSeriesLeftPoint = rightPoint;
                }

                // Time to paint the bottom series
                // Get the right mz for this series
                switch (bottomSeries)
                {
                    case "x": if (i < sequence.Length) rightPoint = fragmentation.x(i, ionSeriesChargeState); break;
                    case "y": rightPoint = fragmentation.y(i, ionSeriesChargeState); break;
                    case "z": rightPoint = fragmentation.z(i, ionSeriesChargeState); break;
                    case "z*": rightPoint = fragmentation.zRadical(i, ionSeriesChargeState); break;
                    default: rightPoint = 0.0; break;
                }

                // If the left and right mz are different
                if (rightPoint > 0 && bottomSeriesLeftPoint != rightPoint)
                {
                    LineObj line;
                    // Use a dashed line format if there are fragment ions supporting this
                    // amino acid
                    if (!aminoAcidHasFragmentEvidence(points, bottomSeriesLeftPoint, rightPoint))
                    {
                        // Draw the line from previous mz to site to this mz in trasparent color.
                        line = new LineObj(Color.FromArgb(115, bottomSeriesColor), bottomSeriesLeftPoint, bottomSeriesOffset, rightPoint, bottomSeriesOffset);
                        line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
                    }
                    else
                    {
                        // Draw the line from previous mz to site to this mz in solid color.
                        line = new LineObj(bottomSeriesColor, bottomSeriesLeftPoint, bottomSeriesOffset, rightPoint, bottomSeriesOffset);
                    }
                    line.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                    line.Line.Width = 2;
                    line.ZOrder = ZOrder.F_BehindGrid;
                    line.IsClippedToChartRect = true;
                    list.Add(line);
                    // Draw a tick mark demarking the fragmentation site
                    LineObj tick = new LineObj(bottomSeriesColor, rightPoint, (bottomSeriesOffset - 0.015), rightPoint, (bottomSeriesOffset + 0.015));
                    tick.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                    tick.Line.Width = 2;
                    tick.IsClippedToChartRect = true;
                    list.Add(tick);
                    // Add the text label containing the amino acid
                    StringBuilder label = new StringBuilder(sequence[sequence.Length - i].ToString());
                    // Figure out if any mods are there on this amino acid
                    double deltaMass = modifications[sequence.Length - i].monoisotopicDeltaMass();
                    // Round the mod mass and append it to the amino acid as a string
                    if (deltaMass > 0.0)
                    {
                        label.Append("+" + Math.Round(deltaMass));
                    }
                    else if (deltaMass < 0.0)
                    {
                        label.Append(Math.Round(deltaMass));
                    }
                    TextObj text = new TextObj(label.ToString(), (bottomSeriesLeftPoint + rightPoint) / 2.0,
                        bottomSeriesOffset, CoordType.XScaleYChartFraction, AlignH.Center, AlignV.Center);
                    text.ZOrder = ZOrder.A_InFront;
                    text.FontSpec = new FontSpec("Arial", 13, Color.Black, true, false, false);
                    text.FontSpec.Border.IsVisible = false;
                    text.FontSpec.Fill.Color = Color.White;
                    text.IsClippedToChartRect = true;
                    list.Add(text);
                    bottomSeriesLeftPoint = rightPoint;
                }
            }
        }
コード例 #20
0
ファイル: ChromGraphItem.cs プロジェクト: lgatto/proteowizard
        public override void AddAnnotations(MSGraphPane graphPane, Graphics g,
            MSPointList pointList, GraphObjList annotations)
        {
            if (Chromatogram == null)
                return;

            // Calculate maximum y for potential retention time indicators
            PointF ptTop = new PointF(0, graphPane.Chart.Rect.Top);

            if (GraphChromatogram.ShowRT != ShowRTChrom.none)
            {
                if (RetentionMsMs != null)
                {
                    foreach (double retentionTime in RetentionMsMs)
                    {
                        Color color = COLOR_MSMSID_TIME;
                        if (SelectedRetentionMsMs.HasValue && Equals((float) retentionTime, (float) SelectedRetentionMsMs))
                        {
                            color = ColorSelected;
                        }
                        AddRetentionTimeAnnotation(graphPane, g, annotations, ptTop,
                            Resources.ChromGraphItem_AddAnnotations_ID, GraphObjType.ms_ms_id, color,
                            ScaleRetentionTime(retentionTime));
                    }
                }
                if (AlignedRetentionMsMs != null)
                {
                    foreach (var time in AlignedRetentionMsMs)
                    {
                        var scaledTime = ScaleRetentionTime(time);
                        var line = new LineObj(COLOR_ALIGNED_MSMSID_TIME, scaledTime.DisplayTime, 0,
                                               scaledTime.DisplayTime, 1)
                        {
                            ZOrder = ZOrder.F_BehindGrid,
                            Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                            IsClippedToChartRect = true,
                            Tag = new GraphObjTag(this, GraphObjType.aligned_ms_id, scaledTime),
                        };
                        annotations.Add(line);
                    }
                }
                if (UnalignedRetentionMsMs != null)
                {
                    foreach (var time in UnalignedRetentionMsMs)
                    {
                        var scaledTime = ScaleRetentionTime(time);
                        var line = new LineObj(COLOR_UNALIGNED_MSMSID_TIME, scaledTime.DisplayTime, 0,
                                               scaledTime.DisplayTime, 1)
                        {
                            ZOrder = ZOrder.F_BehindGrid,
                            Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                            IsClippedToChartRect = true,
                            Tag = new GraphObjTag(this, GraphObjType.unaligned_ms_id, scaledTime),
                        };
                        annotations.Add(line);
                    }
                }
            }

            // Draw retention time indicator, if set
            if (RetentionPrediction.HasValue)
            {
                double time = RetentionPrediction.Value;

                // Create temporary label to calculate positions
                if (GraphChromatogram.ShowRT != ShowRTChrom.none)
                {
                    AddRetentionTimeAnnotation(graphPane,
                                               g,
                                               annotations,
                                               ptTop,
                                               Resources.ChromGraphItem_AddAnnotations_Predicted,
                                               GraphObjType.predicted_rt_window,
                                               COLOR_RETENTION_TIME,
                                               ScaleRetentionTime(time));
                }

                // Draw background for retention time window
                if (RetentionWindow > 0)
                {
                    double x1 = ScaleRetentionTime(time - RetentionWindow/2).DisplayTime;
                    double x2 = ScaleRetentionTime(time + RetentionWindow/2).DisplayTime;
                    BoxObj box = new BoxObj(x1, 0, x2-x1, 1,
                                            COLOR_RETENTION_WINDOW, COLOR_RETENTION_WINDOW)
                                     {
                                         Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                                         IsClippedToChartRect = true,
                                         ZOrder = ZOrder.F_BehindGrid
                                     };
                    annotations.Add(box);
                }
            }

            if (RetentionExplicit != null && GraphChromatogram.ShowRT != ShowRTChrom.none)
            {
                // Create temporary label to calculate positions
                AddRetentionTimeAnnotation(graphPane,
                                            g,
                                            annotations,
                                            ptTop,
                                            Resources.ChromGraphItem_AddAnnotations_Explicit,
                                            GraphObjType.predicted_rt_window,
                                            COLOR_RETENTION_TIME,
                                            ScaleRetentionTime(RetentionExplicit.RetentionTime));
            }

            for (int i = 0, len = Chromatogram.NumPeaks; i < len; i++)
            {
                if (_arrayLabelIndexes[i] == -1)
                    continue;

                double maxIntensity = _intensities[_arrayLabelIndexes[i]];

                // Show peak extent indicators, if they are far enough apart
                ChromPeak peak = Chromatogram.GetPeak(i);
                AddPeakBoundaries(graphPane, annotations, false,
                                  ScaleRetentionTime(peak.StartTime), ScaleRetentionTime(peak.EndTime), maxIntensity);
            }
        }
コード例 #21
0
ファイル: Form1.cs プロジェクト: hzhiguang/AbuseAnalysis
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog oFD1 = new OpenFileDialog();
            oFD1.Multiselect = true;

            if (oFD1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                files = oFD1.SafeFileNames; //Save only the names
                paths = oFD1.FileNames; //Save the full paths
                for (int i = 0; i < files.Length; i++)
                {
                    //listBox1.Items.Add(files[i]); //Add songs to the listbox
                    ext = Path.GetExtension(oFD1.FileName);
                    if (ext == ".avi")
                    {
                        //Convert Avi to wav
                        AviManager aviManager = new AviManager(oFD1.FileName, true);
                        AudioStream audioStream = aviManager.GetWaveStream();
                        audioStream.ExportStream(oFD1.FileName + ".wav");
                        filepath = oFD1.FileName + ".wav";
                        aviManager.Close();
                        listBox1.Items.Add(files[i]); //Add songs to the listbox
                    }
                    else if (ext == ".wav")
                    {
                        filepath = oFD1.FileName;
                        listBox1.Items.Add(files[i]); //Add songs to the listbox
                    }
                }
            }

            NAudio.Wave.WaveChannel32 wave = new NAudio.Wave.WaveChannel32(new NAudio.Wave.WaveFileReader(filepath));
            WaveFileReader wavFile = new WaveFileReader(filepath);
            byte[] mainBuffer = new byte[wave.Length];

            float fileSize = (float)wavFile.Length / 1048576;
            if (fileSize < 2)
                window = 8;
            else if (fileSize > 2 && fileSize < 4)
                window = 16;
            else if (fileSize > 4 && fileSize < 8)
                window = 32;
            else if (fileSize > 8 && fileSize < 12)
                window = 128;
            else if (fileSize > 12 && fileSize < 20)
                window = 256;
            else if (fileSize > 20 && fileSize < 30)
                window = 512;
            else
                window = 2048;

            float[] fbuffer = new float[mainBuffer.Length / window];
            wave.Read(mainBuffer, 0, mainBuffer.Length);

            for (int i = 0; i < fbuffer.Length; i++)
            {
                fbuffer[i] = (BitConverter.ToSingle(mainBuffer, i * window));
            }

            double time = wave.TotalTime.TotalSeconds;
            GraphPane myPane1 = zedGraphControl2.GraphPane;
            PointPairList list1 = new PointPairList();
            PointPairList list2 = new PointPairList();
            for (int i = 0; i < fbuffer.Length; i++)
            {
                list1.Add(i, fbuffer[i]);
            }
            list2.Add(0, 0);
            list2.Add(time, 0);
            if (myCurve1 != null && myCurve2 != null)
            {
                myCurve1.Clear();
                myCurve2.Clear();
            }
            GraphPane myPane2 = zedGraphControl2.GraphPane;
            myPane2.Title.Text = "Audio Sound Wave";
            myPane2.XAxis.Title.Text = "Time, Seconds";
            myPane2.YAxis.Title.Text = "Sound Wave Graph";
            myCurve1 = myPane1.AddCurve(null, list1, System.Drawing.Color.Blue, SymbolType.None);
            myCurve1.IsX2Axis = true;
            myCurve2 = myPane1.AddCurve(null, list2, System.Drawing.Color.Black, SymbolType.None);
            myPane1.XAxis.Scale.MaxAuto = true;
            myPane1.XAxis.Scale.MinAuto = true;

            //Threshold Line
            double threshHoldY = -1.2;
            double threshHoldX = 1.2;
            LineObj threshHoldLine = new LineObj(System.Drawing.Color.Red, myPane2.XAxis.Scale.Min, threshHoldY, myPane2.XAxis.Scale.Max, threshHoldY);
            LineObj threshHoldLine2 = new LineObj(System.Drawing.Color.Red, myPane2.XAxis.Scale.Min, threshHoldX, myPane2.XAxis.Scale.Max, threshHoldX);
            myPane2.GraphObjList.Add(threshHoldLine);
            myPane2.GraphObjList.Add(threshHoldLine2);

            // Add a text box with instructions
            TextObj text = new TextObj(
                "Ratio Conversion: 1:100\nRed Lines: Threshold\nZoom: left mouse & drag\nContext Menu: right mouse",
                0.05f, 0.95f, CoordType.ChartFraction, AlignH.Left, AlignV.Bottom);
            text.FontSpec.StringAlignment = StringAlignment.Near;
            myPane2.GraphObjList.Add(text);

            // Show the x axis grid
            myPane2.XAxis.MajorGrid.IsVisible = true;
            myPane2.YAxis.MajorGrid.IsVisible = true;
            // Just manually control the X axis range so it scrolls continuously
            // instead of discrete step-sized jumps
            //myPane2.XAxis.Scale.Format = @"00:00:00";
            myPane2.XAxis.Scale.IsSkipCrossLabel = true;
            myPane2.XAxis.Scale.IsPreventLabelOverlap = true;
            myPane2.XAxis.Type = ZedGraph.AxisType.Linear;
            myPane2.XAxis.Scale.Min = 0;
            myPane2.XAxis.Scale.Max = 1.2;
            myPane2.AxisChange();

            // turn off the opposite tics so the Y tics don't show up on the Y2 axis
            myPane2.YAxis.MajorTic.IsOpposite = false;
            myPane2.YAxis.MinorTic.IsOpposite = false;
            // Don't display the Y zero line
            myPane2.YAxis.MajorGrid.IsZeroLine = false;
            // Align the Y axis labels so they are flush to the axis
            myPane2.YAxis.Scale.Align = AlignP.Inside;
            // Manually set the axis range
            myPane2.YAxis.Scale.Min = -1.5;
            myPane2.YAxis.Scale.Max = 1.5;

            zedGraphControl2.AxisChange();
            zedGraphControl2.Invalidate();
        }
コード例 #22
0
ファイル: ChromGraphItem.cs プロジェクト: lgatto/proteowizard
        private void AddPeakBoundaries(GraphPane graphPane, ICollection<GraphObj> annotations,
            bool best, ScaledRetentionTime startTime, ScaledRetentionTime endTime, double maxIntensity)
        {
            // Only show boundaries for dragging when boundaries turned off
            if (!Settings.Default.ShowPeakBoundaries && (!best || DragInfo == null))
                return;
            float xStart = graphPane.XAxis.Scale.Transform(startTime.DisplayTime);
            float xEnd = graphPane.XAxis.Scale.Transform(endTime.DisplayTime);
            // Hide boundaries, if they are too close together
            if (xEnd - xStart <= MIN_BOUNDARY_DISPLAY_WIDTH)
            {
                // But not if they are currently part of a drag operation.
                if (DragInfo == null)
                    return;
            }

            // Make sure the best borders are visible
            if (best)
            {
                float yMax = graphPane.YAxis.Scale.Transform(maxIntensity);
                float yZero = graphPane.YAxis.Scale.Transform(0);
                if (yZero - yMax < MIN_BEST_BOUNDARY_HEIGHT)
                    maxIntensity = graphPane.YAxis.Scale.ReverseTransform(yZero - MIN_BEST_BOUNDARY_HEIGHT);
            }
            // Summary graphs show only the best peak boundaries
            else if (_isSummary)
            {
                return;
            }

            Color colorBoundaries = (best ? COLOR_BOUNDARIES_BEST : COLOR_BOUNDARIES);
            GraphObjType graphObjType = best ? GraphObjType.best_peak : GraphObjType.peak;

            // Make sure to get maximum intensity within the peak range,
            // as this is not guaranteed to be the center of the peak
            LineObj stickStart = new LineObj(colorBoundaries, startTime.DisplayTime, maxIntensity, startTime.DisplayTime, 0)
                                     {
                                         IsClippedToChartRect = true,
                                         Location = { CoordinateFrame = CoordType.AxisXYScale },
                                         ZOrder = ZOrder.B_BehindLegend,
                                         Line = { Width = 1, Style = DashStyle.Dash },
                                         Tag = new GraphObjTag(this, graphObjType, startTime),
                                     };
            annotations.Add(stickStart);
            LineObj stickEnd = new LineObj(colorBoundaries, endTime.DisplayTime, maxIntensity, endTime.DisplayTime, 0)
                                   {
                                       IsClippedToChartRect = true,
                                       Location = { CoordinateFrame = CoordType.AxisXYScale },
                                       ZOrder = ZOrder.B_BehindLegend,
                                       Line = { Width = 1, Style = DashStyle.Dash },
                                       Tag = new GraphObjTag(this, graphObjType, endTime),
                                   };
            annotations.Add(stickEnd);
        }
コード例 #23
0
ファイル: Form1.cs プロジェクト: Jungwon/ZedGraph
        // Basic curve test - Date Axis
        private void CreateGraph_DateAxis( ZedGraphControl z1 )
        {
            GraphPane myPane = z1.GraphPane;

            PointPairList list = new PointPairList();
            PointPairList list2 = new PointPairList();

            for ( int i = 0; i < 50; i++ )
            {
                double x = new XDate( 2005, 12 + i, 15 );
                double y = Math.Sin( i / 8.0 ) * 1000 + 1001;
                list.Add( x, y, 1500 );
                list2.Add( x, y * 1.2, 1500 );
            }

            LineItem line = myPane.AddCurve( "Line", list, Color.Blue, SymbolType.Diamond );
            //myPane.XAxis.Scale.Format = "MMM\nyyyy";
            myPane.XAxis.Type = AxisType.Date;

            //myPane.XAxis.Scale.MajorStep = 1;
            //myPane.XAxis.Scale.MajorUnit = DateUnit.Year;
            myPane.XAxis.Scale.MinorStep = 1;
            myPane.XAxis.Scale.MinorUnit = DateUnit.Month;

            /*
            BarItem myBar = myPane.AddBar( "Bar", list, Color.Blue );
            BarItem myBar2 = myPane.AddBar( "Bar2", list2, Color.Green );
            //LineItem myCurve = myPane.AddCurve( "curve", list, Color.Blue, SymbolType.Diamond );
            myPane.BarSettings.Type = BarType.ClusterHiLow;
            myPane.BarSettings.ClusterScaleWidth = 20.0;
            */

            z1.IsAutoScrollRange = true;
            z1.IsShowHScrollBar = true;
            z1.IsShowVScrollBar = true;

            XDate now = new XDate( DateTime.Now );
            ArrowObj arrow = new ArrowObj( Color.Black,
                    2.0f, (float) now.XLDate, 0.0f, (float) now.XLDate, 1.0f );
            arrow.IsArrowHead = false;
            arrow.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
            arrow.IsClippedToChartRect = true;
            myPane.GraphObjList.Add( arrow );

            // Make the first year line
            double xDate = new XDate( 2006, 1, 1 ).XLDate;
            LineObj myLine = new LineObj();
            myLine.Location.X1 = xDate;
            myLine.Location.Y1 = 0.0;
            myLine.Location.Width = 0.0;
            myLine.Location.Height = 1.0;
            myLine.IsClippedToChartRect = true;
            myLine.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
            myLine.Line.Width = 2.0f;
            myLine.Line.Color = Color.Red;
            myPane.GraphObjList.Add( myLine );

            // Repeat for each Grid by cloning
            xDate = new XDate( 2007, 1, 1 ).XLDate;
            ;
            myLine = new LineObj( myLine );
            myLine.Location.X1 = xDate;
            myPane.GraphObjList.Add( myLine );
        }
コード例 #24
0
ファイル: ChromGraphItem.cs プロジェクト: lgatto/proteowizard
        private void AddRetentionTimeAnnotation(MSGraphPane graphPane, Graphics g, GraphObjList annotations,
            PointF ptTop, string title, GraphObjType graphObjType, Color color, ScaledRetentionTime retentionTime)
        {
            string label = string.Format("{0}\n{1:F01}", title, retentionTime.DisplayTime); // Not L10N
            FontSpec fontLabel = CreateFontSpec(color, _fontSpec.Size);
            SizeF sizeLabel = fontLabel.MeasureString(g, label, graphPane.CalcScaleFactor());
            PointF realTopPoint = ptTop;
            ptTop = new PointF(0, ptTop.Y + sizeLabel.Height + 15);
            float chartHeightWithLabel = graphPane.Chart.Rect.Height + sizeLabel.Height + 15;
            double intensityChartFraction = (ptTop.Y - realTopPoint.Y) / chartHeightWithLabel;

            LineObj stick = new LineObj(color, retentionTime.DisplayTime, intensityChartFraction, retentionTime.DisplayTime, 1)
                                {
                                    IsClippedToChartRect = true,
                                    Location = { CoordinateFrame = CoordType.XScaleYChartFraction },
                                    ZOrder = ZOrder.E_BehindCurves,
                                    Line = { Width = 1 },
                                    Tag = new GraphObjTag(this, graphObjType, retentionTime),
                                };
            annotations.Add(stick);

            ptTop = new PointF(0, ptTop.Y - 5);
            intensityChartFraction = (ptTop.Y - realTopPoint.Y) / chartHeightWithLabel;
            TextObj text = new TextObj(label, retentionTime.DisplayTime, intensityChartFraction,
                                       CoordType.XScaleYChartFraction, AlignH.Center, AlignV.Bottom)
                               {
                                   IsClippedToChartRect = true,
                                   ZOrder = ZOrder.E_BehindCurves,
                                   FontSpec = CreateFontSpec(color, _fontSpec.Size),
                                   Tag = new GraphObjTag(this, graphObjType, retentionTime),
                               };
            annotations.Add(text);
        }
コード例 #25
0
ファイル: Form1.cs プロジェクト: Jungwon/ZedGraph
        private void CreateGraph_NegativeHorizontalBars( ZedGraphControl z1 )
        {
            GraphPane myPane = z1.GraphPane;

            PointPairList list = new PointPairList();
            Random rand = new Random();

            for ( int i = 0; i < 20; i++ )
            {
                list.Add( rand.NextDouble() * 200.0 - 100.0, (double) i + 1.0, 50.0 );
            }

            list.Sort( SortType.XValues );

            HiLowBarItem myBar = myPane.AddHiLowBar( "histogram", list, Color.Blue );
            myBar.Bar.Fill = new Fill( Color.Blue );
            myPane.BarSettings.MinClusterGap = 0.0f;
            myPane.YAxis.MajorGrid.IsZeroLine = false;

            myPane.BarSettings.Base = BarBase.Y;

            LineObj line = new LineObj( Color.Black, 0, 50, 1, 50 );
            line.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            myPane.GraphObjList.Add( line );

            z1.AxisChange();
        }
コード例 #26
0
ファイル: RssiAnalyserForm.cs プロジェクト: kaaLabs15/LoRa
 private void CreateThreshold()
 {
     GraphPane graphPane = graph.PaneList[0];
     double num = 0.0;
     LineObj lineObj = new LineObj(Color.Green, 0.0, num, 1.0, num);
     lineObj.Location.CoordinateFrame = CoordType.XChartFractionYScale;
     lineObj.IsVisible = true;
     graphPane.GraphObjList.Add((GraphObj)lineObj);
     graphPane.AxisChange();
     graph.Invalidate();
 }
コード例 #27
0
ファイル: ConfigTradHeli.cs プロジェクト: maxencep02/MPCD
        void GenerateGraphData()
        {
            PointPairList stab = new PointPairList();
            stab.Add(0, MainV2.comPort.MAV.param["IM_STAB_COL_1"].Value);
            stab.Add(40, MainV2.comPort.MAV.param["IM_STAB_COL_2"].Value);
            stab.Add(60, MainV2.comPort.MAV.param["IM_STAB_COL_3"].Value);
            stab.Add(100, MainV2.comPort.MAV.param["IM_STAB_COL_4"].Value);

            PointPairList acro = new PointPairList();

            double _acro_col_expo = MainV2.comPort.MAV.param["IM_ACRO_COL_EXP"].Value;

            // 100 point curve
            for (int a = 0; a <= 100; a++)
            {
                double col_in = (a-50.0)/50.0;
                double col_in3 = col_in*col_in*col_in;
                double col_out = (_acro_col_expo*col_in3) + ((1 - _acro_col_expo)*col_in);
                double acro_col_out = 500 + col_out*500;

                acro.Add(a, acro_col_out);
            }

            zedGraphControl1.GraphPane.CurveList.Clear();
            zedGraphControl1.GraphPane.GraphObjList.Clear();

            var myCurve = zedGraphControl1.GraphPane.AddCurve("Stabalize Collective", stab, Color.DodgerBlue, SymbolType.Circle);

            foreach (PointPair pp in stab)
            {
                // Add a another text item to to point out a graph feature
                TextObj text = new TextObj(pp.X.ToString(), pp.X, pp.Y);
                // rotate the text 90 degrees
                text.FontSpec.Angle = 0;
                text.FontSpec.FontColor = Color.White;
                // Align the text such that the Right-Center is at (700, 50) in user scale coordinates
                text.Location.AlignH = AlignH.Right;
                text.Location.AlignV = AlignV.Center;
                // Disable the border and background fill options for the text
                text.FontSpec.Fill.IsVisible = false;
                text.FontSpec.Border.IsVisible = false;
                zedGraphControl1.GraphPane.GraphObjList.Add(text);
            }

            zedGraphControl1.GraphPane.AddCurve("Acro Collective", acro, Color.Yellow, SymbolType.None);

            double posx = map(MainV2.comPort.MAV.cs.ch6out, MainV2.comPort.MAV.param["H_COL_MIN"].Value,
                MainV2.comPort.MAV.param["H_COL_MAX"].Value, 0, 100);

            // set current marker
            var m_cursorLine = new LineObj(Color.Black, posx, 0, posx, 1);

            m_cursorLine.Location.CoordinateFrame = CoordType.XScaleYChartFraction; // This do the trick !
            m_cursorLine.IsClippedToChartRect = true;
            m_cursorLine.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            m_cursorLine.Line.Width = 2f;
            m_cursorLine.Line.Color = Color.Red;
            m_cursorLine.ZOrder = ZOrder.E_BehindCurves;
            zedGraphControl1.GraphPane.GraphObjList.Add(m_cursorLine);

            try
            {
                //zedGraphControl1.AxisChange();
            }
            catch
            {
            }
            // Force a redraw
            zedGraphControl1.Invalidate();
        }
コード例 #28
0
ファイル: LineObj.cs プロジェクト: lgatto/proteowizard
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see cref="LineObj"/> object from which to copy</param>
		public LineObj( LineObj rhs ) : base( rhs )
		{
			_line = new LineBase( rhs._line );
		}
コード例 #29
0
ファイル: LineObj.cs プロジェクト: ctddjyds/WinFormsApp
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="LineObj"/> object from which to copy</param>
 public LineObj(LineObj rhs) : base(rhs)
 {
     _line = new LineBase(rhs._line);
 }
コード例 #30
0
ファイル: Annotation.cs プロジェクト: hap-adong/SeeMS
        private void addFragment(GraphObjList list, pwiz.MSGraph.MSPointList points, string series, int length, int charge, double mz)
        {
            ///<summary>
            /// IMPORTANT: INORDER TO ADAPT TO ORBI-ORBI DATA, I NEED TO CHANGE THE TOLERANCE TO 30PPM!
            ///</summary>
            double basePeakIntensity = 0;
            double cutoff = 0;
            foreach (var pointlist in points)
            {
                if (basePeakIntensity < pointlist.Y)
                    basePeakIntensity = pointlist.Y;
            }
            cutoff = basePeakIntensity * basePeakPercentage * 0.01;
            double tolerance = mz * 30 * Math.Pow(10.0, -6);

            //define the max of scaled list
            //double maxScaledIntensity = 0;
            //foreach (var pointlist in points.ScaledList)
            //{
            //    if (maxScaledIntensity < pointlist.Y)
            //        maxScaledIntensity = pointlist.Y;
            //}

            //test neutral loss
            string label = String.Format("{0}{1}{2}", series, length, (charge > 1 ? "+" + charge.ToString() : ""));

            Color color;
            double offset;
            switch (series)
            {
                default: color = Color.Gray; offset = 0.1; break;
                case "a": color = Color.YellowGreen; offset = 0.1; break;
                case "x": color = Color.Green; offset = 0.12; break;
                case "b": color = Color.Red; offset = 0.14; break;
                case "y": color = Color.Blue; offset = 0.16; break;
                case "c": color = Color.Orange; offset = 0.18; break;
                case "z": color = Color.OrangeRed; offset = 0.2; break;
                case "z*": color = Color.Crimson; offset = 0.4; break;
                //test neutral loss
                case "a-water": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H2O"); break;
                case "x-water": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H2O"); break;
                case "b-water": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H2O"); break;
                case "y-water": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H2O"); break;
                case "c-water": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H2O"); break;
                case "z-water": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H2O"); break;
                case "z*-water": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H2O"); break;
                //test neutral loss
                case "a-ammonium": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-NH3"); break;
                case "x-ammonium": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-NH3"); break;
                case "b-ammonium": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-NH3"); break;
                case "y-ammonium": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-NH3"); break;
                case "c-ammonium": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-NH3"); break;
                case "z-ammonium": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-NH3"); break;
                case "z*-ammonium": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-NH3"); break;

                case "a-1phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H3PO4"); break;
                case "x-1phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H3PO4"); break;
                case "b-1phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H3PO4"); break;
                case "y-1phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H3PO4"); break;
                case "c-1phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H3PO4"); break;
                case "z-1phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H3PO4"); break;
                case "z*-1phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-H3PO4"); break;

                case "a-2phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)2"); break;
                case "x-2phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)2"); break;
                case "b-2phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)2"); break;
                case "y-2phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)2"); break;
                case "c-2phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)2"); break;
                case "z-2phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)2"); break;
                case "z*-2phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)2"); break;

                case "a-3phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)3"); break;
                case "x-3phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)3"); break;
                case "b-3phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)3"); break;
                case "y-3phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)3"); break;
                case "c-3phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)3"); break;
                case "z-3phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)3"); break;
                case "z*-3phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)3"); break;

                case "a-4phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)4"); break;
                case "x-4phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)4"); break;
                case "b-4phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)4"); break;
                case "y-4phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)4"); break;
                case "c-4phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)4"); break;
                case "z-4phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)4"); break;
                case "z*-4phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)4"); break;

                case "a-5phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)5"); break;
                case "x-5phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)5"); break;
                case "b-5phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)5"); break;
                case "y-5phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)5"); break;
                case "c-5phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)5"); break;
                case "z-5phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)5"); break;
                case "z*-5phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)5"); break;

                case "a-6phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)6"); break;
                case "x-6phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)6"); break;
                case "b-6phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)6"); break;
                case "y-6phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)6"); break;
                case "c-6phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)6"); break;
                case "z-6phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)6"); break;
                case "z*-6phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)6"); break;

                case "a-7phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)7"); break;
                case "x-7phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)7"); break;
                case "b-7phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)7"); break;
                case "y-7phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)7"); break;
                case "c-7phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)7"); break;
                case "z-7phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)7"); break;
                case "z*-7phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)7"); break;

                case "a-8phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)8"); break;
                case "x-8phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)8"); break;
                case "b-8phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)8"); break;
                case "y-8phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)8"); break;
                case "c-8phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)8"); break;
                case "z-8phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)8"); break;
                case "z*-8phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)8"); break;

                case "a-9phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)9"); break;
                case "x-9phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)9"); break;
                case "b-9phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)9"); break;
                case "y-9phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)9"); break;
                case "c-9phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)9"); break;
                case "z-9phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)9"); break;
                case "z*-9phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)9"); break;

                case "a-10phos": color = Color.YellowGreen; offset = 0.1; label = String.Format("{0}{1}{2}{3}", "a", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)10"); break;
                case "x-10phos": color = Color.Green; offset = 0.12; label = String.Format("{0}{1}{2}{3}", "x", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)10"); break;
                case "b-10phos": color = Color.Red; offset = 0.14; label = String.Format("{0}{1}{2}{3}", "b", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)10"); break;
                case "y-10phos": color = Color.Blue; offset = 0.16; label = String.Format("{0}{1}{2}{3}", "y", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)10"); break;
                case "c-10phos": color = Color.Orange; offset = 0.18; label = String.Format("{0}{1}{2}{3}", "c", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)10"); break;
                case "z-10phos": color = Color.OrangeRed; offset = 0.2; label = String.Format("{0}{1}{2}{3}", "z", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)10"); break;
                case "z*-10phos": color = Color.Crimson; offset = 0.4; label = String.Format("{0}{1}{2}{3}", "z*", length, (charge > 1 ? "+" + charge.ToString() : ""), "-(H3PO4)10"); break;

            }

            int index = -1;
            if (points != null)
                index = points.ScaledLowerBound(mz - tolerance);

            ///
            #region regular ion series a/b/c/x/y/z/z* keep unchanged
            if (series == "a" || series == "b" || series == "c" || series == "x" || series == "y" || series == "z" || series == "z*")
            {

                if (index == -1 || points.ScaledList[index].X > (mz + tolerance))
                // no matching point: present a "missed" fragment annotation
                {
                    if (!showMisses)
                        return;

                    color = Color.FromArgb(115, color); // transparent to emphasize miss

                    LineObj stick = new LineObj(color, mz, offset, mz, 1);
                    stick.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                    stick.Line.Width = 2;
                    stick.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                    list.Add(stick);

                    if (showLabels)
                    {
                        TextObj text = new TextObj(label, mz, offset, CoordType.XScaleYChartFraction,
                                                    AlignH.Left, AlignV.Center);
                        text.ZOrder = ZOrder.A_InFront;
                        text.FontSpec = new FontSpec("Arial", 12, color, false, false, false);
                        text.FontSpec.Border.IsVisible = false;
                        text.FontSpec.Angle = 90;
                        //text.IsClippedToChartRect = true;
                        list.Add(text);
                    }
                }
                else
                // matching point found: present the point as the fragment
                {
                    LineObj stick = new LineObj(color, mz, points.ScaledList[index].Y, mz, 0);
                    stick.Location.CoordinateFrame = CoordType.AxisXYScale;
                    stick.Line.Width = 2;
                    list.Add(stick);

                    if (showLabels)
                    {
                        // use an existing text point annotation if possible
                        TextObj text = null;
                        foreach (GraphObj obj in list)
                        {
                            if (obj is TextObj &&
                                (obj.Location.CoordinateFrame == CoordType.AxisXYScale ||
                                  obj.Location.CoordinateFrame == CoordType.XScaleYChartFraction) &&
                                Math.Abs(obj.Location.X - mz) < tolerance)
                            {
                                text = obj as TextObj;
                                text.Text = String.Format("{0}\n{1}", label, text.Text);
                                break;
                            }
                        }

                        if (text == null)
                        {
                            text = new TextObj(label, mz, points.ScaledList[index].Y, CoordType.AxisXYScale,
                                                AlignH.Left, AlignV.Center);
                            list.Add(text);
                        }

                        text.ZOrder = ZOrder.A_InFront;
                        text.FontSpec = new FontSpec("Arial", 12, color, false, false, false);
                        text.FontSpec.Border.IsVisible = false;
                        text.FontSpec.Fill.IsVisible = false;
                        text.FontSpec.Angle = 90;
                        //SizeF size = text.LayoutArea;
                        //float width = size.Width;

                        //pwiz.MSGraph.MSGraphPane g = new pwiz.MSGraph.MSGraphPane();
                        //YAxis y = g.YAxis;
                        //double scaled2pixel = width + y.Scale.Transform(points.ScaledList[index].Y) ;
                        //double width2Scale = width / 0.75 * maxScaledIntensity*1.1;

                        //text.IsClippedToChartRect = true;
                        //if (charge > 1)
                        //{
                        //    //calculate the Y value to actual size in CharFraction
                        //    TextObj chargeLabel = new TextObj("+" + charge, mz, 1-scaled2pixel, CoordType.XScaleYChartFraction,
                        //                                        AlignH.Left, AlignV.Bottom);

                        //    chargeLabel.ZOrder = ZOrder.A_InFront;
                        //    chargeLabel.FontSpec = new FontSpec("Arial", 8, color, false, false, false);
                        //    chargeLabel.FontSpec.Border.IsVisible = false;
                        //    chargeLabel.FontSpec.Fill.IsVisible = false;
                        //    chargeLabel.FontSpec.Angle = 90;
                        //    list.Add(chargeLabel);
                        //}

                    }
                }
            }
            #endregion

            else //if neutral loss ion series
            {
                ///
                #region basepeakthresholding is false
                if (basePeakThresholding == false)
                {
                    if (index == -1 || points.ScaledList[index].X > (mz + 0.5))
                    // no matching point: present a "missed" fragment annotation
                    {
                        if (!showMisses)
                            return;

                        color = Color.FromArgb(115, color); // transparent to emphasize miss

                        LineObj stick = new LineObj(color, mz, offset, mz, 1);
                        stick.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                        stick.Line.Width = 2;
                        stick.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                        list.Add(stick);

                        if (showLabels)
                        {
                            TextObj text = new TextObj(label, mz, offset, CoordType.XScaleYChartFraction,
                                                        AlignH.Left, AlignV.Center);
                            text.ZOrder = ZOrder.A_InFront;
                            text.FontSpec = new FontSpec("Arial", 12, color, false, false, false);
                            text.FontSpec.Border.IsVisible = false;
                            text.FontSpec.Angle = 90;
                            //text.IsClippedToChartRect = true;
                            list.Add(text);
                        }
                    }

                    else
                    // matching point found: present the point as the fragment
                    {
                        LineObj stick = new LineObj(color, mz, points.ScaledList[index].Y, mz, 0);
                        stick.Location.CoordinateFrame = CoordType.AxisXYScale;
                        stick.Line.Width = 2;
                        list.Add(stick);

                        if (showLabels)
                        {
                            // use an existing text point annotation if possible
                            TextObj text = null;
                            foreach (GraphObj obj in list)
                            {
                                if (obj is TextObj &&
                                    (obj.Location.CoordinateFrame == CoordType.AxisXYScale ||
                                      obj.Location.CoordinateFrame == CoordType.XScaleYChartFraction) &&
                                    Math.Abs(obj.Location.X - mz) < 0.5)
                                {
                                    text = obj as TextObj;
                                    text.Text = String.Format("{0}\n{1}", label, text.Text);
                                    break;
                                }
                            }

                            if (text == null)
                            {
                                text = new TextObj(label, mz, points.ScaledList[index].Y, CoordType.AxisXYScale,
                                                    AlignH.Left, AlignV.Center);
                                list.Add(text);
                            }

                            text.ZOrder = ZOrder.A_InFront;
                            text.FontSpec = new FontSpec("Arial", 12, color, false, false, false);
                            text.FontSpec.Border.IsVisible = false;
                            text.FontSpec.Fill.IsVisible = false;
                            text.FontSpec.Angle = 90;
                            //text.IsClippedToChartRect = true;
                        }
                    }
                }
                #endregion

                ///
                #region basepeakthresholding is true
                else //if basepeakthresholding is true
                {
                    if (index == -1 || points.ScaledList[index].X > (mz + 0.5) || points.FullList[index].Y < cutoff)
                    // no matching point: present a "missed" fragment annotation
                    {
                        if (!showMisses)
                            return;

                        color = Color.FromArgb(115, color); // transparent to emphasize miss

                        LineObj stick = new LineObj(color, mz, offset, mz, 1);
                        stick.Location.CoordinateFrame = CoordType.XScaleYChartFraction;
                        stick.Line.Width = 2;
                        stick.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                        list.Add(stick);

                        if (showLabels)
                        {
                            TextObj text = new TextObj(label, mz, offset, CoordType.XScaleYChartFraction,
                                                        AlignH.Left, AlignV.Center);
                            text.ZOrder = ZOrder.A_InFront;
                            text.FontSpec = new FontSpec("Arial", 12, color, false, false, false);
                            text.FontSpec.Border.IsVisible = false;
                            text.FontSpec.Angle = 90;
                            //text.IsClippedToChartRect = true;
                            list.Add(text);
                        }
                    }
                    else
                    // matching point found: present the point as the fragment
                    {
                        LineObj stick = new LineObj(color, mz, points.ScaledList[index].Y, mz, 0);
                        stick.Location.CoordinateFrame = CoordType.AxisXYScale;
                        stick.Line.Width = 2;
                        list.Add(stick);

                        if (showLabels)
                        {
                            // use an existing text point annotation if possible
                            TextObj text = null;
                            foreach (GraphObj obj in list)
                            {
                                if (obj is TextObj &&
                                    (obj.Location.CoordinateFrame == CoordType.AxisXYScale ||
                                      obj.Location.CoordinateFrame == CoordType.XScaleYChartFraction) &&
                                    Math.Abs(obj.Location.X - mz) < 0.5)
                                {
                                    text = obj as TextObj;
                                    text.Text = String.Format("{0}\n{1}", label, text.Text);
                                    break;
                                }
                            }

                            if (text == null)
                            {
                                text = new TextObj(label, mz, points.ScaledList[index].Y, CoordType.AxisXYScale,
                                                    AlignH.Left, AlignV.Center);
                                list.Add(text);
                            }

                            text.ZOrder = ZOrder.A_InFront;
                            text.FontSpec = new FontSpec("Arial", 12, color, false, false, false);
                            text.FontSpec.Border.IsVisible = false;
                            text.FontSpec.Fill.IsVisible = false;
                            text.FontSpec.Angle = 90;
                            //text.IsClippedToChartRect = true;
                        }
                    }
                }
                #endregion
            }
        }
コード例 #31
0
ファイル: HtmlReporter.cs プロジェクト: arthurzaczek/OSPC
        private static void AddLine(GraphPane g, double val, Color color, string label = null)
        {
            var line = new LineObj(0, val, 1, val);
            line.IsClippedToChartRect = true;
            line.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            line.Line.Color = color;
            line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash;
            g.GraphObjList.Add(line);

            if (!string.IsNullOrWhiteSpace(label))
            {
                var text = new TextObj(label, 0.01, val);
                text.IsClippedToChartRect = true;
                text.Location.CoordinateFrame = CoordType.XChartFractionYScale;
                text.Location.AlignH = AlignH.Left;
                text.Location.AlignV = AlignV.Bottom;
                text.FontSpec.FontColor = color;
                text.FontSpec.Fill.IsVisible = false;
                text.FontSpec.Size = 18.0f;
                text.FontSpec.Border.IsVisible = false;
                g.GraphObjList.Add(text);
            }
        }
コード例 #32
0
ファイル: Annotation.cs プロジェクト: hap-adong/SeeMS
        ///<summary>Adds user requested ion series to the fragmentation summary.</summary>
        private void addFragmentationSummary(GraphObjList list, pwiz.MSGraph.MSPointList points, Peptide peptide, Fragmentation fragmentation, string topSeries, string bottomSeries)
        {
            ///cutoff definition for neutral loss
            double basePeakIntensity = 0;
            double cutoff = 0;
            foreach (var pointlist in points)
            {
                if (basePeakIntensity < pointlist.Y)
                    basePeakIntensity = pointlist.Y;
            }
            cutoff = basePeakIntensity * basePeakPercentage * 0.01;
            ///

            int ionSeriesChargeState = min;
            string sequence = peptide.sequence;
            int sequenceLength = peptide.sequence.Length;
            ModificationMap modifications = peptide.modifications();

            // Select the color for the ion series.
            Color topSeriesColor;
            Color bottomSeriesColor;
            switch (topSeries)
            {
                default: topSeriesColor = Color.Gray; break;
                case "a": topSeriesColor = Color.YellowGreen; break;
                case "b": topSeriesColor = Color.Red; break;
                case "c": topSeriesColor = Color.Orange; break;
            }

            switch (bottomSeries)
            {
                default: bottomSeriesColor = Color.Gray; break;
                case "x": bottomSeriesColor = Color.Green; break;
                case "y": bottomSeriesColor = Color.Blue; break;
                case "z": bottomSeriesColor = Color.OrangeRed; break;
                case "z*": bottomSeriesColor = Color.Crimson; break;
            }
            // Ion series offsets. These offsets control where on the chart a particular ion series
            // get displayed
            //change the seriesTopLeftOffset value to 0.1 to make the label higher in the image.
            //original is 0.031
            double seriesTopLeftOffset = 0.05;
            // Set the constants for starting the label paint
            double topSeriesLeftPoint = 0.025;
            //test and looks reasonalbe
            double residueWidth = 0.031;
            //double residueWidth = 0.25 / ((double)sequence.Length);

            // Process all the series except c and x

            //small block modified
            //here is a big bug: if go like orignal code, then the y ions is just the like the order of b ions, which are not right.
            //My modification is to seperate a/b/c and x/y/z ions, and then it will solve this problem.
            //it seems works well.

            ///
            #region Process a/b ions
            //first we are going to touch only a/b ions
            ///
            for (int i = 1; i <= sequence.Length; ++i)
            {
                double tickStart = residueWidth * 4 / 5.0;
                double topSeriesFragmentMZ = 0.0;

                //test neutral loss
                //this block is to give clear clue for phospate loss
                //exact number of phosphated amino acids are counted.
                string Nseq = peptide.sequence.Substring(0, i);
                char[] Nseqchars = Nseq.ToCharArray();
                int Nphosmodi = 0;
                for (int k = 0; k < i; k++)
                {
                    if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (Nseqchars[k] == 'S' || Nseqchars[k] == 'T' || Nseqchars[k] == 'Y'))
                    {
                        Nphosmodi++;
                    }
                }

                //correct the bug:
                //when multiple charges allowed for fragmentation, then there is no tick thing showing the existance of the fragment
                //what I did is: make top/bottomSeriesHasMatch true if there is fragment of any charges matched.
                //bug fixed
                bool topSeriesHasMatch = false;
                for (int z = min; z <= max; z++)
                {
                    switch (topSeries)
                    {
                        case "a": topSeriesFragmentMZ = fragmentation.a(i, z); break;
                        case "b": topSeriesFragmentMZ = fragmentation.b(i, z); break;
                        default: topSeriesFragmentMZ = 0.0; break;
                    }

                    // Check if the top and bottom fragments have evidence
                    if (points != null)
                    {
                        // Search index
                        int index = -1;
                        // Find the left mz value using a mass tolerance of 0.5 da.
                        index = points.FullLowerBound(topSeriesFragmentMZ - 0.5);
                        if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ + 0.5))
                        {
                            topSeriesHasMatch = true;
                            break;
                        }
                    }

                    //test neutral loss
                    #region water loss a/b top series
                    if (waterLoss == true)
                    {
                        if (Nseq.Contains("S") || Nseq.Contains("T") || Nseq.Contains("E") || Nseq.Contains("D"))
                        {
                            // Check if the top and bottom fragments have evidence
                            if (points != null)
                            {
                                // Search index
                                int index = -1;
                                // Find the left mz value using a mass tolerance of 0.5 da.
                                index = points.FullLowerBound(topSeriesFragmentMZ - WATERMONOMASS/z - 0.5);
                                if (basePeakThresholding == false)
                                {
                                    if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - WATERMONOMASS / z + 0.5))
                                    {
                                        topSeriesHasMatch = true;
                                        break;
                                    }
                                }
                                else
                                {
                                    if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - WATERMONOMASS / z + 0.5) && points.FullList[index].Y >= cutoff)
                                    {
                                        topSeriesHasMatch = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    #endregion

                    //test neutral loss
                    #region ammonium loss a/b top series
                    if (ammoniumLoss == true)
                    {
                        if (Nseq.Contains("R") || Nseq.Contains("K") || Nseq.Contains("Q") || Nseq.Contains("N"))
                        {
                            if (points != null)
                            {
                                // Search index
                                int index = -1;
                                // Find the left mz value using a mass tolerance of 0.5 da.
                                index = points.FullLowerBound(topSeriesFragmentMZ - AMMONIUMMONOMASS / z - 0.5);
                                if (basePeakThresholding == false)
                                {
                                    if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - AMMONIUMMONOMASS / z + 0.5))
                                    {
                                        topSeriesHasMatch = true;
                                        break;
                                    }
                                }
                                else
                                {
                                    if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - AMMONIUMMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                    {
                                        topSeriesHasMatch = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    #endregion

                    //test neutral loss
                    #region phosphate loss a/b top series
                    if (phosphateLoss == true)
                    {
                        //need to judge qualified number of AAs;
                        int minPhosphate = Math.Min(Nphosmodi, numPhosphate);

                        if (minPhosphate > 0)
                        {
                            for (int k = 1; k <= minPhosphate; k++)
                            {
                                //first need to judge if there are as many as phos AAs
                                //then if AA <= phos, then deal with AA;
                                //if AA > phos, then deal with phos.
                                if (points != null)
                                {
                                    // Search index
                                    int index = -1;
                                    // Find the left mz value using a mass tolerance of 0.5 da.
                                    index = points.FullLowerBound(topSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z - 0.5);
                                    if (basePeakThresholding == false)
                                    {
                                        if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z + 0.5))
                                        {
                                            topSeriesHasMatch = true;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                        {
                                            topSeriesHasMatch = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                    }
                    #endregion
                }

                // Build the label for the amino acid
                // Add a text box in the middle of the left and right mz boundaries
                StringBuilder label = new StringBuilder(sequence[i - 1].ToString());
                // Figure out if any mods are there on this amino acid
                double deltaMass = modifications[i - 1].monoisotopicDeltaMass();
                string deltaMassString = deltaMass.ToString();

                TextObj text = new TextObj(label.ToString(), topSeriesLeftPoint,
                       seriesTopLeftOffset, CoordType.ChartFraction, AlignH.Left, AlignV.Center);
                text.ZOrder = ZOrder.E_BehindCurves;
                text.FontSpec = new FontSpec("Arial", 13, Color.Black, true, false, false);
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible = false;
                text.IsClippedToChartRect = true;
                list.Add(text);

                SizeF size = text.LayoutArea;
                float width = size.Width;

                if (deltaMass > 0.0)
                {
                    deltaMassString = "+" + Math.Round(deltaMass).ToString();
                    TextObj textModi = new TextObj(deltaMassString, topSeriesLeftPoint + 0.011,
                       seriesTopLeftOffset, CoordType.ChartFraction, AlignH.Left, AlignV.Center);

                    textModi.ZOrder = ZOrder.A_InFront;
                    textModi.FontSpec = new FontSpec("Arial", 8, Color.Black, true, false, false);
                    textModi.FontSpec.Border.IsVisible = false;
                    textModi.FontSpec.Fill.IsVisible = false ;
                    textModi.IsClippedToChartRect = true;
                    list.Add(textModi);

                }
                else if (deltaMass < 0.0)
                {
                    deltaMassString = Math.Round(deltaMass).ToString();
                    TextObj textModi = new TextObj(deltaMassString, topSeriesLeftPoint + 0.01,
                       seriesTopLeftOffset, CoordType.ChartFraction, AlignH.Left, AlignV.Center);

                    textModi.ZOrder = ZOrder.B_BehindLegend;
                    textModi.FontSpec = new FontSpec("Arial", 8, Color.Black, true, false, false);
                    textModi.FontSpec.Border.IsVisible = false;
                    textModi.FontSpec.Fill.IsVisible = false ;
                    textModi.IsClippedToChartRect = true;
                    list.Add(textModi);
                }

                if (topSeriesHasMatch)
                {
                    // Paint the tick in the middle
                    LineObj tick = new LineObj(topSeriesColor, topSeriesLeftPoint + tickStart, (seriesTopLeftOffset - 0.03), topSeriesLeftPoint + tickStart, seriesTopLeftOffset);
                    tick.Location.CoordinateFrame = CoordType.ChartFraction;
                    tick.Line.Width = 2;
                    tick.IsClippedToChartRect = true;
                    list.Add(tick);
                    // Paint the hook
                    LineObj hook = new LineObj(topSeriesColor, topSeriesLeftPoint, (seriesTopLeftOffset - 0.05), topSeriesLeftPoint + tickStart, seriesTopLeftOffset - 0.03);
                    hook.Location.CoordinateFrame = CoordType.ChartFraction;
                    hook.Line.Width = 2;
                    hook.IsClippedToChartRect = true;
                    list.Add(hook);
                }
                // Update the next paint point
                topSeriesLeftPoint += residueWidth;
            }

            // Reset the series starting point
            topSeriesLeftPoint = 0.025;
            #endregion

            ///
            #region Process y/z ions
            //then for y/z ions:
            //note: since the fragmentsummary starts the ticking/lining from left to right,
            //so we need to adjust the starting point of bottoms series from the highest to lowest.
            ///
            for (int i = sequence.Length; i >= 1; --i)
            {
                double tickStart = residueWidth / 5.0;
                double bottomSeriesFragmentMZ = 0.0;
                bool bottomSeriesHasMatch = false;
                //test neutral
                string Cseq = peptide.sequence.Substring(sequenceLength - i, i);
                char[] seqchars = peptide.sequence.ToCharArray();
                int Cphosmodi = 0;
                for (int k = sequenceLength - i; k < sequenceLength; k++)
                {
                    if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (seqchars[k] == 'S' || seqchars[k] == 'T' || seqchars[k] == 'Y'))
                    {
                        Cphosmodi++;
                    }
                }

                for (int z = min; z <= max; z++)
                {
                    switch (bottomSeries)
                    {
                        case "y": bottomSeriesFragmentMZ = fragmentation.y(i, z); break;
                        case "z": bottomSeriesFragmentMZ = fragmentation.z(i, z); break;
                        case "z*": bottomSeriesFragmentMZ = fragmentation.zRadical(i, z); break;
                        default: bottomSeriesFragmentMZ = 0.0; break;
                    }

                    // Check if the top and bottom fragments have evidence

                    if (points != null)
                    {
                        // Search index
                        int index = -1;
                        // Find the left mz value using a mass tolerance of 0.5 da.
                        index = points.FullLowerBound(bottomSeriesFragmentMZ - 0.5);
                        if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ + 0.5))
                        {
                            bottomSeriesHasMatch = true;
                            break;
                        }
                    }

                    //test neutral loss
                    #region water loss y/z bottom series
                    if (waterLoss == true)
                    {
                        if (Cseq.Contains("S") || Cseq.Contains("T") || Cseq.Contains("E") || Cseq.Contains("D"))
                        {
                            if (points != null)
                            {
                                // Search index
                                int index = -1;
                                // Find the left mz value using a mass tolerance of 0.5 da.
                                index = points.FullLowerBound(bottomSeriesFragmentMZ - WATERMONOMASS / z - 0.5);
                                if (basePeakThresholding == false)
                                {
                                    if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - WATERMONOMASS / z + 0.5))
                                    {
                                        bottomSeriesHasMatch = true;
                                        break;
                                    }
                                }
                                else
                                {
                                    if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - WATERMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                    {
                                        bottomSeriesHasMatch = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    #endregion

                    //test neutral loss
                    #region ammonium loss y/z bottom series
                    if (ammoniumLoss == true)
                    {
                        if (Cseq.Contains("R") || Cseq.Contains("K") || Cseq.Contains("Q") || Cseq.Contains("N"))
                        if (points != null)
                        {
                            // Search index
                            int index = -1;
                            // Find the left mz value using a mass tolerance of 0.5 da.
                            index = points.FullLowerBound(bottomSeriesFragmentMZ - AMMONIUMMONOMASS / z - 0.5);
                            if (basePeakThresholding == false)
                            {
                                if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - AMMONIUMMONOMASS / z + 0.5))
                                {
                                    bottomSeriesHasMatch = true;
                                    break;
                                }
                            }
                            else
                            {
                                if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - AMMONIUMMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                {
                                    bottomSeriesHasMatch = true;
                                    break;
                                }
                            }
                        }
                    }
                    #endregion

                    //test neutral loss
                    #region phosphate loss y/z bottom series
                    if (phosphateLoss == true)
                    {
                        int minPhosphate = Math.Min(Cphosmodi, numPhosphate);
                        if (minPhosphate > 0)
                        {
                            for (int k = 1; k <= minPhosphate; k++)
                            {
                                if (points != null)
                                {
                                    // Search index
                                    int index = -1;
                                    // Find the left mz value using a mass tolerance of 0.5 da.
                                    index = points.FullLowerBound(bottomSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z - 0.5);
                                    if (basePeakThresholding == false)
                                    {
                                        if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z + 0.5))
                                        {
                                            bottomSeriesHasMatch = true;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                        {
                                            bottomSeriesHasMatch = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    #endregion
                }

                if (bottomSeriesHasMatch)
                {
                    // Paint the tick in the middle
                    LineObj tick = new LineObj(bottomSeriesColor, topSeriesLeftPoint - tickStart, seriesTopLeftOffset, topSeriesLeftPoint - tickStart, seriesTopLeftOffset + 0.03);
                    tick.Location.CoordinateFrame = CoordType.ChartFraction;
                    tick.Line.Width = 2;
                    tick.IsClippedToChartRect = true;
                    list.Add(tick);
                    // Paint the hook
                    LineObj hook = new LineObj(bottomSeriesColor, topSeriesLeftPoint - tickStart, seriesTopLeftOffset + 0.03, topSeriesLeftPoint + 2.0 * tickStart, seriesTopLeftOffset + 0.05);
                    hook.Location.CoordinateFrame = CoordType.ChartFraction;
                    hook.Line.Width = 2;
                    hook.IsClippedToChartRect = true;
                    list.Add(hook);
                }
                // Update the next paint point
                topSeriesLeftPoint += residueWidth;
            }

            // Reset the series starting point
            topSeriesLeftPoint = 0.025;
            #endregion

            ///
            #region Process x/c series
            ///
            //the reason that I didn't split c/x as ab/yz, is that c/x doesn't have to deal with the termini. so good to go.
            //disable the function of neutral losses
            for (int i = 1; i < sequence.Length; ++i)
            {
                double tickStart = residueWidth *4 / 5.0;
                double topSeriesFragmentMZ = 0.0;
                double bottomSeriesFragmentMZ = 0.0;
                // Check if the top and bottom fragments have evidence
                bool topSeriesHasMatch = false;
                bool bottomSeriesHasMatch = false;

                ///
                //test neutral loss
                //test neutral
                //adjust the "i" accordingly, must let the C ions be left=>right.
                //if it goes from left to right, then N series is i;
                //C series is more tricky. Get a NTempSeq from 0 to sequenceLength-i; then get C from total.
                ///
                string Nseq = peptide.sequence.Substring(0, i);
                string NTempSeq = peptide.sequence.Substring(0, sequenceLength - i);
                string Cseq = peptide.sequence.Substring(i, sequenceLength-i);
                char[] Nseqchars = Nseq.ToCharArray();
                char[] seqchars = peptide.sequence.ToCharArray();
                char[] NTempSeqChars = NTempSeq.ToCharArray();
                int Nphosmodi = 0;
                int NTempPhosmodi = 0;
                int Cphosmodi = 0;
                int phosmodi = 0;
                for (int k = 0; k < i; k++)
                {
                    if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (Nseqchars[k] == 'S' || Nseqchars[k] == 'T' || Nseqchars[k] == 'Y'))
                    {
                        Nphosmodi++;
                    }
                }

                for (int k = 0; k < sequenceLength - i; k++)
                {
                    if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (NTempSeqChars[k] == 'S' || NTempSeqChars[k] == 'T' || NTempSeqChars[k] == 'Y'))
                    {
                        NTempPhosmodi++;
                    }
                }
                for (int k = 0; k < sequenceLength; k++)
                {
                    if (Math.Round(modifications[k].monoisotopicDeltaMass()) == 80 && (seqchars[k] == 'S' || seqchars[k] == 'T' || seqchars[k] == 'Y'))
                    {
                        phosmodi++;
                    }
                }
                Cphosmodi = phosmodi - NTempPhosmodi;

                for (int z = min; z <= max; z++)
                {
                    switch (topSeries)
                    {
                        case "c": topSeriesFragmentMZ = fragmentation.c(i, z); break;
                        default: topSeriesFragmentMZ = 0.0; break;
                    }
                    switch (bottomSeries)
                    {
                        case "x": bottomSeriesFragmentMZ = fragmentation.x(sequence.Length - i, z); break;
                        default: bottomSeriesFragmentMZ = 0.0; break;
                    }

                    if (points != null)
                    {
                        // Search index
                        int index = -1;
                        // Find the left mz value using a mass tolerance of 0.5 da.
                        index = points.FullLowerBound(topSeriesFragmentMZ - 0.5);
                        if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ + 0.5))
                            topSeriesHasMatch = true;

                        // Reset the search index
                        index = -1;
                        // Find the left mz value using a mass tolerance of 0.5 da.
                        index = points.FullLowerBound(bottomSeriesFragmentMZ - 0.5);
                        if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ + 0.5))
                            bottomSeriesHasMatch = true;
                    }

                    //disable neutral losses for c/x series
                    //test neutral loss
                    #region water loss c/x
                    if (waterLoss == true)
                    {
                        if (Nseq.Contains("S") || Nseq.Contains("T") || Nseq.Contains("E") || Nseq.Contains("D"))
                        {
                            if (points != null)
                            {
                                // Search index
                                int index = -1;
                                // Find the left mz value using a mass tolerance of 0.5 da.
                                index = points.FullLowerBound(topSeriesFragmentMZ - WATERMONOMASS / z - 0.5);
                                if (basePeakThresholding == false)
                                {
                                    if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - WATERMONOMASS / z + 0.5))
                                        topSeriesHasMatch = true;
                                }
                                else
                                {
                                    if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - WATERMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                        topSeriesHasMatch = true;
                                }
                            }
                        }
                        if (Cseq.Contains("S") || Cseq.Contains("T") || Cseq.Contains("E") || Cseq.Contains("D"))
                        {
                            if (points != null)
                            {
                                // Search index
                                int index = -1;
                                // Find the left mz value using a mass tolerance of 0.5 da.
                                index = points.FullLowerBound(bottomSeriesFragmentMZ - WATERMONOMASS / z - 0.5);
                                if (basePeakThresholding == false)
                                {
                                    if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - WATERMONOMASS / z + 0.5))
                                        bottomSeriesHasMatch = true;
                                }
                                else
                                {
                                    if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - WATERMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                        bottomSeriesHasMatch = true;
                                }
                            }
                        }
                    }
                    #endregion

                    ////test neutral loss
                    #region ammonium loss c/x
                    if (ammoniumLoss == true)
                    {
                        if (points != null)
                        {
                            if (Nseq.Contains("R") || Nseq.Contains("K") || Nseq.Contains("Q") || Nseq.Contains("N"))
                            {
                                // Search index
                                int index = -1;
                                // Find the left mz value using a mass tolerance of 0.5 da.
                                index = points.FullLowerBound(topSeriesFragmentMZ - AMMONIUMMONOMASS / z - 0.5);
                                if (basePeakThresholding == false)
                                {
                                    if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - AMMONIUMMONOMASS / z + 0.5))
                                        topSeriesHasMatch = true;
                                }
                                else
                                {
                                    if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - AMMONIUMMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                        topSeriesHasMatch = true;
                                }

                            }

                            if (Cseq.Contains("R") || Cseq.Contains("K") || Cseq.Contains("Q") || Cseq.Contains("N"))
                            {
                                // Reset the search index
                                int index = -1;
                                // Find the left mz value using a mass tolerance of 0.5 da.
                                index = points.FullLowerBound(bottomSeriesFragmentMZ - AMMONIUMMONOMASS / z - 0.5);
                                if (basePeakThresholding == false)
                                {
                                    if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - AMMONIUMMONOMASS / z + 0.5))
                                        bottomSeriesHasMatch = true;
                                }
                                else
                                {
                                    if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - AMMONIUMMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                        bottomSeriesHasMatch = true;
                                }

                            }
                        }
                    }
                    #endregion

                    ////test neutral loss
                    #region phosphate loss c/x
                    if (phosphateLoss == true)
                    {
                        int minPhosphate = Math.Min(Nphosmodi, numPhosphate);
                        if (minPhosphate > 0)
                        {
                            for (int k = 1; k <= minPhosphate; k++)
                            {
                                if (points != null)
                                {
                                    // Search index
                                    int index = -1;
                                    // Find the left mz value using a mass tolerance of 0.5 da.
                                    index = points.FullLowerBound(topSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z - 0.5);
                                    if (basePeakThresholding == false)
                                    {
                                        if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z + 0.5))
                                        {
                                            topSeriesHasMatch = true;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        if (index != -1 && points.FullList[index].X <= (topSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                        {
                                            topSeriesHasMatch = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }

                        minPhosphate = Math.Min(Cphosmodi, numPhosphate);
                        {
                            if (minPhosphate > 0)
                            {
                                for (int k = 1; k <= minPhosphate; k++)
                                {
                                    if (points != null)
                                    {
                                        // Search index
                                        int index = -1;
                                        // Find the left mz value using a mass tolerance of 0.5 da.
                                        index = points.FullLowerBound(bottomSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z - 0.5);
                                        if (basePeakThresholding == false)
                                        {
                                            if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z + 0.5))
                                            {
                                                bottomSeriesHasMatch = true;
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            if (index != -1 && points.FullList[index].X <= (bottomSeriesFragmentMZ - k * PHOSPHATEMONOMASS / z + 0.5) && points.FullList[index].Y > cutoff)
                                            {
                                                bottomSeriesHasMatch = true;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }

                        }
                    }
                    #endregion

                }

                // Build the label for the amino acid
                // Add a text box in the middle of the left and right mz boundaries
                StringBuilder label = new StringBuilder(sequence[i - 1].ToString());
                // Figure out if any mods are there on this amino acid
                double deltaMass = modifications[i - 1].monoisotopicDeltaMass();
                string deltaMassString = deltaMass.ToString();
                // Round the mod mass and append it to the amino acid as a string
                //if (deltaMass > 0.0)
                //{
                //    label.Append("+" + Math.Round(deltaMass));
                //}
                //else if (deltaMass < 0.0)
                //{
                //    label.Append(Math.Round(deltaMass));
                //}
                TextObj text = new TextObj(label.ToString(), topSeriesLeftPoint,
                            seriesTopLeftOffset, CoordType.ChartFraction, AlignH.Left, AlignV.Center);
                text.ZOrder = ZOrder.B_BehindLegend;
                text.FontSpec = new FontSpec("Arial", 13, Color.Black, true, false, false);
                text.FontSpec.Border.IsVisible = false;
                text.FontSpec.Fill.IsVisible = false;
                text.IsClippedToChartRect = true;
                list.Add(text);

                SizeF size = text.LayoutArea;
                float width = size.Width;

                if (deltaMass > 0.0)
                {
                    deltaMassString = "+" + Math.Round(deltaMass).ToString();
                    TextObj textModi = new TextObj(deltaMassString, topSeriesLeftPoint + 0.01,
                       seriesTopLeftOffset, CoordType.ChartFraction, AlignH.Left, AlignV.Center);

                    textModi.ZOrder = ZOrder.B_BehindLegend;
                    textModi.FontSpec = new FontSpec("Arial", 8, Color.Black, true, false, false);
                    textModi.FontSpec.Border.IsVisible = false;
                    textModi.FontSpec.Fill.IsVisible = false;
                    textModi.IsClippedToChartRect = true;
                    list.Add(textModi);

                }
                else if (deltaMass < 0.0)
                {
                    deltaMassString = Math.Round(deltaMass).ToString();
                    TextObj textModi = new TextObj(deltaMassString, topSeriesLeftPoint + 0.01,
                       seriesTopLeftOffset, CoordType.ChartFraction, AlignH.Left, AlignV.Center);

                    textModi.ZOrder = ZOrder.B_BehindLegend;
                    textModi.FontSpec = new FontSpec("Arial", 8, Color.Black, true, false, false);
                    textModi.FontSpec.Border.IsVisible = false;
                    textModi.FontSpec.Fill.IsVisible = false;
                    textModi.IsClippedToChartRect = true;
                    list.Add(textModi);
                }

                if (topSeriesHasMatch)
                {
                    // Paint the tick in the middle
                    LineObj tick = new LineObj(topSeriesColor, topSeriesLeftPoint + tickStart, (seriesTopLeftOffset - 0.03), topSeriesLeftPoint + tickStart, seriesTopLeftOffset);
                    tick.Location.CoordinateFrame = CoordType.ChartFraction;
                    tick.Line.Width = 2;
                    tick.IsClippedToChartRect = true;
                    list.Add(tick);
                    // Paint the hook
                    LineObj hook = new LineObj(topSeriesColor, topSeriesLeftPoint, (seriesTopLeftOffset - 0.05), topSeriesLeftPoint + tickStart, seriesTopLeftOffset - 0.03);
                    hook.Location.CoordinateFrame = CoordType.ChartFraction;
                    hook.Line.Width = 2;
                    hook.IsClippedToChartRect = true;
                    list.Add(hook);
                }
                if (bottomSeriesHasMatch)
                {
                    // Paint the tick in the middle
                    LineObj tick = new LineObj(bottomSeriesColor, topSeriesLeftPoint + tickStart, seriesTopLeftOffset, topSeriesLeftPoint + tickStart, seriesTopLeftOffset + 0.03);
                    tick.Location.CoordinateFrame = CoordType.ChartFraction;
                    tick.Line.Width = 2;
                    tick.IsClippedToChartRect = true;
                    list.Add(tick);
                    // Paint the hook
                    LineObj hook = new LineObj(bottomSeriesColor, topSeriesLeftPoint + tickStart, seriesTopLeftOffset + 0.03, topSeriesLeftPoint + 2.0 * tickStart, seriesTopLeftOffset + 0.05);
                    hook.Location.CoordinateFrame = CoordType.ChartFraction;
                    hook.Line.Width = 2;
                    hook.IsClippedToChartRect = true;
                    list.Add(hook);
                }
                // Update the next paint point
                topSeriesLeftPoint += residueWidth;
            }
            #endregion
        }