/// <summary> /// add precursor and non-matched annotations /// </summary> public override void AddAnnotations(pwiz.MSGraph.MSGraphPane graphPane, Graphics g, pwiz.MSGraph.MSPointList pointList, ZedGraph.GraphObjList annotations) { base.AddAnnotations(graphPane, g, pointList, annotations); //using( Spectrum element = Element ) { foreach (Precursor p in Element.precursors) { foreach (SelectedIon si in p.selectedIons) { double precursorMz = (double)si.cvParam(CVID.MS_selected_ion_m_z).value; int precursorCharge = 0; CVParam precursorChargeParam = si.cvParam(CVID.MS_charge_state); if (precursorChargeParam.empty()) { precursorChargeParam = si.cvParam(CVID.MS_possible_charge_state); } if (!precursorChargeParam.empty()) { precursorCharge = (int)precursorChargeParam.value; } double stickLength = 0.1; ZedGraph.LineObj stickOverlay = new ZedGraph.LineObj(precursorMz, 1, precursorMz, stickLength); stickOverlay.Location.CoordinateFrame = ZedGraph.CoordType.XScaleYChartFraction; stickOverlay.Line.Width = 3; stickOverlay.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot; stickOverlay.Line.Color = Color.Green; annotations.Add(stickOverlay); // Create a text label from the X data value string precursorLabel; if (precursorCharge > 0) { precursorLabel = String.Format("{0}\n(+{1} precursor)", precursorMz.ToString("f3"), precursorCharge); } else { precursorLabel = String.Format("{0}\n(precursor of unknown charge)", precursorMz.ToString("f3")); } ZedGraph.TextObj text = new ZedGraph.TextObj(precursorLabel, precursorMz, stickLength, ZedGraph.CoordType.XScaleYChartFraction, ZedGraph.AlignH.Center, ZedGraph.AlignV.Bottom); text.ZOrder = ZedGraph.ZOrder.A_InFront; text.FontSpec.FontColor = stickOverlay.Line.Color; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; //text.FontSpec.Fill = new Fill( Color.FromArgb( 100, Color.White ) ); text.FontSpec.Angle = 0; annotations.Add(text); } } } }
private static void AddlabelToBars(ZedGraph.GraphPane myPn, double[] X, double[] Y) { for (int i = 0; i < Y.Length; i++) { ZedGraph.TextObj item = new ZedGraph.TextObj(Y[i].ToString("F1"), (double)((float)X[i]), (double)(((Y[i] < 0.0) ? ((float)0.0) : ((float)Y[i])) + 1f)); item.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale; item.Location.AlignH = ZedGraph.AlignH.Left; item.Location.AlignV = ZedGraph.AlignV.Center; item.FontSpec.Border.IsVisible = false; item.FontSpec.Fill.IsVisible = false; item.FontSpec.Angle = 90f; myPn.GraphObjList.Add(item); } }
private bool zedSequence_MouseDownEvent(ZedGraph.ZedGraphControl sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { double outX, outY; zedSequence.GraphPane.ReverseTransform(new Point(e.X, e.Y), out outX, out outY); MassStartValue = new ZedGraph.TextObj(outX.ToString("0.00"), outX, outY); MassStartValue.FontSpec.Border.IsVisible = false; MassStartValue.FontSpec.Size = MassStartValue.FontSpec.Size * 0.7f; zedSequence.GraphPane.GraphObjList.Insert(0, MassStartValue); zedSequence.Refresh(); } return(default(bool)); }
/// <summary> /// used internally to draw the max and min label values for the gauge region /// </summary> /// <param name="pane"></param> /// <param name="fAngle"></param> /// <param name="objLabel"></param> /// <param name="dValue"></param> private void DrawLabelValue(GraphPane pane, float fAngle, ref TextObj objLabel, double dValue) { RectangleF tRect = _boundingRectangle; double xmiddle = tRect.Width / 2.0; double ymiddle = tRect.Height / 2.0; double cos = Math.Cos((Math.PI / (180)) * fAngle); double sin = Math.Sin((Math.PI / (180)) * fAngle); if (!pane.Clockwise) { cos = -cos; } if (objLabel == null) { objLabel = new ZedGraph.TextObj(); objLabel.Location.CoordinateFrame = ZedGraph.CoordType.PaneFraction; objLabel.FontSpec.Size = 10; objLabel.ZOrder = ZedGraph.ZOrder.A_InFront; objLabel.FontSpec.Border.IsVisible = false; objLabel.FontSpec.Fill.IsVisible = false; objLabel.Location.AlignH = AlignH.Center; objLabel.Location.AlignV = AlignV.Center; pane.GraphObjList.Add(objLabel); } objLabel.IsVisible = true; objLabel.Location.X = (tRect.X + xmiddle + (xmiddle * cos * 1.15)) / pane.Rect.Width; objLabel.Location.Y = (tRect.Y + ymiddle - (ymiddle * sin * 1.15)) / pane.Rect.Height; //Console.WriteLine("Angle:" + fAngle + " Sin/Cos:" + sin.ToString("f1") + "/" + cos.ToString("f1") + " X,Y:" + m_LabelMin.Location.X.ToString("f3") + "," + m_LabelMin.Location.Y.ToString("f3")); objLabel.Text = dValue.ToString("f0"); if (m_bRotateLabels) { objLabel.FontSpec.Angle = (float)(180 - fAngle); if (objLabel.FontSpec.Angle > 90) { objLabel.FontSpec.Angle += 180; } } }
private void zedSequence_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (zedSequence.GraphPane.GraphObjList.Count != 0) { zedSequence.GraphPane.GraphObjList.Remove(MassEndValue); zedSequence.GraphPane.GraphObjList.Remove(MassDiffValue); zedSequence.GraphPane.GraphObjList.Remove(MassLine); zedSequence.Refresh(); } double outX, outY; zedSequence.GraphPane.ReverseTransform(new Point(e.X, e.Y), out outX, out outY); outY = MassStartValue.Location.Y; //Add Line MassLine = new ZedGraph.LineObj(MassStartValue.Location.X, MassStartValue.Location.Y, outX, MassStartValue.Location.Y); MassLine.Line.Style = DashStyle.Dash; MassLine.Line.Color = Color.Blue; zedSequence.GraphPane.GraphObjList.Insert(1, MassLine); MassEndValue = new ZedGraph.TextObj(outX.ToString("0.00"), outX, outY); MassEndValue.FontSpec.Border.IsVisible = false; MassEndValue.FontSpec.Size = MassEndValue.FontSpec.Size * 0.5f; zedSequence.GraphPane.GraphObjList.Insert(0, MassEndValue); double massdiff = Convert.ToDouble(MassEndValue.Text) - Convert.ToDouble(MassStartValue.Text); double diffLoc = (MassStartValue.Location.X + MassEndValue.Location.X) / 2; MassDiffValue = new ZedGraph.TextObj(Math.Abs(massdiff).ToString("0.00"), diffLoc, outY); MassDiffValue.FontSpec.Border.IsVisible = false; MassDiffValue.FontSpec.Size = MassDiffValue.FontSpec.Size * 0.8f; zedSequence.GraphPane.GraphObjList.Insert(0, MassDiffValue); zedSequence.Refresh(); } }
private void btnDaySummary_Click(object sender, EventArgs e) { Random rnd = new Random(); DataTable t = GetDateTbl(); if (t != null) { if (frmPie != null && !frmPie.IsDisposed) { frmPie.Dispose(); } frmPie = new frmChart(); ZedGraph.GraphPane Pane = frmPie.zedGraph.GraphPane; //Titulos frmPie.Text = lblTimeSpent.Text + ": " + lblDay.Text + " " + dTP.Value.Date.ToString().Split()[0]; Pane.Title.Text = frmPie.Text; Pane.Title.FontSpec.Size = 24f; //Pane.Title.FontSpec.IsItalic = true; Pane.Fill = new ZedGraph.Fill(Color.White, Color.LightYellow, 45f); Pane.Chart.Fill.Type = ZedGraph.FillType.None; //fonte da legenda Pane.Legend.FontSpec.Size = 11f; //Slices int tempoTot = 0; foreach (DataRow r in t.Rows) { int tempo = (int)r["colElapTimeInSeconds"]; tempoTot += tempo; Color cor = Color.FromArgb(rnd.Next(240), rnd.Next(240), rnd.Next(240)); ZedGraph.PieItem p = Pane.AddPieSlice(Math.Round((double)tempo / 3600, 2), cor, Color.White, 45f, 0.1, r["colTask"].ToString()); //Menu pie slices removal feature ToolStripMenuItem m = new ToolStripMenuItem(r["colTask"].ToString()); m.Checked = true; frmPie.itemsMenu.DropDownItems.Add(m); m.Click += new EventHandler(m_Click); frmPie.vals.Add((double)tempo / 3600); } //Sets menu text frmPie.itemsMenu.Text = lblTask.Text; TimeSpan tsp = new TimeSpan(0, 0, tempoTot); //Total label txt = new ZedGraph.TextObj(lblTotTime.Text + "\n" + Math.Round(tsp.TotalHours, 2).ToString() + " h", 0.88f, 0.3f, ZedGraph.CoordType.PaneFraction); Pane.GraphObjList.Add(txt); txt.FontSpec.Fill = new ZedGraph.Fill(Color.White, Color.Yellow, 45f); //shadow ZedGraph.TextObj txt2 = new ZedGraph.TextObj(txt); txt2.FontSpec.Fill = new ZedGraph.Fill(Color.Black); txt2.Location.X += 0.006f; txt2.Location.Y += 0.008f; Pane.GraphObjList.Add(txt2); frmPie.zedGraph.AxisChange(); frmPie.Show(); } }
private void btnMonthSummary_Click(object sender, EventArgs e) { string mes = dTP.Value.Month.ToString(); List <string> _tasks = new List <string>(); List <double> _times = new List <double>(); foreach (DataTable tbl in PBData.Tables) { //checks if month is in selected day string[] s = tbl.TableName.Split(':'); if (s.Length > 1) { s = s[1].Split('-'); } if (s.Length > 1 && s[1] == mes) { //adds each task foreach (DataRow r in tbl.Rows) { //position int i = _tasks.IndexOf(r["colTask"].ToString()); if (i < 0) { i = _tasks.Count; _tasks.Add(r["colTask"].ToString()); _times.Add(0); } //time count _times[i] += (double)((int)r["colElapTimeInSeconds"]); } } } Random rnd = new Random(); //zedGraph Pie Chart DataTable t = GetDateTbl(); if (frmPie != null && !frmPie.IsDisposed) { frmPie.Dispose(); } frmPie = new frmChart(); ZedGraph.GraphPane Pane = frmPie.zedGraph.GraphPane; //Titulos frmPie.Text = lblTimeSpent.Text + ": " + lblMonth.Text + " " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[dTP.Value.Month - 1] + "/" + dTP.Value.Year.ToString(); Pane.Title.Text = frmPie.Text; Pane.Title.FontSpec.Size = 24f; //Pane.Title.FontSpec.IsItalic = true; Pane.Fill = new ZedGraph.Fill(Color.White, Color.LightYellow, 45f); Pane.Chart.Fill.Type = ZedGraph.FillType.None; //fonte da legenda Pane.Legend.FontSpec.Size = 11f; //Slices TimeSpan tspTot = new TimeSpan(0, 0, 0); for (int j = 0; j < _tasks.Count; j++) { TimeSpan tsp = new TimeSpan(0, 0, (int)_times[j]); tspTot += tsp; Color cor = Color.FromArgb(rnd.Next(240), rnd.Next(240), rnd.Next(240)); ZedGraph.PieItem p = Pane.AddPieSlice(Math.Round(_times[j] / 3600, 2), cor, Color.White, 45f, 0.1, _tasks[j]); //Menu pie slices removal feature ToolStripMenuItem m = new ToolStripMenuItem(_tasks[j]); m.Checked = true; frmPie.itemsMenu.DropDownItems.Add(m); m.Click += new EventHandler(m_Click); frmPie.vals.Add(_times[j] / 3600); } //Sets menu text frmPie.itemsMenu.Text = lblTask.Text; //Total label txt = new ZedGraph.TextObj(lblTotTime.Text + "\n" + Math.Round(tspTot.TotalHours, 1).ToString() + " h", 0.9f, 0.17f, ZedGraph.CoordType.PaneFraction); Pane.GraphObjList.Add(txt); txt.FontSpec.Fill = new ZedGraph.Fill(Color.White, Color.Yellow, 45f); //shadow ZedGraph.TextObj txt2 = new ZedGraph.TextObj(txt); txt2.FontSpec.Fill = new ZedGraph.Fill(Color.Black); txt2.Location.X += 0.006f; txt2.Location.Y += 0.008f; Pane.GraphObjList.Add(txt2); frmPie.zedGraph.AxisChange(); frmPie.Show(); }
public void SetDataLabelsVisible( bool visible ) { // set direct references ZedGraph.GraphPane pane = zedGraphControl1.GraphPane; ZedGraph.Axis xAxis = pane.XAxis; ZedGraph.Axis yAxis = pane.YAxis; if( CurrentGraphItem == null ) return; //zedGraphControl1.GraphPane.GraphObjList.Clear(); foreach( ZedGraph.GraphObj dataLabel in dataLabels ) zedGraphControl1.GraphPane.GraphObjList.Remove( dataLabel ); if( visible ) { if( CurrentGraphItem.IsChromatogram ) { if( !( ChromatogramAnnotationSettings.ShowPointTimes || ChromatogramAnnotationSettings.ShowPointIntensities || ChromatogramAnnotationSettings.ShowUnmatchedAnnotations || ChromatogramAnnotationSettings.ShowMatchedAnnotations ) ) return; } else { if( !( ScanAnnotationSettings.ShowPointMZs || ScanAnnotationSettings.ShowPointIntensities || ScanAnnotationSettings.ShowUnmatchedAnnotations || ScanAnnotationSettings.ShowMatchedAnnotations ) ) return; } yAxis.Scale.MinAuto = false; yAxis.Scale.Min = 0; // setup axes scales to enable the Transform method xAxis.Scale.SetupScaleData( pane, xAxis ); yAxis.Scale.SetupScaleData( pane, yAxis ); Graphics g = zedGraphControl1.CreateGraphics(); System.Drawing.Bitmap gmap; if( pane.Chart.Rect.Width > 0 && pane.Chart.Rect.Height > 0 ) { try { //pane.Draw( g ); pane.CurveList.Draw( g, pane, 1.0f ); gmap = new Bitmap( Convert.ToInt32( pane.Rect.Width ), Convert.ToInt32( pane.Rect.Height ) ); zedGraphControl1.DrawToBitmap( gmap, Rectangle.Round( pane.Rect ) ); } catch { return; } } else return; Region textBoundsRegion; Region chartRegion = new Region( pane.Chart.Rect ); Region clipRegion = new Region(); clipRegion.MakeEmpty(); g.SetClip( zedGraphControl1.MasterPane.Rect, CombineMode.Replace ); g.SetClip( chartRegion, CombineMode.Exclude ); /*Bitmap clipBmp = new Bitmap( Convert.ToInt32( pane.Rect.Width ), Convert.ToInt32( pane.Rect.Height ) ); Graphics clipG = Graphics.FromImage( clipBmp ); clipG.Clear( Color.White ); clipG.FillRegion( new SolidBrush( Color.Black ), g.Clip ); clipBmp.Save( "C:\\clip.bmp" );*/ PointDataMap<SeemsPointAnnotation> matchedAnnotations = new PointDataMap<SeemsPointAnnotation>(); // add precursor label(s) for tandem mass spectra if( CurrentGraphItem.IsMassSpectrum ) { MassSpectrum scanItem = (MassSpectrum) CurrentGraphItem; pwiz.CLI.msdata.PrecursorList precursorList = scanItem.Element.spectrumDescription.precursors; for( int i = 0; i < precursorList.Count; ++i ) { pwiz.CLI.msdata.Precursor precursor = precursorList[i]; pwiz.CLI.msdata.SelectedIonList selectedIons = precursor.selectedIons; if( selectedIons.Count == 0 ) continue; double precursorMz = (double) selectedIons[0].cvParam( pwiz.CLI.msdata.CVID.MS_m_z ).value; pwiz.CLI.msdata.CVParam precursorChargeParam = selectedIons[0].cvParam( pwiz.CLI.msdata.CVID.MS_charge_state ); int precursorCharge = 0; if( precursorChargeParam.cvid != pwiz.CLI.msdata.CVID.CVID_Unknown ) precursorCharge = (int) selectedIons[0].cvParam( pwiz.CLI.msdata.CVID.MS_charge_state ).value; float stickLength = ( yAxis.MajorTic.Size * 5 ) / pane.Chart.Rect.Height; ZedGraph.LineObj stickOverlay = new ZedGraph.LineObj( precursorMz, 1, precursorMz, 1 + stickLength ); stickOverlay.Location.CoordinateFrame = ZedGraph.CoordType.XScaleYChartFraction; stickOverlay.Line.Width = 3; stickOverlay.Line.Style = DashStyle.Dot; stickOverlay.Line.Color = Color.Green; pane.GraphObjList.Add( stickOverlay ); dataLabels.Add( stickOverlay ); // Create a text label from the X data value string precursorLabel; if( precursorCharge > 0 ) precursorLabel = String.Format( "{0}\n(+{1} precursor)", precursorMz.ToString( "f3" ), precursorCharge ); else precursorLabel = String.Format( "{0}\n(precursor of unknown charge)", precursorMz.ToString( "f3" ) ); ZedGraph.TextObj text = new ZedGraph.TextObj( precursorLabel, precursorMz, 1 + stickLength, ZedGraph.CoordType.XScaleYChartFraction, ZedGraph.AlignH.Center, ZedGraph.AlignV.Top ); text.ZOrder = ZedGraph.ZOrder.A_InFront; text.FontSpec.FontColor = stickOverlay.Line.Color; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; //text.FontSpec.Fill = new Fill( Color.FromArgb( 100, Color.White ) ); text.FontSpec.Angle = 0; if( !detectLabelOverlap( pane, g, gmap, text, out textBoundsRegion ) ) { pane.GraphObjList.Add( text ); clipRegion.Union( textBoundsRegion ); //g.SetClip( chartRegion, CombineMode.Replace ); g.SetClip( clipRegion, CombineMode.Replace ); //clipG.Clear( Color.White ); //clipG.FillRegion( new SolidBrush( Color.Black ), g.Clip ); //clipBmp.Save( "C:\\clip.bmp" ); dataLabels.Add( text ); //text.Draw( g, pane, 1.0f ); //zedGraphControl1.DrawToBitmap( gmap, Rectangle.Round( pane.Rect ) ); } } } // add automatic labels foreach( ZedGraph.CurveItem curve in pane.CurveList ) { if( !( curve.Points is PointList ) ) continue; PointList pointList = (PointList) curve.Points; for( int i = 0; i < pointList.MaxCount; i++ ) { ZedGraph.PointPair pt = pointList.GetPointAtIndex( pointList.ScaledMaxIndexList[i] ); if( pt.X < xAxis.Scale.Min || pt.Y > yAxis.Scale.Max || pt.Y < yAxis.Scale.Min ) continue; if( pt.X > xAxis.Scale.Max ) break; StringBuilder pointLabel = new StringBuilder(); Color pointColor = curve.Color; // Add annotation double annotationX = 0.0; SeemsPointAnnotation annotation = null; if( CurrentGraphItem.IsMassSpectrum ) { PointDataMap<SeemsPointAnnotation>.MapPair annotationPair = ScanAnnotationSettings.PointAnnotations.FindNear( pt.X, ScanAnnotationSettings.MatchTolerance ); if( annotationPair != null ) { annotationX = annotationPair.Key; annotation = annotationPair.Value; matchedAnnotations.Add( annotationPair ); } } else { PointDataMap<SeemsPointAnnotation>.MapPair annotationPair = ChromatogramAnnotationSettings.PointAnnotations.FindNear( pt.X, ChromatogramAnnotationSettings.MatchTolerance ); if( annotationPair != null ) { annotationX = annotationPair.Key; annotation = annotationPair.Value; matchedAnnotations.Add( annotationPair ); } } bool showMatchedAnnotations = false; if( CurrentGraphItem.IsMassSpectrum ) showMatchedAnnotations = ScanAnnotationSettings.ShowMatchedAnnotations; else showMatchedAnnotations = ChromatogramAnnotationSettings.ShowMatchedAnnotations; if( showMatchedAnnotations && annotation != null ) { pointLabel.AppendLine( annotation.Label ); pointColor = annotation.Color; //if( curve is ZedGraph.StickItem ) { ZedGraph.LineObj stickOverlay = new ZedGraph.LineObj( annotationX, 0, annotationX, pt.Y ); //stickOverlay.IsClippedToChartRect = true; stickOverlay.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale; stickOverlay.Line.Width = annotation.Width; stickOverlay.Line.Color = pointColor; zedGraphControl1.GraphPane.GraphObjList.Add( stickOverlay ); dataLabels.Add(stickOverlay); //( (ZedGraph.StickItem) curve ).Color = pointColor; //( (ZedGraph.StickItem) curve ).Line.Width = annotation.Width; } } if( CurrentGraphItem.IsMassSpectrum ) { if( ScanAnnotationSettings.ShowPointMZs ) pointLabel.AppendLine( pt.X.ToString( "f2" ) ); if( ScanAnnotationSettings.ShowPointIntensities ) pointLabel.AppendLine( pt.Y.ToString( "f2" ) ); } else { if( ChromatogramAnnotationSettings.ShowPointTimes ) pointLabel.AppendLine( pt.X.ToString( "f2" ) ); if( ChromatogramAnnotationSettings.ShowPointIntensities ) pointLabel.AppendLine( pt.Y.ToString( "f2" ) ); } string pointLabelString = pointLabel.ToString(); if( pointLabelString.Length == 0 ) continue; // Create a text label from the X data value ZedGraph.TextObj text = new ZedGraph.TextObj( pointLabelString, pt.X, yAxis.Scale.ReverseTransform( yAxis.Scale.Transform( pt.Y ) - 5 ), ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Center, ZedGraph.AlignV.Bottom ); text.ZOrder = ZedGraph.ZOrder.A_InFront; //text.IsClippedToChartRect = true; text.FontSpec.FontColor = pointColor; // Hide the border and the fill text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; //text.FontSpec.Fill = new Fill( Color.FromArgb( 100, Color.White ) ); // Rotate the text to 90 degrees text.FontSpec.Angle = 0; if( !detectLabelOverlap( pane, g, gmap, text, out textBoundsRegion ) ) { pane.GraphObjList.Add( text ); clipRegion.Union( textBoundsRegion ); //g.SetClip( chartRegion, CombineMode.Replace ); g.SetClip( clipRegion, CombineMode.Replace ); //clipG.Clear( Color.White ); //clipG.FillRegion( new SolidBrush( Color.Black ), g.Clip ); //clipBmp.Save( "C:\\clip.bmp" ); dataLabels.Add( text ); //text.Draw( g, pane, 1.0f ); //zedGraphControl1.DrawToBitmap( gmap, Rectangle.Round( pane.Rect ) ); } } } bool showUnmatchedAnnotations = false; if( CurrentGraphItem.IsMassSpectrum ) showUnmatchedAnnotations = ScanAnnotationSettings.ShowUnmatchedAnnotations; else showUnmatchedAnnotations = ChromatogramAnnotationSettings.ShowUnmatchedAnnotations; if( showUnmatchedAnnotations ) { PointDataMap<SeemsPointAnnotation> annotations = CurrentPointAnnotations; foreach( PointDataMap<SeemsPointAnnotation>.MapPair annotationPair in annotations ) { if( matchedAnnotations.Contains( annotationPair ) ) continue; float stickLength = ( yAxis.MajorTic.Size * 2 ) / pane.Chart.Rect.Height; ZedGraph.LineObj stickOverlay = new ZedGraph.LineObj( annotationPair.Key, 1, annotationPair.Key, 1 + stickLength ); //stickOverlay.IsClippedToChartRect = true; stickOverlay.Location.CoordinateFrame = ZedGraph.CoordType.XScaleYChartFraction; stickOverlay.Line.Width = annotationPair.Value.Width; stickOverlay.Line.Color = annotationPair.Value.Color; zedGraphControl1.GraphPane.GraphObjList.Add( stickOverlay ); dataLabels.Add( stickOverlay ); } } g.Dispose(); } else { // remove labels } }
/// <summary> /// used internally to draw the max and min label values for the gauge region /// </summary> /// <param name="pane"></param> /// <param name="fAngle"></param> /// <param name="objLabel"></param> /// <param name="dValue"></param> private void DrawLabelValue(GraphPane pane, float fAngle, ref TextObj objLabel, double dValue) { RectangleF tRect = _boundingRectangle; double xmiddle = tRect.Width / 2.0; double ymiddle = tRect.Height / 2.0; double cos = Math.Cos((Math.PI / (180)) * fAngle); double sin = Math.Sin((Math.PI / (180)) * fAngle); if (!pane.Clockwise) cos = -cos; if (objLabel == null) { objLabel = new ZedGraph.TextObj(); objLabel.Location.CoordinateFrame = ZedGraph.CoordType.PaneFraction; objLabel.FontSpec.Size = 10; objLabel.ZOrder = ZedGraph.ZOrder.A_InFront; objLabel.FontSpec.Border.IsVisible = false; objLabel.FontSpec.Fill.IsVisible = false; objLabel.Location.AlignH = AlignH.Center; objLabel.Location.AlignV = AlignV.Center; pane.GraphObjList.Add(objLabel); } objLabel.IsVisible = true; objLabel.Location.X = (tRect.X + xmiddle + (xmiddle * cos * 1.15)) / pane.Rect.Width; objLabel.Location.Y = (tRect.Y + ymiddle - (ymiddle * sin * 1.15)) / pane.Rect.Height; //Console.WriteLine("Angle:" + fAngle + " Sin/Cos:" + sin.ToString("f1") + "/" + cos.ToString("f1") + " X,Y:" + m_LabelMin.Location.X.ToString("f3") + "," + m_LabelMin.Location.Y.ToString("f3")); objLabel.Text = dValue.ToString("f0"); if (m_bRotateLabels) { objLabel.FontSpec.Angle = (float)(180 - fAngle); if (objLabel.FontSpec.Angle > 90) objLabel.FontSpec.Angle += 180; } }
private static void AddlabelToBars(ZedGraph.GraphPane myPn, double[] X, double[] Y) { for (int i = 0; i < Y.Length; i++) { ZedGraph.TextObj item = new ZedGraph.TextObj(Y[i].ToString("F1"), (double) ((float) X[i]), (double) (((Y[i] < 0.0) ? ((float) 0.0) : ((float) Y[i])) + 1f)); item.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale; item.Location.AlignH = ZedGraph.AlignH.Left; item.Location.AlignV = ZedGraph.AlignV.Center; item.FontSpec.Border.IsVisible = false; item.FontSpec.Fill.IsVisible = false; item.FontSpec.Angle = 90f; myPn.GraphObjList.Add(item); } }
public void SetDataLabelsVisible(bool visible) { //zedGraphControl1.GraphPane.GraphObjList.Clear(); foreach (ZedGraph.GraphObj dataLabel in dataLabels) { zedGraphControl1.GraphPane.GraphObjList.Remove(dataLabel); } if (visible) { if (!(AnnotationSettings.ShowChromatogramPointTimes || AnnotationSettings.ShowScanPointMZs || AnnotationSettings.ShowChromatogramPointIntensities || AnnotationSettings.ShowScanPointIntensities || AnnotationSettings.ShowUnmatchedAnnotations || AnnotationSettings.ShowMatchedAnnotations)) { return; } // set direct references ZedGraph.GraphPane pane = zedGraphControl1.GraphPane; ZedGraph.Axis xAxis = pane.XAxis; ZedGraph.Axis yAxis = pane.YAxis; yAxis.Scale.MinAuto = false; yAxis.Scale.Min = 0; // setup axes scales to enable the Transform method xAxis.Scale.SetupScaleData(pane, xAxis); yAxis.Scale.SetupScaleData(pane, yAxis); Graphics g = zedGraphControl1.CreateGraphics(); //pane.Draw( g ); pane.CurveList.Draw(g, pane, 1.0f); System.Drawing.Bitmap gmap = new Bitmap(Convert.ToInt32(pane.Rect.Width), Convert.ToInt32(pane.Rect.Height)); zedGraphControl1.DrawToBitmap(gmap, Rectangle.Round(pane.Rect)); Region chartRegion = new Region(pane.Chart.Rect); Region clipRegion = new Region(); clipRegion.MakeEmpty(); g.SetClip(zedGraphControl1.MasterPane.Rect, CombineMode.Replace); g.SetClip(chartRegion, CombineMode.Exclude); /*Bitmap clipBmp = new Bitmap( Convert.ToInt32( pane.Rect.Width ), Convert.ToInt32( pane.Rect.Height ) ); * Graphics clipG = Graphics.FromImage( clipBmp ); * clipG.Clear( Color.White ); * clipG.FillRegion( new SolidBrush( Color.Black ), g.Clip ); * clipBmp.Save( "C:\\clip.bmp" );*/ PointDataMap <SeemsPointAnnotation> matchedAnnotations = new PointDataMap <SeemsPointAnnotation>(); // add automatic labels foreach (ZedGraph.CurveItem curve in pane.CurveList) { SeemsPointList pointList = (SeemsPointList)curve.Points; for (int i = 0; i < pointList.MaxCount; i++) { ZedGraph.PointPair pt = pointList.GetPointAtIndex(pointList.ScaledMaxIndexList[i]); if (pt.X < xAxis.Scale.Min || pt.Y > yAxis.Scale.Max || pt.Y < yAxis.Scale.Min) { continue; } if (pt.X > xAxis.Scale.Max) { break; } StringBuilder pointLabel = new StringBuilder(); Color pointColor = curve.Color; // Add annotation double annotationX = 0.0; SeemsPointAnnotation annotation = null; if (CurrentScan.IsMassSpectrum) { PointDataMap <SeemsPointAnnotation> .MapPair annotationPair = AnnotationSettings.ScanPointAnnotations.FindNear(pt.X, AnnotationSettings.ScanMatchTolerance); if (annotationPair != null) { annotationX = annotationPair.Key; annotation = annotationPair.Value; matchedAnnotations.Add(annotationPair); } } else { PointDataMap <SeemsPointAnnotation> .MapPair annotationPair = AnnotationSettings.ChromatogramPointAnnotations.FindNear(pt.X, AnnotationSettings.ChromatogramMatchTolerance); if (annotationPair != null) { annotationX = annotationPair.Key; annotation = annotationPair.Value; matchedAnnotations.Add(annotationPair); } } if (AnnotationSettings.ShowMatchedAnnotations && annotation != null) { pointLabel.AppendLine(annotation.Label); pointColor = annotation.Color; //if( curve is ZedGraph.StickItem ) { ZedGraph.LineObj stickOverlay = new ZedGraph.LineObj(annotationX, 0, annotationX, pt.Y); //stickOverlay.IsClippedToChartRect = true; stickOverlay.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale; stickOverlay.Line.Width = annotation.Width; stickOverlay.Line.Color = pointColor; zedGraphControl1.GraphPane.GraphObjList.Add(stickOverlay); dataLabels.Add(stickOverlay); //( (ZedGraph.StickItem) curve ).Color = pointColor; //( (ZedGraph.StickItem) curve ).Line.Width = annotation.Width; } } if (CurrentScan.IsMassSpectrum) { if (AnnotationSettings.ShowScanPointMZs) { pointLabel.AppendLine(pt.X.ToString("f2")); } if (AnnotationSettings.ShowScanPointIntensities) { pointLabel.AppendLine(pt.Y.ToString("f2")); } } else { if (AnnotationSettings.ShowChromatogramPointTimes) { pointLabel.AppendLine(pt.X.ToString("f2")); } if (AnnotationSettings.ShowChromatogramPointIntensities) { pointLabel.AppendLine(pt.Y.ToString("f2")); } } string pointLabelString = pointLabel.ToString(); if (pointLabelString.Length == 0) { continue; } // Create a text label from the X data value ZedGraph.TextObj text = new ZedGraph.TextObj(pointLabelString, pt.X, yAxis.Scale.ReverseTransform(yAxis.Scale.Transform(pt.Y) - 5), ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Center, ZedGraph.AlignV.Bottom); text.ZOrder = ZedGraph.ZOrder.A_InFront; //text.IsClippedToChartRect = true; text.FontSpec.FontColor = pointColor; // Hide the border and the fill text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; //text.FontSpec.Fill = new Fill( Color.FromArgb( 100, Color.White ) ); // Rotate the text to 90 degrees text.FontSpec.Angle = 0; string shape, coords; text.GetCoords(pane, g, 1.0f, out shape, out coords); if (shape != "poly") { throw new InvalidOperationException("shape must be 'poly'"); } string[] textBoundsPointStrings = coords.Split(",".ToCharArray()); if (textBoundsPointStrings.Length != 9) { throw new InvalidOperationException("coords length must be 8"); } Point[] textBoundsPoints = new Point[] { new Point(Convert.ToInt32(textBoundsPointStrings[0]), Convert.ToInt32(textBoundsPointStrings[1])), new Point(Convert.ToInt32(textBoundsPointStrings[2]), Convert.ToInt32(textBoundsPointStrings[3])), new Point(Convert.ToInt32(textBoundsPointStrings[4]), Convert.ToInt32(textBoundsPointStrings[5])), new Point(Convert.ToInt32(textBoundsPointStrings[6]), Convert.ToInt32(textBoundsPointStrings[7])) }; byte[] textBoundsPointTypes = new byte[] { (byte)PathPointType.Start, (byte)PathPointType.Line, (byte)PathPointType.Line, (byte)PathPointType.Line }; GraphicsPath textBoundsPath = new GraphicsPath(textBoundsPoints, textBoundsPointTypes); textBoundsPath.CloseFigure(); Region textBoundsRegion = new Region(textBoundsPath); textBoundsRegion.Intersect(pane.Chart.Rect); RectangleF[] textBoundsRectangles = textBoundsRegion.GetRegionScans(g.Transform); bool overlapDetected = false; for (int j = 0; j < textBoundsRectangles.Length && !overlapDetected; ++j) { if (g.Clip.IsVisible(textBoundsRectangles[j])) { overlapDetected = true; } for (float y = textBoundsRectangles[j].Top; y <= textBoundsRectangles[j].Bottom && !overlapDetected; ++y) { for (float x = textBoundsRectangles[j].Left; x <= textBoundsRectangles[j].Right && !overlapDetected; ++x) { if (gmap.GetPixel(Convert.ToInt32(x), Convert.ToInt32(y)).ToArgb() != pane.Chart.Fill.Color.ToArgb()) { overlapDetected = true; } } } } if (!overlapDetected) { pane.GraphObjList.Add(text); clipRegion.Union(textBoundsRegion); //g.SetClip( chartRegion, CombineMode.Replace ); g.SetClip(clipRegion, CombineMode.Replace); //clipG.Clear( Color.White ); //clipG.FillRegion( new SolidBrush( Color.Black ), g.Clip ); //clipBmp.Save( "C:\\clip.bmp" ); dataLabels.Add(text); //text.Draw( g, pane, 1.0f ); //zedGraphControl1.DrawToBitmap( gmap, Rectangle.Round( pane.Rect ) ); } } } if (AnnotationSettings.ShowUnmatchedAnnotations) { PointDataMap <SeemsPointAnnotation> annotations; if (CurrentScan.IsMassSpectrum) { annotations = AnnotationSettings.ScanPointAnnotations; } else { annotations = AnnotationSettings.ChromatogramPointAnnotations; } foreach (PointDataMap <SeemsPointAnnotation> .MapPair annotationPair in annotations) { if (matchedAnnotations.Contains(annotationPair)) { continue; } float stickLength = (yAxis.MajorTic.Size * 2) / pane.Chart.Rect.Height; ZedGraph.LineObj stickOverlay = new ZedGraph.LineObj(annotationPair.Key, 1, annotationPair.Key, -stickLength); //stickOverlay.IsClippedToChartRect = true; stickOverlay.Location.CoordinateFrame = ZedGraph.CoordType.XScaleYChartFraction; stickOverlay.Line.Width = annotationPair.Value.Width; stickOverlay.Line.Color = annotationPair.Value.Color; zedGraphControl1.GraphPane.GraphObjList.Add(stickOverlay); dataLabels.Add(stickOverlay); } } g.Dispose(); } else { // remove labels } }
private void DrawArea(Graphics g, float scale) { //Bitmap bmp = new Bitmap(pnlCh.Width, pnlCh.Height); //Graphics g = Graphics.FromImage(bmp); //PointF pPad = new PointF(0, 0); //if (pnlAx.Tag != null) //{ // pPad = (PointF)pnlAx.Tag; //} int ht = (int)((float)pnlCh.Height * scale); int wh = (int)((float)pnlCh.Width * scale); g.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, pnlCh.Width, pnlCh.Height), Color.MintCream, Color.LemonChiffon, 65f), 0, 0, wh - 1, ht - 1); for (int i = 0; i < 11; i++) { g.DrawLine(new Pen(Color.LightGray, 1), 0, i * ht / 11, pnlCh.Width, i * ht / 11); g.DrawLine(new Pen(Color.Black, 1), 0, i * ht / 11, 4, i * ht / 11); g.DrawLine(new Pen(Color.Black, 1), pnlCh.Width - 5, i * ht / 11, pnlCh.Width, i * ht / 11); for (int j = 1; j < 5; j++) { g.DrawLine(new Pen(Color.Black, 1), 0, (i * ht + j * ht / 5) / 11, 3, (i * ht + j * ht / 5) / 11); g.DrawLine(new Pen(Color.Black, 1), pnlCh.Width - 3, (i * ht + j * ht / 5) / 11, pnlCh.Width, (i * ht + j * ht / 5) / 11); } } int dec = -(int)Math.Round(Math.Log10(logMax - logMin), 0); dec++; if (dec < 0) { dec = 0; } for (double d = logMin; d < logMax; d += (logMax - logMin) / 10) { g.DrawLine(new Pen(Color.LightGray, 1), (float)(wh * (d - logMin) / (logMax - logMin)), 0, (float)(wh * (d - logMin) / (logMax - logMin)), pnlCh.Height); g.DrawLine(new Pen(Color.Black, 1), (float)(wh * (d - logMin) / (logMax - logMin)), 0, (float)(wh * (d - logMin) / (logMax - logMin)), 4); g.DrawLine(new Pen(Color.Black, 1), (float)(wh * (d - logMin) / (logMax - logMin)), pnlCh.Height - 5, (float)(wh * (d - logMin) / (logMax - logMin)), pnlCh.Height); for (int j = 1; j < 5; j++) { g.DrawLine(new Pen(Color.Black, 1), (float)(wh * (d - logMin + j * (logMax - logMin) / 50) / (logMax - logMin)), 0, (float)(wh * (d - logMin + j * (logMax - logMin) / 50) / (logMax - logMin)), 2); g.DrawLine(new Pen(Color.Black, 1), (float)(wh * (d - logMin + j * (logMax - logMin) / 50) / (logMax - logMin)), pnlCh.Height - 3, (float)(wh * (d - logMin + j * (logMax - logMin) / 50) / (logMax - logMin)), pnlCh.Height); } } double[] par = new double[p_vals.Count]; for (int i = 0; i < p_vals.Count; i++) { par[i] = (double)p_vals[i]; } zedGraphControl1.GraphPane.CurveList.Clear(); zedGraphControl1.GraphPane.GraphObjList.Clear(); zedGraphControl1.ZoomOutAll(zedGraphControl1.GraphPane); double[] probCur9 = new double[l_vals.Count]; double[] probCurY9 = new double[l_vals.Count]; double[] probCur7 = new double[l_vals.Count]; double[] probCurY7 = new double[l_vals.Count]; double[] probCur5 = new double[l_vals.Count]; double[] probCurY5 = new double[l_vals.Count]; string stmod = ""; for (int y = 0; y < l_vals.Count; y++) { ArrayList arr = (ArrayList)l_vals[y]; double[] log = new double[arr.Count]; for (int i = 0; i < arr.Count; i++) { log[i] = (double)arr[i]; } ArrayList pt = new ArrayList(); double[] zedPar = new double[log.Length]; double[] zedLog = new double[log.Length]; Gridat.StatisticParam stp = new Gridat.StatisticParam(log); float pcv = (float)((stp.Average - logMin) * wh / (logMax - logMin)); double mod = 0; int cmod = 0; for (int x = 0; x < log.Length; x++) //= log.Length / 1000 + 1) { float py = (float)(par[y] * ht / 110); float px = (float)((log[x] - logMin) * wh / (logMax - logMin)); double ind = (log.Max() - log.Min()) / 24; int c = 0; for (int d = 0; d < log.Length; d++) { if (log[d] > log[x] - ind && log[d] < log[x] + ind) { c++; } } if (c > cmod) { cmod = c; mod = log[x]; } c = 200 * c / log.Length;// reoGridControl1.RowCount; //g.DrawLine(new Pen(Color.FromArgb(255, 0, 0, 0)), px , py , px , py + c / 10); //g.FillEllipse(new SolidBrush(Color.FromArgb(25, 0, 0, 0)), px , py, c/10, c/10 ); //g.FillRectangle(new SolidBrush(Color.FromArgb(75, 0, 0, 0)), px , py - c * 2, 1, c * 2); //g.DrawLine(new Pen(Color.FromArgb(255, y*225/par.Length , 0, 255-y*225/par.Length )), px-1, py - c /5, px, py - c /5); //g.DrawLine(new Pen(Color.FromArgb(175, y * 225 / par.Length, 0, 255 - y * 225 / par.Length)), px - 10, py, px + 10, py); int cp = 0; for (cp = 0; cp < pt.Count; cp++) { PointF p = (PointF)pt[cp]; if (p.X < px) { pt.Insert(cp, new PointF(px, py + c / 5)); break; } } if (cp == pt.Count) { pt.Add(new PointF(px, py + c / 5)); } } stmod = stmod + mod.ToString() + "\t" + par[y].ToString() + "\r\n"; for (int x = 0; x < log.Length; x++)//= log.Length / 1000 + 1) { if (Math.Round(GEV(log[x], stp.StdDev, mod), 2) == .9) { float py = (float)(par[y] * ht / 110); float px = (float)((log[x] - logMin) * wh / (logMax - logMin)); g.FillEllipse(new SolidBrush(Color.Red), px - 2, py - 2, 4, 4); probCur9[y] = (double)px * (logMax - logMin) / wh + logMin; probCurY9[y] = (double)py; } if (Math.Round(GEV(log[x], stp.StdDev, mod), 2) == .7) { float py = (float)(par[y] * ht / 110); float px = (float)((log[x] - logMin) * wh / (logMax - logMin)); g.FillEllipse(new SolidBrush(Color.Red), px - 2, py - 2, 4, 4); probCur7[y] = (double)px * (logMax - logMin) / wh + logMin; probCurY7[y] = (double)py; } if (Math.Round(GEV(log[x], stp.StdDev, mod), 2) == .5) { float py = (float)(par[y] * ht / 110); float px = (float)((log[x] - logMin) * wh / (logMax - logMin)); g.FillEllipse(new SolidBrush(Color.Red), px - 2, py - 2, 4, 4); probCur5[y] = (double)px * (logMax - logMin) / wh + logMin; probCurY5[y] = (double)py; } } Clipboard.SetText(stmod); for (int i = 0; i < pt.Count - 1; i++) { PointF p1 = (PointF)pt[i]; PointF p2 = (PointF)pt[i + 1]; g.DrawLine(new Pen(Color.FromArgb(175, y * 225 / par.Length, 0, 255 - y * 225 / par.Length)), p1, p2); if (i == 0) { g.DrawString(par[y].ToString(), new Font(this.Font.Name, 7f), new SolidBrush(Color.FromArgb(175, y * 225 / par.Length, 0, 255 - y * 225 / par.Length)), p2); zedPar[0] = p1.Y; zedLog[0] = p1.X * (logMax - logMin) / wh + logMin; } zedPar[i + 1] = p2.Y; zedLog[i + 1] = p2.X * (logMax - logMin) / wh + logMin; } Random rnd = new Random(); Color col = Color.FromArgb(255, rnd.Next(200), rnd.Next(200), rnd.Next(200)); //zedGraphControl1.GraphPane.YAxis.IsVisible = false; zedGraphControl1.GraphPane.AddCurve("", zedLog, zedPar, col, ZedGraph.SymbolType.None).Line.IsAntiAlias = true; zedGraphControl1.GraphPane.Title.Text = ""; zedGraphControl1.GraphPane.XAxis.Title.Text = cmbLog1.Text + "(G/C3)"; zedGraphControl1.GraphPane.XAxis.Title.FontSpec.Size = 10; zedGraphControl1.GraphPane.XAxis.Scale.FontSpec.Size = 8; zedGraphControl1.GraphPane.YAxis.Title.Text = "Ash Content(%)"; zedGraphControl1.GraphPane.YAxis.Title.FontSpec.Size = 10; zedGraphControl1.GraphPane.YAxis.Scale.FontSpec.Size = 8; zedGraphControl1.AxisChange(); ZedGraph.TextObj myText = new ZedGraph.TextObj(par[y].ToString(), zedLog[0] + .06, zedPar[0] + 2); myText.Location.CoordinateFrame = ZedGraph.CoordType.AxisXYScale; myText.Location.AlignH = ZedGraph.AlignH.Right; myText.Location.AlignV = ZedGraph.AlignV.Center; myText.FontSpec.IsItalic = true; myText.FontSpec.IsBold = false; myText.FontSpec.FontColor = col; myText.FontSpec.Size = 8f; myText.FontSpec.Fill.IsVisible = false; myText.FontSpec.Border.IsVisible = false; zedGraphControl1.GraphPane.GraphObjList.Add(myText); zedGraphControl1.Refresh(); } for (int i = probCurY9.Length - 2; i >= 0; i--) { if (probCurY9[i] == 0) { probCur9[i] = probCur9[i + 1]; probCurY9[i] = probCurY9[i + 1]; } } zedGraphControl1.GraphPane.AddCurve("", probCur9, probCurY9, Color.Blue, ZedGraph.SymbolType.None).Line.Style = System.Drawing.Drawing2D.DashStyle.Dash; for (int i = probCurY7.Length - 2; i >= 0; i--) { if (probCurY7[i] == 0) { probCur7[i] = probCur7[i + 1]; probCurY7[i] = probCurY7[i + 1]; } } zedGraphControl1.GraphPane.AddCurve("", probCur7, probCurY7, Color.Blue, ZedGraph.SymbolType.None).Line.Style = System.Drawing.Drawing2D.DashStyle.Dash; for (int i = probCurY5.Length - 2; i >= 0; i--) { if (probCurY5[i] == 0) { probCur5[i] = probCur5[i + 1]; probCurY5[i] = probCurY5[i + 1]; } } zedGraphControl1.GraphPane.AddCurve("", probCur5, probCurY5, Color.Blue, ZedGraph.SymbolType.None).Line.Style = System.Drawing.Drawing2D.DashStyle.Dash; ZedGraph.TextObj cuText = new ZedGraph.TextObj("CDF=.9", probCur9[probCur9.Length - 1], probCurY9[probCurY9.Length - 1] + 5); cuText.FontSpec.FontColor = Color.Blue; cuText.FontSpec.Size = 8f; cuText.FontSpec.Fill.IsVisible = false; cuText.FontSpec.Border.IsVisible = false; zedGraphControl1.GraphPane.GraphObjList.Add(cuText); cuText = new ZedGraph.TextObj("CDF=.7", probCur7[probCur7.Length - 1], probCurY7[probCurY7.Length - 1] + 5); cuText.FontSpec.FontColor = Color.Blue; cuText.FontSpec.Size = 8f; cuText.FontSpec.Fill.IsVisible = false; cuText.FontSpec.Border.IsVisible = false; zedGraphControl1.GraphPane.GraphObjList.Add(cuText); cuText = new ZedGraph.TextObj("CDF=.5", probCur5[probCur5.Length - 1], probCurY5[probCurY5.Length - 1] + 5); cuText.FontSpec.FontColor = Color.Blue; cuText.FontSpec.Size = 8f; cuText.FontSpec.Fill.IsVisible = false; cuText.FontSpec.Border.IsVisible = false; zedGraphControl1.GraphPane.GraphObjList.Add(cuText); zedGraphControl1.Refresh(); g.DrawRectangle(new Pen(Color.Black), 0, 0, pnlCh.Width - 1, pnlCh.Height - 1); //bmp.Save(Application.StartupPath + "\\charts\\" + cmbLog1.Text + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //g.Dispose(); //bmp.Dispose(); //MessageBox.Show("Ready"); //pnlCh.BackgroundImage = Image.FromFile(Application.StartupPath + "\\charts\\" + cmbLog1.Text + ".jpg"); }
public static Image GetAnnotatedImage(string argPeptide, MSScan argScan, List<MSPoint> argPeaks, GlycanStructure argStructure) { float MaxX = argStructure.Root.FetchAllGlycanNode().OrderByDescending(o => o.IDMass).ToList()[0].IDMass; if (MaxX + 100 > 2000.0) { MaxX = 2000.0f; } else { MaxX = MaxX + 100; } ZedGraph.GraphPane Pane = new ZedGraph.GraphPane(new RectangleF(0.0f, 0.0f, 2000.0f, 1500.0f), argScan.ScanNo.ToString(), "Mass", "Intensity"); //ZedGraph.MasterPane Pane = new ZedGraph.MasterPane(argTitle,new RectangleF(0.0f, 0.0f, 2400.0f, 1800.0f) ); Pane.XAxis.MajorTic.IsInside = false; Pane.XAxis.MinorTic.IsInside = false; Pane.Legend.IsVisible = false; ZedGraph.PointPairList Peaks = new ZedGraph.PointPairList(); double MaxIntensity = 0.0; ///////////////// //Peaks //////////////// foreach (MSPoint p in argPeaks) { if (p.Intensity > MaxIntensity && p.Mass<=MaxX) { MaxIntensity = p.Intensity; } } foreach (MSPoint p in argPeaks) { if (p.Mass <= MaxX) { Peaks.Add(p.Mass, (p.Intensity/MaxIntensity)*100.0); } } Pane.AddStick("Peaks", Peaks, Color.Red); ////////////////// //Y1 text object ////////////////// /* ZedGraph.TextObj txtY1 = new ZedGraph.TextObj("Y1", argStructure.Y1.MZ, 102); txtY1.FontSpec.Size = txtY1.FontSpe.cSize*0.5f; txtY1.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Insert(0, txtY1);*/ ///////////////// //Structure //////////////// GlycansDrawer GS; double previousBoundary = 0; foreach (GlycanTreeNode t in argStructure.Root.FetchAllGlycanNode().OrderBy(o => o.IDMass).ToList()) { GS = new GlycansDrawer(t.IUPACFromRoot, false); double glycopeptideMZ = t.IDMass; //double glycopeptideMZ =argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHexNac * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHex*GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.Hex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfDeHex * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.DeHex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuAc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuGc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuGc, FGS.Charge); Image imgStructure = GlycanImage.RotateImage(GS.GetImage(), 270); ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 131); double PositionX = glycopeptideMZ; if (previousBoundary >= PositionX) { PositionX = previousBoundary + 20; } if (imgStructure.Width > txtGlycanMz.Location.Width) { previousBoundary = imgStructure.Width + PositionX; } else { previousBoundary = (float)txtGlycanMz.Location.Width + PositionX; } ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width + 20, imgStructure.Height); glycan.IsScaled = false; glycan.Location.AlignV = ZedGraph.AlignV.Bottom; txtGlycanMz.Location.X = glycan.Location.X + (float)glycan.Image.Width / 2 - (float)txtGlycanMz.Location.Width / 2; txtGlycanMz.FontSpec.Size = txtGlycanMz.FontSpec.Size * 0.3f; txtGlycanMz.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMz); Pane.GraphObjList.Add(glycan); double interval = 100000; int idx = 0; for (int i = 0; i < Peaks.Count; i++) { if (Math.Abs(Peaks[i].X - glycopeptideMZ) < interval) { interval = Math.Abs((float)Peaks[i].X - glycopeptideMZ); idx = i; } } string mzLabelwPPM = Peaks[idx].X.ToString("0.000");// + "\n(" + Math.Abs(glycopeptideMZ - (float)Peaks[idx].X).ToString("0") + "da)"; ZedGraph.TextObj PeakLabel = new ZedGraph.TextObj(mzLabelwPPM, Peaks[idx].X, Peaks[idx].Y + 3.0); PeakLabel.FontSpec.Size = PeakLabel.FontSpec.Size * 0.3f; PeakLabel.FontSpec.Border.IsVisible = false; PeakLabel.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(PeakLabel); } Pane.AxisChange(); Pane.YAxis.Scale.Max = 145; Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100); Pane.XAxis.Scale.Max = Peaks[Peaks.Count - 1].X + 100; //////////// //Glycan Structure //////////// GS = new GlycansDrawer(argStructure.IUPACString, false); Image imgStruc = RotateImage( GS.GetImage() ,180); ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, Pane.XAxis.Scale.Min + 20, 140, imgStruc.Width + 20, imgStruc.Height); fullStructure.IsScaled = false; Pane.GraphObjList.Add(fullStructure); /////////////// //Glycan M/Z ////////////// double glycopeptidemz = GlycanMass.GetGlycanMasswithCharge(argStructure.Root.GlycanType,argStructure.Charge) + argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, argStructure.Charge); ZedGraph.TextObj txtGlycanMZ = new ZedGraph.TextObj("\n Precursor:" + argScan.ParentMZ.ToString("0.000")+"(" +argScan.ParentCharge.ToString()+")"+ "\nPeptide Sequence:" + argPeptide , Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2, 140); txtGlycanMZ.FontSpec.Size = txtGlycanMZ.FontSpec.Size * 0.3f; txtGlycanMZ.FontSpec.Border.IsVisible = false; txtGlycanMZ.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMZ); Image tmp = (Image)Pane.GetImage(); return tmp; }
private void LoadGraph() { if (lineProductionDatas.Count <= 0) { MessageBox.Show("Unable to load data from server.", "Line efficiency daily graph", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var bufferList = new List <ArticleProductionData>(); var pane = new ZedGraph.GraphPane(); pane.Title.Text = "EFF con " + Line + " (" + Department + ")"; pane.YAxis.Title.Text = "EFF %"; pane.XAxis.Title.Text = Month.ToString() + "/" + Year.ToString(); pane.XAxis.MajorTic.IsAllTics = true; pane.XAxis.Scale.MajorStep = 1; pane.XAxis.Scale.Min = 1; pane.XAxis.Scale.Max = 31; pane.Fill = new ZedGraph.Fill(Brushes.WhiteSmoke); ZedGraph.PointPairList list = new ZedGraph.PointPairList(); foreach (var lineProduction in lineProductionDatas) { var workEff = Math.Round((lineProduction.Qty / lineProduction.Producibili) * 100.0, 1); list.Add(lineProduction.Datex.Day, workEff); } pane.GraphObjList.Clear(); zedGraph.GraphPane.CurveList.Clear(); var curve = new ZedGraph.LineItem("EFF %", list, Color.SteelBlue, ZedGraph.SymbolType.Circle); curve.Line.IsVisible = true; curve.Symbol.Fill.Color = Color.SteelBlue; curve.Symbol.Fill.Type = ZedGraph.FillType.Solid; curve.Symbol.Size = 10; curve.Line.Width = 4; curve.Symbol.IsAntiAlias = true; curve.Line.IsSmooth = false; curve.Line.IsAntiAlias = true; curve.Line.Fill = new ZedGraph.Fill(Color.White, Color.LightSkyBlue, -45F); curve.Symbol.Size = 8.0F; curve.Symbol.Fill = new ZedGraph.Fill(Color.White); curve.Line.Width = 2.0F; pane.XAxis.MajorTic.IsBetweenLabels = true; pane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.FromArgb(250, 250, 250), 90F); pane.Fill = new ZedGraph.Fill(Color.FromArgb(250, 250, 250)); zedGraph.GraphPane = pane; pane.Legend.IsVisible = false; ZedGraph.PointPairList articleRangeList = new ZedGraph.PointPairList(); ZedGraph.LineItem articleVertCurve = new ZedGraph.LineItem(""); for (var i = 0; i <= curve.Points.Count - 1; i++) { ZedGraph.PointPair pt = curve.Points[i]; ZedGraph.TextObj text = new ZedGraph.TextObj(pt.Y.ToString("f1"), pt.X, pt.Y, ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center); text.ZOrder = ZedGraph.ZOrder.D_BehindAxis; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; text.FontSpec.Angle = 90; pane.GraphObjList.Add(text); var art = articleProductions.LastOrDefault(x => x.Day == pt.X); var buf = bufferList.FirstOrDefault(x => x.Article == art.Article || x.Day == art.Day); if (art != null && buf == null) { bufferList.Add(art); ZedGraph.TextObj textArt = new ZedGraph.TextObj(art.Article, pt.X + 0.2f, pane.YAxis.Scale.Min + pt.Y / 2, ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center); textArt.ZOrder = ZedGraph.ZOrder.D_BehindAxis; textArt.FontSpec.Border.IsVisible = false; textArt.FontSpec.Fill.IsVisible = false; textArt.FontSpec.Size = 9; textArt.FontSpec.FontColor = Color.Black; var lastArt = articleProductions.LastOrDefault(x => x.Day == pt.X - 1); var nextArt = articleProductions.FirstOrDefault(x => x.Day == pt.X + 2); if (lastArt != null && lastArt.Article != art.Article || nextArt != null && nextArt.Article != art.Article) { textArt.FontSpec.Angle = 90; } else { textArt.FontSpec.Angle = 0; } pane.GraphObjList.Add(textArt); articleRangeList = new ZedGraph.PointPairList(); articleRangeList.Add(pt.X, pt.Y); articleRangeList.Add(pt.X, pane.YAxis.Scale.Min); var ac = new ZedGraph.LineItem(art.Article); ac.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot; ac = pane.AddCurve(art.Article, articleRangeList, Color.Orange, ZedGraph.SymbolType.None); } } zedGraph.GraphPane.CurveList.Add(curve); zedGraph.AxisChange(); zedGraph.Refresh(); zedGraph.IsShowPointValues = true; zedGraph.PointValueFormat = "0"; zedGraph.Invalidate(); }
public static Image GetAnnotatedImage(string argPeptide, MSScan argScan, List <MSPoint> argPeaks, GlycanStructure argStructure) { float MaxX = argStructure.Root.FetchAllGlycanNode().OrderByDescending(o => o.IDMass).ToList()[0].IDMass; if (MaxX + 100 > 2000.0) { MaxX = 2000.0f; } else { MaxX = MaxX + 100; } ZedGraph.GraphPane Pane = new ZedGraph.GraphPane(new RectangleF(0.0f, 0.0f, 2000.0f, 1500.0f), argScan.ScanNo.ToString(), "Mass", "Intensity"); //ZedGraph.MasterPane Pane = new ZedGraph.MasterPane(argTitle,new RectangleF(0.0f, 0.0f, 2400.0f, 1800.0f) ); Pane.XAxis.MajorTic.IsInside = false; Pane.XAxis.MinorTic.IsInside = false; Pane.Legend.IsVisible = false; ZedGraph.PointPairList Peaks = new ZedGraph.PointPairList(); double MaxIntensity = 0.0; ///////////////// //Peaks //////////////// foreach (MSPoint p in argPeaks) { if (p.Intensity > MaxIntensity && p.Mass <= MaxX) { MaxIntensity = p.Intensity; } } foreach (MSPoint p in argPeaks) { if (p.Mass <= MaxX) { Peaks.Add(p.Mass, (p.Intensity / MaxIntensity) * 100.0); } } Pane.AddStick("Peaks", Peaks, Color.Red); ////////////////// //Y1 text object ////////////////// /* ZedGraph.TextObj txtY1 = new ZedGraph.TextObj("Y1", argStructure.Y1.MZ, 102); * txtY1.FontSpec.Size = txtY1.FontSpe.cSize*0.5f; * txtY1.FontSpec.Border.IsVisible = false; * Pane.GraphObjList.Insert(0, txtY1);*/ ///////////////// //Structure //////////////// GlycansDrawer GS; double previousBoundary = 0; foreach (GlycanTreeNode t in argStructure.Root.FetchAllGlycanNode().OrderBy(o => o.IDMass).ToList()) { GS = new GlycansDrawer(t.IUPACFromRoot, false); double glycopeptideMZ = t.IDMass; //double glycopeptideMZ =argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHexNac * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.HexNAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfHex*GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.Hex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfDeHex * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.DeHex, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuAc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuAc, FGS.Charge); //glycopeptideMZ = glycopeptideMZ + // FGS.NoOfNeuGc * GlycanMass.GetGlycanAVGMasswithCharge(Glycan.Type.NeuGc, FGS.Charge); Image imgStructure = GlycanImage.RotateImage(GS.GetImage(), 270); ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 131); double PositionX = glycopeptideMZ; if (previousBoundary >= PositionX) { PositionX = previousBoundary + 20; } if (imgStructure.Width > txtGlycanMz.Location.Width) { previousBoundary = imgStructure.Width + PositionX; } else { previousBoundary = (float)txtGlycanMz.Location.Width + PositionX; } ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width + 20, imgStructure.Height); glycan.IsScaled = false; glycan.Location.AlignV = ZedGraph.AlignV.Bottom; txtGlycanMz.Location.X = glycan.Location.X + (float)glycan.Image.Width / 2 - (float)txtGlycanMz.Location.Width / 2; txtGlycanMz.FontSpec.Size = txtGlycanMz.FontSpec.Size * 0.3f; txtGlycanMz.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMz); Pane.GraphObjList.Add(glycan); double interval = 100000; int idx = 0; for (int i = 0; i < Peaks.Count; i++) { if (Math.Abs(Peaks[i].X - glycopeptideMZ) < interval) { interval = Math.Abs((float)Peaks[i].X - glycopeptideMZ); idx = i; } } string mzLabelwPPM = Peaks[idx].X.ToString("0.000");// + "\n(" + Math.Abs(glycopeptideMZ - (float)Peaks[idx].X).ToString("0") + "da)"; ZedGraph.TextObj PeakLabel = new ZedGraph.TextObj(mzLabelwPPM, Peaks[idx].X, Peaks[idx].Y + 3.0); PeakLabel.FontSpec.Size = PeakLabel.FontSpec.Size * 0.3f; PeakLabel.FontSpec.Border.IsVisible = false; PeakLabel.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(PeakLabel); } Pane.AxisChange(); Pane.YAxis.Scale.Max = 145; Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100); Pane.XAxis.Scale.Max = Peaks[Peaks.Count - 1].X + 100; //////////// //Glycan Structure //////////// GS = new GlycansDrawer(argStructure.IUPACString, false); Image imgStruc = RotateImage(GS.GetImage(), 180); ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, Pane.XAxis.Scale.Min + 20, 140, imgStruc.Width + 20, imgStruc.Height); fullStructure.IsScaled = false; Pane.GraphObjList.Add(fullStructure); /////////////// //Glycan M/Z ////////////// double glycopeptidemz = GlycanMass.GetGlycanMasswithCharge(argStructure.Root.GlycanType, argStructure.Charge) + argStructure.Y1.Mass - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, argStructure.Charge); ZedGraph.TextObj txtGlycanMZ = new ZedGraph.TextObj("\n Precursor:" + argScan.ParentMZ.ToString("0.000") + "(" + argScan.ParentCharge.ToString() + ")" + "\nPeptide Sequence:" + argPeptide , Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2, 140); txtGlycanMZ.FontSpec.Size = txtGlycanMZ.FontSpec.Size * 0.3f; txtGlycanMZ.FontSpec.Border.IsVisible = false; txtGlycanMZ.FontSpec.Fill.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMZ); Image tmp = (Image)Pane.GetImage(); return(tmp); }
public void DrawsequencingGraph(GlycanStructure argStructure) { zedSequence.GraphPane.GraphObjList.Clear(); zedSequence.GraphPane.Legend.IsVisible = false; List <String> tmp = argStructure.Root.GetSequencingMapList(); if (tmp.Count == 0) { return; } float Xmin = Convert.ToSingle(tmp[0].Split('-')[0]); float Xmax = Convert.ToSingle(tmp[tmp.Count - 1].Split('-')[2]); if (Xmax == 0.0f) { Xmax = scan.MSPeaks[scan.MSPeaks.Count - 1].MonoMass; } double YMax = 0.0; ZedGraph.PointPairList pplPeak = new ZedGraph.PointPairList(); for (int i = 0; i < GS.FilteredPeaks.Count; i++) { if (GS.FilteredPeaks[i].Mass >= Xmin + 10.0f && GS.FilteredPeaks[i].Mass <= Xmax + 10.0f) { if (GS.FilteredPeaks[i].Intensity > YMax) { YMax = GS.FilteredPeaks[i].Intensity; } } } for (int i = 0; i < GS.FilteredPeaks.Count; i++) { if (GS.FilteredPeaks[i].Mass >= Xmin + 10.0f && GS.FilteredPeaks[i].Mass <= Xmax + 10.0f) { pplPeak.Add(GS.FilteredPeaks[i].Mass, GS.FilteredPeaks[i].Intensity / YMax * 100.0f); } } ZedGraph.GraphPane Pane = zedSequence.GraphPane; Pane.XAxis.MajorTic.IsInside = false; Pane.XAxis.MinorTic.IsInside = false; Pane.CurveList.Clear(); Pane.AddStick("Peaks", pplPeak, Color.Red); //Pane.XAxis.Scale.Min = Xmin - 10; //Pane.XAxis.Scale.Max = Xmax + 10; Pane.Title.Text = "No. " + txtScanNo.Text + "; Y1 m/z:" + argStructure.Y1.Mass.ToString("0.000");//+ " Structure:" + Convert.ToString(dgView.Rows[e.RowIndex].Cells[0].Value); Pane.AxisChange(); double YLevel = YMax; double outX, outY, outY2, diff; Pane.ReverseTransform(new Point(100, 100), out outX, out outY); Pane.ReverseTransform(new Point(100, 110), out outX, out outY2); diff = outY - outY2; GlycanTreeNode GT = argStructure.Root;//GS.GlycanTrees[e.RowIndex]; //Peak Interval //List<string> SeqList = new List<string>(); //for (int i = 0; i < GT.GetSequencingMapList().Count; i++) //{ // //Split the string // string[] strArray = GT.GetSequencingMapList()[i].Split('-'); // ZedGraph.TextObj TxtObg = new ZedGraph.TextObj(); // TxtObg.Text = strArray[1]; // double Start = Convert.ToDouble(strArray[0]); // double End = Convert.ToDouble(strArray[2]); // System.Drawing.Drawing2D.DashStyle LineStyle = DashStyle.Solid; // if (Start == 0) // { // if (strArray[1] == "HexNAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge); // } // else if (strArray[1] == "DeHex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge); // } // else if (strArray[1] == "Hex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge); // } // else if (strArray[1] == "NeuAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge); // } // else // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge); // } // TxtObg.Text = TxtObg.Text + "?"; // LineStyle = DashStyle.Dash; // } // else // { // if (strArray[1] == "HexNAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge); // } // else if (strArray[1] == "DeHex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge); // } // else if (strArray[1] == "Hex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge); // } // else if (strArray[1] == "NeuAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge); // } // else // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge); // } // } // if (End == 0) // { // if (strArray[1] == "HexNAc") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge); // } // else if (strArray[1] == "DeHex") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge); // } // else if (strArray[1] == "Hex") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge); // } // else if (strArray[1] == "NeuAc") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge); // } // else // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge); // } // TxtObg.Text = TxtObg.Text + "?"; // LineStyle = DashStyle.Dash; // } // //Determine the Y level // int Ylevel = 0; // if (SeqList.Count == 0) // { // SeqList.Add(Start.ToString() + "," + End.ToString() + ",0"); // } // else // { // for (int j = i - 1; j >= 0; j--) // { // double PreStart = Convert.ToDouble(SeqList[j].Split(',')[0]); // double PreEnd = Convert.ToDouble(SeqList[j].Split(',')[1]); // int Prelevel = Convert.ToInt32(SeqList[j].Split(',')[2]); // if ((PreStart <= Start && Start <= PreEnd)) // { // if (Math.Abs(PreEnd - Start) <= 10.0) // { // Ylevel = Prelevel; // break; // } // else // { // Ylevel = Prelevel + 1; // break; // } // } // } // SeqList.Add(Start.ToString() + "," + End.ToString() + "," + Ylevel.ToString()); // } // TxtObg.FontSpec.Size = TxtObg.FontSpec.Size * 0.8f; // YLevel = YMax + diff * Ylevel; // ZedGraph.LineObj Lne = new ZedGraph.LineObj(Start, YLevel + diff, Start, YLevel - diff); //Left V Line // Pane.GraphObjList.Add(Lne); // Lne = new ZedGraph.LineObj(End, YLevel + diff, End, YLevel - diff); //Right V Line // Pane.GraphObjList.Add(Lne); // Lne = new ZedGraph.LineObj(Start, YLevel, End, YLevel); //Add Line // Lne.Line.Style = LineStyle; // Pane.GraphObjList.Add(Lne); // //ZedGraph.ArrowObj arr= new ZedGraph.ArrowObj(Start, YLevel, End, YLevel); // //arr.IsArrowHead = true; // //arr.Line.Style = LineStyle; // //Pane.GraphObjList.Add(arr); // TxtObg.Location = new ZedGraph.Location(((Start + End) / 2), (double)YLevel, ZedGraph.CoordType.AxisXYScale); // TxtObg.FontSpec.Border.IsVisible = false; // TxtObg.Location.AlignH = ZedGraph.AlignH.Center; // TxtObg.Location.AlignV = ZedGraph.AlignV.Center; // Pane.GraphObjList.Insert(0, TxtObg); //} /////Annotation GlycansDrawer GDraw; double previousX2 = 0; List <GlycanTreeNode> Fragements = argStructure.Root.FetchAllGlycanNode(); Fragements.Sort(delegate(GlycanTreeNode T1, GlycanTreeNode T2) { return(Comparer <float> .Default.Compare(T1.IDMass, T2.IDMass)); }); foreach (GlycanTreeNode FGS in Fragements) { string Exp = argStructure.GetIUPACfromParentToNodeID(FGS.NodeID); //Queue<string> tmpQue = new Queue<string>(); //for (int i = 0; i < Exp.Length; i++) //{ // int NodeID = 0; // if (Exp[i].StartsWith("(") || Exp[i].StartsWith(")")) // { // NodeID = Convert.ToInt32(Exp[i].Split(',')[0].Substring(1)); // } // else // { // NodeID = Convert.ToInt32(Exp[i].Split(',')[0]); // } // if (NodeID > FGS.NodeID) // { // if (Exp[i].StartsWith("(") || Exp[i].StartsWith(")")) // { // tmpQue.Enqueue(Exp[i].Substring(0, 1)); // // } // } // else // { // tmpQue.Enqueue(Exp[i]); // } //} //string IUPAC = ""; //do //{ // string tmp =tmpQue.Dequeue(); // if(tmp == "(" && tmpQue.Peek() == ")" ) // { // } //}while(tmpQue.Count!=0) string tmpIUPAC = argStructure.GetSequqncedIUPACwNodeID(FGS.NodeID); GDraw = new GlycansDrawer(tmpIUPAC); float glycopeptideMZ = FGS.IDMass; if (double.IsNaN(glycopeptideMZ)) { continue; } Image imgStructure = RotateImage(GDraw.GetImage(), 270); double PositionX = glycopeptideMZ; if (previousX2 >= PositionX) { PositionX = previousX2 + 20; } ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width * 0.3f, imgStructure.Height * 0.3f); glycan.IsScaled = true; glycan.Location.AlignV = ZedGraph.AlignV.Bottom; Pane.GraphObjList.Add(glycan); ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 140); txtGlycanMz.Location.X = Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X1 + (Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2 - Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X1) / 2; txtGlycanMz.FontSpec.Size = txtGlycanMz.FontSpec.Size * 0.5f; txtGlycanMz.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMz); if (Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2 > Pane.GraphObjList[Pane.GraphObjList.Count - 2].Location.X2) { previousX2 = Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2; } else { previousX2 = Pane.GraphObjList[Pane.GraphObjList.Count - 2].Location.X2; } } Pane.AxisChange(); Pane.YAxis.Scale.Max = 145; Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100); Pane.XAxis.Scale.Max = pplPeak[pplPeak.Count - 1].X + 100; //////////// //Glycan Structure on the Right Top Header //////////// GDraw = new GlycansDrawer(argStructure.IUPACString, false); Image imgStruc = GDraw.GetImage(); ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, 0.01f, 0.01f, imgStruc.Width, imgStruc.Height); fullStructure.IsScaled = false; Pane.GraphObjList.Add(fullStructure); Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.CoordinateFrame = ZedGraph.CoordType.PaneFraction; zedSequence.AxisChange(); zedSequence.Refresh(); }