public void SetThreshold(double?value) { if (value.HasValue) { if (m_Threshold == null) { m_Threshold = new LineObj(Color.Red, 0, value.Value, 1, value.Value) { Location = { CoordinateFrame = CoordType.XChartFractionYScale }, IsClippedToChartRect = true }; GraphObjList.Add(m_Threshold); } else { m_Threshold.Location.Y = value.Value; } } else { GraphObjList.Remove(m_Threshold); m_Threshold = null; } m_Parent.UpdateGraph(); }
private void AddAnnotations(Graphics g) { foreach (GraphObj obj in _pointAnnotations) { TextObj text = obj as TextObj; if (text != null) { if (text.Location.CoordinateFrame == CoordType.ChartFraction && text.Location.AlignH == AlignH.Left && text.Location.AlignV == AlignV.Top) { GraphObjList.Add(text); continue; } if (isXChartFractionObject(text) && (text.Location.X < XAxis.Scale.Min || text.Location.X > XAxis.Scale.Max)) { continue; } var textRect = _labelBoundsCache.GetLabelBounds(text, this, g); if (_overlapDetector == null || !_overlapDetector.Overlaps(textRect)) { _manualLabels[text] = textRect; } } else if (!GraphObjList.Contains(obj)) // always add non-text annotations { GraphObjList.Add(obj); } } }
public override void UpdateGraph(bool selectionChanged) { GraphObjList.Clear(); CurveList.Clear(); Legend.IsVisible = false; if (!DetectionPlotData.GetDataCache().TryGet( GraphSummary.DocumentUIContainer.DocumentUI, Settings.QValueCutoff, this.DataCallback, out _detectionData)) { return; } AddLabels(); BarSettings.Type = BarType.SortedOverlay; BarSettings.MinClusterGap = 0.3f; //draw bars var countPoints = new PointPairList(Enumerable.Range(0, _detectionData.ReplicateCount) .Select(i => new PointPair(i, TargetData.Histogram[i] / YScale)).ToList()); CurveList.Insert(0, MakeBarItem(countPoints, Color.FromArgb(180, 220, 255))); //axes formatting XAxis.Scale.Max = _detectionData.ReplicateCount + 1; YAxis.Scale.Max = TargetData.Histogram.Max() / YScale * 1.15; }
public MSGraphPane(MSGraphPane other) : base(other) { _currentItemType = other._currentItemType; _pointAnnotations = new GraphObjList(); _manualLabels = new Dictionary <TextObj, RectangleF>(); _labelBoundsCache = other._labelBoundsCache; }
/// <summary> /// 设置memo /// </summary> /// <param name="gl"></param> public void SetTextObj(GraphObjList gl) { zed1.GraphPane.GraphObjList = gl; foreach (var a in zed1.GraphPane.GraphObjList) { ((TextObj)a).FontSpec.FontColor = Color.Black; } }
public override void Draw(Graphics g) { GraphObjList.Clear(); // Force Axes to recalculate to ensure proper layout of labels AxisChange(g); base.Draw(g); }
private void AddDotProductLabels(Graphics g, TransitionGroupDocNode nodeGroup, IList <double> sumAreas) { // Create temporary label to calculate positions var pointSize = GetDotProductsPointSize(g); bool visible = pointSize.HasValue; bool visibleState = _dotpLabels.Count > 0; if (visible == visibleState && (!visibleState || ((TextObj)_dotpLabels[0]).FontSpec.Size == pointSize)) { return; } foreach (GraphObj pa in _dotpLabels) { GraphObjList.Remove(pa); } _dotpLabels.Clear(); if (visible) { // x shift of the dot product labels var xShift = 1; if (IsExpectedVisible) { // shift dot product labels over by 1 more, if library is visible xShift++; } for (int i = 0; i < sumAreas.Count; i++) { string text = GetDotProductResultsText(nodeGroup, i); if (string.IsNullOrEmpty(text)) { continue; } TextObj textObj = new TextObj(text, i + xShift, sumAreas[i], CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom) { IsClippedToChartRect = true, ZOrder = ZOrder.F_BehindGrid, }; textObj.FontSpec.Border.IsVisible = false; textObj.FontSpec.Size = pointSize.Value; _lableHeight = (int)textObj.FontSpec.GetHeight(CalcScaleFactor()); GraphObjList.Add(textObj); _dotpLabels.Add(textObj); } } }
public override void Draw(Graphics g) { GraphObjList.Clear(); if (_graphData != null) { // Force Axes to recalculate to ensure proper layout of labels AxisChange(g); // Reposition the regression label. RectangleF rectChart = Chart.Rect; PointF ptTop = rectChart.Location; // Setup axes scales to enable the ReverseTransform method XAxis.Scale.SetupScaleData(this, XAxis); YAxis.Scale.SetupScaleData(this, YAxis); float yNext = ptTop.Y; double left = XAxis.Scale.ReverseTransform(ptTop.X + 8); FontSpec fontSpec = GraphSummary.CreateFontSpec(COLOR_LINE_REGRESSION); if (_labelRegression != null) { // Add regression text double top = YAxis.Scale.ReverseTransform(yNext); TextObj text = new TextObj(_labelRegression, left, top, CoordType.AxisXYScale, AlignH.Left, AlignV.Top) { IsClippedToChartRect = true, ZOrder = ZOrder.E_BehindCurves, FontSpec = fontSpec, }; // text.FontSpec.Size = 12; GraphObjList.Add(text); } if (_labelRegressionCurrent != null) { // Add text for current regression SizeF sizeLabel = fontSpec.MeasureString(g, _labelRegression, CalcScaleFactor()); yNext += sizeLabel.Height + 3; double top = YAxis.Scale.ReverseTransform(yNext); TextObj text = new TextObj(_labelRegressionCurrent, left, top, CoordType.AxisXYScale, AlignH.Left, AlignV.Top) { IsClippedToChartRect = true, ZOrder = ZOrder.E_BehindCurves, FontSpec = GraphSummary.CreateFontSpec(COLOR_LINE_REGRESSION_CURRENT), }; // text.FontSpec.Size = 12; GraphObjList.Add(text); } } base.Draw(g); }
public override void Draw(Graphics g) { GraphObjList.Clear(); YAxis.Scale.Min = 0.0; AxisChange(g); AddLabels(g); base.Draw(g); }
public void removeCrosshair() { if (xLine == null) { return; } GraphObjList.Remove(xLine); GraphObjList.Remove(yLine); xLine = null; yLine = null; }
private void SetMappedItem(string itemID) { if (m_MappedItem == itemID) { return; } GraphObjList.Clear(); CurveItem item = GetCurve(m_MappedItem); if (item != null) { item.IsVisible = true; } m_MappedItem = itemID; item = CurveList[itemID]; if (item != null) { item.IsVisible = false; List <GraphObj> objects = new List <GraphObj>(); for (int index = 0; index < item.Points.Count; index++) { PointPair point = item[index]; LineObj line = new LineObj(Color.Gray, point.X, 0, point.X, 1); line.Tag = point.Y; line.Location.CoordinateFrame = CoordType.XScaleYChartFraction; line.ZOrder = ZOrder.E_BehindCurves; TextObj text = new TextObj(point.Y.ToString(), point.X, 1); text.Location.CoordinateFrame = CoordType.XScaleYChartFraction; text.IsClippedToChartRect = false; text.FontSpec.Border.IsVisible = false; text.Location.AlignV = AlignV.Bottom; text.Location.AlignH = AlignH.Right; text.FontSpec.Angle = -90; text.FontSpec.Fill.IsVisible = false; objects.Add(line); objects.Add(text); } GraphObjList.AddRange(objects); } m_HasChanged = true; m_Parent.UpdateGraph(); }
public override void Draw(Graphics g) { GraphObjList.Clear(); var data = Data; if (data != null && RTGraphController.PlotType == PlotTypeRT.correlation) { // Force Axes to recalculate to ensure proper layout of labels AxisChange(g); data.AddLabels(this, g); } base.Draw(g); }
public void addEquity(Simulator simulator) { Bomb.when(Objects.hasContent(equity), () => "equity has content already: " + Objects.toShortString(equity)); equity.AddRange(simulator.equity(symbol)); var points = new PointPairList(); Objects.eachIt(simulator.equity(symbol), (i, value) => points.Add(i + 1, value)); var curve = AddCurve("equity", points, Color.Red); curve.Symbol.IsVisible = false; curve.IsOverrideOrdinal = true; var zero = new LineObj(Color.Gray, 1, 0, bars.count(), 0) { Line = { Style = DashStyle.Dash }, Location = { CoordinateFrame = CoordType.AxisXYScale } }; GraphObjList.Add(zero); AxisChange(); var graphable = new EquityGraphable("equity", simulator.equity(symbol), simulator.dates(symbol)); graphables.Add(graphable); var needsNewPoint = false; bars.pushedDown += () => needsNewPoint = true; bars.valueSet += bar => { var value = simulator.pnl(symbol); var todaysMarketPnl = Objects.sum(Objects.convert(simulator.positions(symbol), position => position.pnl(bars[1].close, bars[0].close))); value += todaysMarketPnl; graphable.add(bar.time, value); QControl.runOnGuiThread(dispatchTo, () => { var lastPoint = curve[curve.Points.Count - 1]; if (needsNewPoint) { curve.AddPoint(lastPoint.X + 1, value); equity.Add(value); } else { lastPoint.Y = value; equity[equity.Count - 1] = value; } BarSpudGraph.addEquityTo(Objects.first(parentTyped.dataTable().Rows), value); needsNewPoint = false; parentTyped.Invalidate(); }); }; }
public MSGraphPane() { Title.IsVisible = false; Chart.Border.IsVisible = false; Y2Axis.IsVisible = false; X2Axis.IsVisible = false; XAxis.MajorTic.IsOpposite = false; YAxis.MajorTic.IsOpposite = false; XAxis.MinorTic.IsOpposite = false; YAxis.MinorTic.IsOpposite = false; IsFontsScaled = false; YAxis.Scale.MaxGrace = 0.1; _currentItemType = MSGraphItemType.unknown; _pointAnnotations = new GraphObjList(); }
private void AddOriginalPeakAnnotation(ChromPeak bestPeak, GraphObjList annotations, GraphPane graphPane) { var start = ScaleRetentionTime(bestPeak.StartTime); var end = ScaleRetentionTime(bestPeak.EndTime); var width = end.DisplayTime - start.DisplayTime; var height = graphPane.YAxis.Scale.Max; var originalPeakShadingBox = new BoxObj(start.DisplayTime, graphPane.YAxis.Scale.Max, width, height) { Fill = new Fill(Color.FromArgb(30, COLOR_ORIGINAL_PEAK_SHADE)), ZOrder = ZOrder.F_BehindGrid, Border = new Border { IsVisible = false }, IsClippedToChartRect = true, Tag = new GraphObjTag(this, GraphObjType.original_peak_shading, start, end) }; annotations.Add(originalPeakShadingBox); }
public override void Draw(Graphics g) { GraphObjList.Clear(); YAxis.Scale.Min = 0.0; AxisChange(g); foreach (var l in _lineItems) { if (l != null) { l[0].X = XAxis.Scale.Min; l[1].X = XAxis.Scale.Max; } } base.Draw(g); }
private void AddLabels(Graphics g) { if (_areaCVGraphData == null) { Title.Text = Resources.AreaCVHistogramGraphPane_AddLabels_Calculating____; } else if (!_areaCVGraphData.IsValid) { Title.Text = Resources.AreaCVHistogramGraphPane_AddLabels_Not_enough_data; } else { Title.Text = string.Empty; var unit = _percentage ? @"%" : string.Empty; var factor = _percentage ? 100.0 : 1.0; var scaleFactor = CalcScaleFactor(); var fontHeight = GraphSummary.CreateFontSpec(Color.Black).GetHeight(scaleFactor); var height = PaneHeightToYValue(fontHeight); // Anchor labels at top of graph pane var y = Math.Min(PaneHeightToYValue(Rect.Height - TitleGap * Title.FontSpec.GetHeight(scaleFactor) - fontHeight * _stickItems.Count), _areaCVGraphData.MaxFrequency + height); var index = 0; if (Settings.Default.AreaCVShowMedianCV) { _stickItems[index++].Points[1].Y = y; string text = string.Format(Resources.AreaCVHistogramGraphPane_AddLabels_Median___0_, HistogramHelper.FormatDouble(_areaCVGraphData.MedianCV * factor, _decimals) + unit); GraphObjList.Add(AddLabel(text, _areaCVGraphData.MedianCV * factor, y, Color.Blue)); y += height; } if (Settings.Default.AreaCVShowCVCutoff) { _stickItems[index++].Points[1].Y = y; string text = string.Format(Resources.AreaCVHistogramGraphPane_UpdateGraph_Below__0____1_, Settings.Default.AreaCVCVCutoff + unit, HistogramHelper.FormatDouble(_areaCVGraphData.BelowCVCutoff * factor, _decimals) + unit); GraphObjList.Add(AddLabel(text, Settings.Default.AreaCVCVCutoff, y, Color.Red)); } } }
public MSGraphPane(LabelBoundsCache labelBoundsCache = null) { Title.IsVisible = false; Chart.Border.IsVisible = false; Y2Axis.IsVisible = false; X2Axis.IsVisible = false; XAxis.MajorTic.IsOpposite = false; YAxis.MajorTic.IsOpposite = false; XAxis.MinorTic.IsOpposite = false; YAxis.MinorTic.IsOpposite = false; IsFontsScaled = false; YAxis.Scale.MaxGrace = 0.1; YAxis.MajorGrid.IsZeroLine = false; // Hide the y=0 line LockYAxisAtZero = true; _currentItemType = MSGraphItemType.unknown; _pointAnnotations = new GraphObjList(); _manualLabels = new Dictionary <TextObj, RectangleF>(); _labelBoundsCache = labelBoundsCache ?? new LabelBoundsCache(); }
void addCrosshair(float x, float y) { Bomb.unlessNull(xLine, () => "addCrosshair called twice without removeCrossHair"); Bomb.unlessNull(yLine, () => "addCrosshair called twice without removeCrossHair"); var chartPoint = point(x, y); xLine = new LineObj(Color.Gray, chartPoint.X, 0, chartPoint.X, 1) { Location = { CoordinateFrame = CoordType.XScaleYChartFraction } }; yLine = new LineObj(Color.Gray, 0, chartPoint.Y, 1, chartPoint.Y) { Location = { CoordinateFrame = CoordType.XChartFractionYScale } }; Objects.each(Objects.list(xLine, yLine), line => { line.ZOrder = ZOrder.E_BehindCurves; line.Line.Style = DashStyle.Dash; }); GraphObjList.Add(xLine); GraphObjList.Add(yLine); }
private void AddRetentionTimeAnnotation(MSGraphPane graphPane, Graphics g, GraphObjList annotations, PointF ptTop, string title, GraphObjType graphObjType, Color color, ScaledRetentionTime retentionTime) { // ReSharper disable LocalizableElement string label = string.Format("{0}\n{1:F01}", title, retentionTime.DisplayTime); // ReSharper restore LocalizableElement 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); }
/// <summary> /// Get all annotation label text, for testing purposes /// </summary> public IEnumerable <string> GetAnnotationLabelStrings() { foreach (CurveItem item in CurveList) { var info = item.Tag as IMSGraphItemExtended; if (info == null || string.IsNullOrEmpty(info.ToString())) { continue; } var points = item.Points as MSPointList; if (points == null) { continue; } var listAnnotations = new GraphObjList(); info.AddPreCurveAnnotations(this, null, points, listAnnotations); foreach (var annotation in listAnnotations) { var textObj = annotation as TextObj; if (textObj != null) { yield return(textObj.Text); } } foreach (var pt in points.FullList) { var annotation = info.AnnotatePoint(pt); if (annotation != null) { yield return(annotation.Label); } } } }
private void AddSelection(int selectedReplicateIndex, double maxRetentionTime, double minRetentionTime) { bool selectLines = CurveList.Any(c => c is LineItem); if (selectLines) { GraphObjList.Add(new LineObj(Color.Black, selectedReplicateIndex + 1, 0, selectedReplicateIndex + 1, maxRetentionTime) { IsClippedToChartRect = true, Line = new Line { Width = 2, Color = Color.Black, Style = DashStyle.Dash } }); } else { GraphObjList.Add(new BoxObj(selectedReplicateIndex + .5, maxRetentionTime, 1, maxRetentionTime - minRetentionTime, Color.Black, Color.Empty) { IsClippedToChartRect = true, }); } }
public override void AddPreCurveAnnotations(MSGraphPane graphPane, Graphics g, MSPointList pointList, GraphObjList annotations) { if (Chromatogram == null) { return; } // Give priority to showing the best peak text object above all other annotations if (DragInfo != null || (!HideBest && TransitionChromInfo != null) || CurveAnnotation != null) { // Show text and arrow for the best peak double intensityBest = 0; if (_bestPeakTimeIndex != -1) { ScaledRetentionTime timeBest = new ScaledRetentionTime(_measuredTimes[_bestPeakTimeIndex], _displayTimes[_bestPeakTimeIndex]); float xBest = graphPane.XAxis.Scale.Transform(timeBest.DisplayTime); intensityBest = _intensities[_bestPeakTimeIndex]; float yBest = graphPane.YAxis.Scale.Transform(intensityBest); if (GraphChromatogram.ShowRT != ShowRTChrom.none || DragInfo != null) { // Best peak gets its own label to avoid curve overlap detection double intensityLabel = graphPane.YAxis.Scale.ReverseTransform(yBest - 5); float? massError = Settings.Default.ShowMassError && TransitionChromInfo != null ? TransitionChromInfo.MassError : null; double dotProduct = _dotProducts != null ? _bestProduct : 0; TextObj text; if (CurveAnnotation != null) { // Darken peptide name a little so light colors stand out against the white background. var color = FontSpec.FontColor; if (!GraphInfo.IsSelected) { color = Color.FromArgb(color.R * 7 / 10, color.G * 7 / 10, color.B * 7 / 10); } var fontSpec = new FontSpec(FontSpec) { FontColor = color, Angle = 90 }; if (GraphInfo.IsSelected) { fontSpec = new FontSpec(fontSpec) { IsBold = true, Size = fontSpec.Size + 2, IsAntiAlias = true } } ; // Display peptide name label using vertical text. text = new TextObj(CurveAnnotation, timeBest.DisplayTime, intensityLabel, CoordType.AxisXYScale, AlignH.Left, AlignV.Center) { ZOrder = ZOrder.A_InFront, IsClippedToChartRect = true, FontSpec = fontSpec, Tag = new GraphObjTag(this, GraphObjType.best_peak, timeBest), }; } else { string label = FormatTimeLabel(timeBest.DisplayTime, massError, dotProduct); text = new TextObj(label, timeBest.DisplayTime, intensityLabel, CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom) { ZOrder = ZOrder.A_InFront, IsClippedToChartRect = true, FontSpec = FontSpec, Tag = new GraphObjTag(this, GraphObjType.best_peak, timeBest), }; } annotations.Add(text); } // If showing multiple peptides, skip the best peak arrow indicator. if (CurveAnnotation == null) { // Show the best peak arrow indicator double timeArrow = graphPane.XAxis.Scale.ReverseTransform(xBest - 4); double intensityArrow = graphPane.YAxis.Scale.ReverseTransform(yBest - 2); ArrowObj arrow = new ArrowObj(COLOR_BEST_PEAK, 12f, timeArrow, intensityArrow, timeArrow, intensityArrow) { Location = { CoordinateFrame = CoordType.AxisXYScale }, IsArrowHead = true, IsClippedToChartRect = true, ZOrder = ZOrder.A_InFront }; annotations.Add(arrow); } } // Show the best peak boundary lines if (CurveAnnotation == null) { double startTime = 0, endTime = 0; if (DragInfo != null) { startTime = DragInfo.StartTime.MeasuredTime; endTime = DragInfo.EndTime.MeasuredTime; } else if (TransitionChromInfo != null) { var tranPeakInfo = TransitionChromInfo; startTime = tranPeakInfo.StartRetentionTime; endTime = tranPeakInfo.EndRetentionTime; } AddPeakBoundaries(graphPane, annotations, true, ScaleRetentionTime(startTime), ScaleRetentionTime(endTime), intensityBest); } if (Chromatogram.BestPeakIndex >= 0) { // Only shade peak when user modified. Otherwise, shading can be added when an entire // precursor was force integrated because of another precursor (e.g. heavy) since that // leads to an empty peak, which will not match the best peak. if (Settings.Default.ShowOriginalPeak && TransitionChromInfo != null && TransitionChromInfo.IsUserModified) { var bestPeak = Chromatogram.GetPeak(Chromatogram.BestPeakIndex); if (bestPeak.StartTime != TransitionChromInfo.StartRetentionTime || bestPeak.EndTime != TransitionChromInfo.EndRetentionTime) { AddOriginalPeakAnnotation(bestPeak, annotations, graphPane); } } } } if (_displayRawTimes.HasValue) { AddPeakRawTimes(graphPane, annotations, ScaleRetentionTime(_displayRawTimes.Value.StartBound), ScaleRetentionTime(_displayRawTimes.Value.EndBound), Chromatogram); } }
public abstract void AddPreCurveAnnotations(MSGraphPane graphPane, Graphics g, MSPointList pointList, GraphObjList annotations);
public override void AddPreCurveAnnotations(MSGraphPane graphPane, Graphics g, MSPointList pointList, GraphObjList annotations) { // Do nothing }
public override void UpdateGraph(bool selectionChanged) { Clear(); TransitionGroupDocNode selectedGroup = null; PeptideGroupDocNode selectedProtein = null; var selectedTreeNode = GraphSummary.StateProvider.SelectedNode as SrmTreeNode; if (selectedTreeNode != null) { if (selectedTreeNode is TransitionTreeNode) { selectedGroup = (TransitionGroupDocNode)selectedTreeNode.SrmParent.Model; } else if (selectedTreeNode is TransitionGroupTreeNode) { selectedGroup = (TransitionGroupDocNode)selectedTreeNode.Model; } else { var node = selectedTreeNode as PeptideTreeNode; if (node != null) { var nodePep = node.DocNode; selectedGroup = nodePep.TransitionGroups.FirstOrDefault(); } } var proteinTreeNode = selectedTreeNode.GetNodeOfType <PeptideGroupTreeNode>(); if (proteinTreeNode != null) { selectedProtein = proteinTreeNode.DocNode; } } SrmDocument document = GraphSummary.DocumentUIContainer.DocumentUI; var displayType = GraphChromatogram.GetDisplayType(document, selectedTreeNode); _graphData = CreateGraphData(document, selectedProtein, selectedGroup, displayType); int iColor = 0; int colorOffset = 0; if (selectedGroup != null && displayType == DisplayTypeChrom.products) { // If we are only displaying product ions, we want to use an offset in the colors array // so that we do not re-use colors that would be used for any precursor ions. colorOffset = GraphChromatogram.GetDisplayTransitions(selectedGroup, DisplayTypeChrom.precursors).Count(); } foreach (var pointPairList in _graphData.PointPairLists) { Color color = displayType == DisplayTypeChrom.total ? COLORS_GROUPS[iColor++ % COLORS_GROUPS.Count] : COLORS_TRANSITION[(iColor++ + colorOffset) % COLORS_TRANSITION.Count]; BarItem curveItem; if (HiLowMiddleErrorBarItem.IsHiLoMiddleErrorList(pointPairList)) { curveItem = new HiLowMiddleErrorBarItem(string.Empty, pointPairList, color, Color.Black); } else { curveItem = new MeanErrorBarItem(string.Empty, pointPairList, color, Color.Black); } curveItem.Bar.Border.IsVisible = false; curveItem.Bar.Fill.Brush = new SolidBrush(color); CurveList.Add(curveItem); } if (ShowSelection && SelectedIndex != -1) { double yValue = _graphData.SelectedMaxY; double yMin = _graphData.SelectedMinY; double height = yValue - yMin; GraphObjList.Add(new BoxObj(SelectedIndex + .5, yValue, 0.99, height, Color.Black, Color.Empty) { IsClippedToChartRect = true, }); } UpdateAxes(); }
public void Clear() { Data = null; CurveList.Clear(); GraphObjList.Clear(); }
/// <summary> /// Constructor for deserializing objects /// </summary> /// <param name="info">A <see c_ref="SerializationInfo"/> instance that defines the serialized data /// </param> /// <param name="context">A <see c_ref="StreamingContext"/> instance that contains the serialized data /// </param> protected PaneBase( SerializationInfo info, StreamingContext context ) { // The schema value is just a file version parameter. You can use it to make future versions // backwards compatible as new member variables are added to classes int sch = info.GetInt32( "schema" ); _rect = (RectangleF) info.GetValue( "rect", typeof(RectangleF) ); _legend = (Legend) info.GetValue( "legend", typeof(Legend) ); _title = (GapLabel) info.GetValue( "title", typeof(GapLabel) ); //this.isShowTitle = info.GetBoolean( "isShowTitle" ); _isFontsScaled = info.GetBoolean( "isFontsScaled" ); _isPenWidthScaled = info.GetBoolean( "isPenWidthScaled" ); //this.fontSpec = (FontSpec) info.GetValue( "fontSpec" , typeof(FontSpec) ); _titleGap = info.GetSingle( "titleGap" ); _fill = (Fill) info.GetValue( "fill", typeof(Fill) ); _border = (Border) info.GetValue( "border", typeof(Border) ); _baseDimension = info.GetSingle( "baseDimension" ); _margin = (Margin)info.GetValue( "margin", typeof( Margin ) ); _graphObjList = (GraphObjList) info.GetValue( "graphObjList", typeof(GraphObjList) ); _tag = info.GetValue( "tag", typeof(object) ); }
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 (MidasRetentionMsMs != null) { foreach (var retentionTime in MidasRetentionMsMs) { var color = SelectedRetentionMsMs.HasValue && Equals((float)retentionTime, (float)SelectedRetentionMsMs) ? ColorSelected : COLOR_MSMSID_TIME; AddRetentionTimeAnnotation(graphPane, g, annotations, ptTop, string.Empty, GraphObjType.midas_spectrum, 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); } }
/// <summary> /// We know which labels are overlapping the data points, but we need to make sure the labels that will be /// displayed can fit in the scale using the Min/MaxGrace properties and adjusting the label fractions if appropriate: /// TextObjs with CoordType.AxisXYScale coordinates will move proportionally with Min/MaxGrace, but ChartFraction /// coordinates will not. /// </summary> protected void autoScaleForManualLabels(Graphics g) { Axis yAxis = YAxis; bool maxAuto = yAxis.Scale.MaxAuto; try { if (maxAuto) { AxisChange(g); } double yMaxRequired = 0; foreach (var kvp in _manualLabels) { TextObj text = kvp.Key; if (text.Location.X < XAxis.Scale.Min || text.Location.X > XAxis.Scale.Max) { continue; } if (!YAxis.Scale.IsLog && !IsYChartFractionObject(text)) { double axisHeight = YAxis.Scale.Max - YAxis.Scale.Min; PointF[] pts = text.FontSpec.GetBox(g, text.Text, 0, 0, text.Location.AlignH, text.Location.AlignV, 1.0f, new SizeF()); float pixelShift = 0; var rectPeak = _labelBoundsCache.GetLabelBounds(text, this, g); foreach (var id in _manualLabels.Keys.Where(IsYChartFractionObject)) { var rectID = _labelBoundsCache.GetLabelBounds(id, this, g); // If the rectangles overlap if (Math.Min(rectID.Right, rectPeak.Right) - Math.Max(rectID.Left, rectPeak.Left) > 0 && Math.Min(rectID.Bottom, rectPeak.Bottom) - Math.Max(rectID.Top, rectPeak.Top) > 0) { pixelShift = Math.Max(rectID.Height + 7, pixelShift); // 7 pixel gap between labels } } double y2Pos = yAxis.Scale.ReverseTransform(pts[2].Y); double labelHeight = Math.Abs(yAxis.Scale.ReverseTransform(pts[0].Y - pixelShift) - y2Pos); // If separating the labels takes too much space, just revert to showing them aligned if (labelHeight >= axisHeight / 2) { labelHeight = Math.Abs(yAxis.Scale.ReverseTransform(pts[0].Y) - y2Pos); } if (labelHeight < axisHeight / 2) { // Ensure that the YAxis will have enough space to show the label. // Only do this if the labelHeight is going to take up less than half the space on the graph, because // otherwise the graph will be shrunk too much to have any useful information. // When calculating the scaling required, take into account that the height of the label // itself will not shrink when we shrink the YAxis. var labelYMaxRequired = (text.Location.Y - labelHeight * YAxis.Scale.Min / axisHeight) / (1 - labelHeight / axisHeight); yMaxRequired = Math.Max(yMaxRequired, labelYMaxRequired); } } if (!GraphObjList.Any( o => (o is TextObj) && ((TextObj)o).Location == text.Location && ((TextObj)o).Text == text.Text)) { if (_pointAnnotations.Contains(text)) { GraphObjList.Add(text); } } } if (maxAuto && yMaxRequired > 0) { yAxis.Scale.Max = Math.Max(yAxis.Scale.Max, yMaxRequired); } } finally { // Reset the value of MaxAuto since it may have been changed to false when Scale.Max was changed. yAxis.Scale.MaxAuto = maxAuto; } }
/// <summary> /// Default constructor for the <see c_ref="PaneBase"/> class. Specifies the <see c_ref="Title"/> of /// the <see c_ref="PaneBase"/>, and the size of the <see c_ref="Rect"/>. /// </summary> public PaneBase( string title, RectangleF paneRect ) { _rect = paneRect; _legend = new Legend(); _baseDimension = Default.BaseDimension; _margin = new Margin(); _titleGap = Default.TitleGap; _isFontsScaled = Default.IsFontsScaled; _isPenWidthScaled = Default.IsPenWidthScaled; _fill = new Fill( Default.FillColor ); _border = new Border( Default.IsBorderVisible, Default.BorderColor, Default.BorderPenWidth ); _title = new GapLabel( title, Default.FontFamily, Default.FontSize, Default.FontColor, Default.FontBold, Default.FontItalic, Default.FontUnderline ); _title._fontSpec.Fill.IsVisible = false; _title._fontSpec.Border.IsVisible = false; _graphObjList = new GraphObjList(); _tag = null; }
public void AddAnnotations(MSGraphPane graphPane, Graphics g, MSPointList pointList, GraphObjList annotations) { }
/// <summary> /// The Copy Constructor /// </summary> /// <param name="rhs">The <see c_ref="PaneBase"/> object from which to copy</param> public PaneBase( PaneBase rhs ) { // copy over all the value types _isFontsScaled = rhs._isFontsScaled; _isPenWidthScaled = rhs._isPenWidthScaled; _titleGap = rhs._titleGap; _baseDimension = rhs._baseDimension; _margin = rhs._margin.Clone(); _rect = rhs._rect; // Copy the reference types by cloning _fill = rhs._fill.Clone(); _border = rhs._border.Clone(); _title = rhs._title.Clone(); _legend = rhs.Legend.Clone(); _title = rhs._title.Clone(); _graphObjList = rhs._graphObjList.Clone(); if ( rhs._tag is ICloneable ) _tag = ((ICloneable) rhs._tag).Clone(); else _tag = rhs._tag; }