public void Paint(Graphics g, IPlotArea layer, Processed2DPlotData pdata, Processed2DPlotData prevItemData, Processed2DPlotData nextItemData) { // adjust the skip frequency if it was not set appropriate if (_skipFreq <= 0) { _skipFreq = 1; } if (_scatterSymbol is NoSymbol) { return; } var cachedPathData = new CachedPathData(); var cachedBrushData = new CachedBrushData(); PlotRangeList rangeList = pdata.RangeList; PointF[] plotPositions = pdata.PlotPointsInAbsoluteLayerCoordinates; if (!_independentOnShiftingGroupStyles && (0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY)) { plotPositions = Processed2DPlotData.GetPlotPointsInAbsoluteLayerCoordinatesWithShift(pdata, layer, _cachedLogicalShiftX, _cachedLogicalShiftY); } // Calculate current scatterSymbol overridden with frame and inset var scatterSymbol = CalculateOverriddenScatterSymbol(); if (_ignoreMissingDataPoints) { // in case we ignore the missing points, all ranges can be plotted // as one range, i.e. continuously // for this, we create the totalRange, which contains all ranges var totalRange = new PlotRangeCompound(rangeList); PaintOneRange(g, layer, plotPositions, totalRange, scatterSymbol, ref cachedPathData, ref cachedBrushData); } else // we not ignore missing points, so plot all ranges separately { for (int i = 0; i < rangeList.Count; i++) { PaintOneRange(g, layer, plotPositions, rangeList[i], scatterSymbol, ref cachedPathData, ref cachedBrushData); } } cachedBrushData.Clear(); cachedPathData.Clear(); }
public RectangleF PaintSymbol(System.Drawing.Graphics g, System.Drawing.RectangleF bounds) { if (_scatterSymbol is NoSymbol) { return(bounds); } var cachedPathData = new CachedPathData(); var cachedBrushData = new CachedBrushData(); var scatterSymbol = CalculateOverriddenScatterSymbol(); CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); GraphicsState gs = g.Save(); g.TranslateTransform(bounds.X + 0.5f * bounds.Width, bounds.Y + 0.5f * bounds.Height); if (null != cachedPathData.InsetPath) { g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); } if (null != cachedPathData.FillPath) { g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); } if (null != cachedPathData.FramePath) { g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); } cachedBrushData.Clear(); cachedPathData.Clear(); g.Restore(gs); if (SymbolSize > bounds.Height) { bounds.Inflate(0, (float)(SymbolSize - bounds.Height)); } return(bounds); }
private void PaintOneRange( Graphics g, IPlotArea layer, PointF[] plotPositions, IPlotRange range, IScatterSymbol scatterSymbol, ref CachedPathData cachedPathData, ref CachedBrushData cachedBrushData) { var ptArray = plotPositions; float xpos = 0, ypos = 0; float xdiff, ydiff; int originalIndex; // save the graphics stat since we have to translate the origin System.Drawing.Drawing2D.GraphicsState gs = g.Save(); if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size { // calculate the path only once CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq) { xdiff = ptArray[plotPointIndex].X - xpos; ydiff = ptArray[plotPointIndex].Y - ypos; xpos = ptArray[plotPointIndex].X; ypos = ptArray[plotPointIndex].Y; g.TranslateTransform(xdiff, ydiff); if (null != cachedPathData.InsetPath) { g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); } if (null != cachedPathData.FillPath) { g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); } if (null != cachedPathData.FramePath) { g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); } } // end for } else // using a variable symbol size or variable symbol color { CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq) { originalIndex = range.GetOriginalRowIndexFromPlotPointIndex(plotPointIndex); if (null == _cachedColorForIndexFunction) { double customSymbolSize = _cachedSymbolSizeForIndexFunction(originalIndex); CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData); } else { double customSymbolSize = null == _cachedSymbolSizeForIndexFunction ? _symbolSize : _cachedSymbolSizeForIndexFunction(originalIndex); var customSymbolColor = _cachedColorForIndexFunction(originalIndex); CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B), cachedPathData, ref cachedBrushData); } xdiff = ptArray[plotPointIndex].X - xpos; ydiff = ptArray[plotPointIndex].Y - ypos; xpos = ptArray[plotPointIndex].X; ypos = ptArray[plotPointIndex].Y; g.TranslateTransform(xdiff, ydiff); if (null != cachedPathData.InsetPath) { g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); } if (null != cachedPathData.FillPath) { g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); } if (null != cachedPathData.FramePath) { g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); } } } g.Restore(gs); // Restore the graphics state }
/// <summary> /// Calculates the brushes. /// </summary> /// <param name="scatterSymbol">ScatterSymbol, already processed via <see cref="CalculateOverriddenScatterSymbol"/></param> /// <param name="plotColor">The current plot color.</param> /// <param name="cachedPathData">The cached path data.</param> /// <param name="cachedBrushData">Cached brush data, which will be filled-in during this call..</param> /// <returns>True if new cached brush data were calculated; false if the cached data were up-to-date.</returns> private bool CalculateBrushes(IScatterSymbol scatterSymbol, NamedColor plotColor, CachedPathData cachedPathData, ref CachedBrushData cachedBrushData) { if (plotColor == cachedBrushData.PlotColor) { return(false); // cached data valid and could be reused; } cachedBrushData.Clear(); cachedBrushData.PlotColor = plotColor; var plotColorInfluence = _overridePlotColorInfluence ?? scatterSymbol.PlotColorInfluence; if (null != cachedPathData.InsetPath) { var insetColor = _overrideInsetColor ?? scatterSymbol.Inset.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorFull)) { insetColor = plotColor; } else if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorPreserveAlpha)) { insetColor = plotColor.NewWithAlphaValue(insetColor.Color.A); } cachedBrushData.InsetBrush = new SolidBrush(insetColor); } if (null != cachedPathData.FillPath) { var fillColor = _overrideFillColor ?? scatterSymbol.FillColor; if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorFull)) { fillColor = plotColor; } else if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorPreserveAlpha)) { fillColor = plotColor.NewWithAlphaValue(fillColor.Color.A); } cachedBrushData.FillBrush = new SolidBrush(fillColor); } if (null != cachedPathData.FramePath) { var frameColor = _overrideFrameColor ?? scatterSymbol.Frame.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorFull)) { frameColor = plotColor; } else if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorPreserveAlpha)) { frameColor = plotColor.NewWithAlphaValue(frameColor.Color.A); } cachedBrushData.FrameBrush = new SolidBrush(frameColor); } return(true); }
public RectangleF PaintSymbol(System.Drawing.Graphics g, System.Drawing.RectangleF bounds) { if (_scatterSymbol is NoSymbol) return bounds; var cachedPathData = new CachedPathData(); var cachedBrushData = new CachedBrushData(); var scatterSymbol = CalculateOverriddenScatterSymbol(); CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); GraphicsState gs = g.Save(); g.TranslateTransform(bounds.X + 0.5f * bounds.Width, bounds.Y + 0.5f * bounds.Height); if (null != cachedPathData.InsetPath) g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); if (null != cachedPathData.FillPath) g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); if (null != cachedPathData.FramePath) g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); cachedBrushData.Clear(); cachedPathData.Clear(); g.Restore(gs); if (this.SymbolSize > bounds.Height) bounds.Inflate(0, (float)(this.SymbolSize - bounds.Height)); return bounds; }
public void Paint(Graphics g, IPlotArea layer, Processed2DPlotData pdata, Processed2DPlotData prevItemData, Processed2DPlotData nextItemData) { // adjust the skip frequency if it was not set appropriate if (_skipFreq <= 0) _skipFreq = 1; if (this._scatterSymbol is NoSymbol) return; CachedPathData cachedPathData = new CachedPathData(); CachedBrushData cachedBrushData = new CachedBrushData(); PlotRangeList rangeList = pdata.RangeList; PointF[] plotPositions = pdata.PlotPointsInAbsoluteLayerCoordinates; if (!_independentOnShiftingGroupStyles && (0 != _cachedLogicalShiftX || 0 != _cachedLogicalShiftY)) { plotPositions = Processed2DPlotData.GetPlotPointsInAbsoluteLayerCoordinatesWithShift(pdata, layer, _cachedLogicalShiftX, _cachedLogicalShiftY); } // Calculate current scatterSymbol overridden with frame and inset var scatterSymbol = CalculateOverriddenScatterSymbol(); if (this._ignoreMissingDataPoints) { // in case we ignore the missing points, all ranges can be plotted // as one range, i.e. continuously // for this, we create the totalRange, which contains all ranges var totalRange = new PlotRangeCompound(rangeList); this.PaintOneRange(g, layer, plotPositions, totalRange, scatterSymbol, ref cachedPathData, ref cachedBrushData); } else // we not ignore missing points, so plot all ranges separately { for (int i = 0; i < rangeList.Count; i++) { this.PaintOneRange(g, layer, plotPositions, rangeList[i], scatterSymbol, ref cachedPathData, ref cachedBrushData); } } cachedBrushData.Clear(); cachedPathData.Clear(); }
private void PaintOneRange( Graphics g, IPlotArea layer, PointF[] plotPositions, IPlotRange range, IScatterSymbol scatterSymbol, ref CachedPathData cachedPathData, ref CachedBrushData cachedBrushData) { var ptArray = plotPositions; float xpos = 0, ypos = 0; float xdiff, ydiff; int originalIndex; // save the graphics stat since we have to translate the origin System.Drawing.Drawing2D.GraphicsState gs = g.Save(); if (null == _cachedSymbolSizeForIndexFunction && null == _cachedColorForIndexFunction) // using a constant symbol size { // calculate the path only once CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq) { xdiff = ptArray[plotPointIndex].X - xpos; ydiff = ptArray[plotPointIndex].Y - ypos; xpos = ptArray[plotPointIndex].X; ypos = ptArray[plotPointIndex].Y; g.TranslateTransform(xdiff, ydiff); if (null != cachedPathData.InsetPath) g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); if (null != cachedPathData.FillPath) g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); if (null != cachedPathData.FramePath) g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); } // end for } else // using a variable symbol size or variable symbol color { CalculatePaths(scatterSymbol, _symbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, _color, cachedPathData, ref cachedBrushData); for (int plotPointIndex = range.LowerBound; plotPointIndex < range.UpperBound; plotPointIndex += _skipFreq) { originalIndex = range.GetOriginalRowIndexFromPlotPointIndex(plotPointIndex); if (null == _cachedColorForIndexFunction) { double customSymbolSize = _cachedSymbolSizeForIndexFunction(originalIndex); CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData); } else { double customSymbolSize = null == _cachedSymbolSizeForIndexFunction ? _symbolSize : _cachedSymbolSizeForIndexFunction(originalIndex); var customSymbolColor = _cachedColorForIndexFunction(originalIndex); CalculatePaths(scatterSymbol, customSymbolSize, ref cachedPathData); CalculateBrushes(scatterSymbol, NamedColor.FromArgb(customSymbolColor.A, customSymbolColor.R, customSymbolColor.G, customSymbolColor.B), cachedPathData, ref cachedBrushData); } xdiff = ptArray[plotPointIndex].X - xpos; ydiff = ptArray[plotPointIndex].Y - ypos; xpos = ptArray[plotPointIndex].X; ypos = ptArray[plotPointIndex].Y; g.TranslateTransform(xdiff, ydiff); if (null != cachedPathData.InsetPath) g.FillPath(cachedBrushData.InsetBrush, cachedPathData.InsetPath); if (null != cachedPathData.FillPath) g.FillPath(cachedBrushData.FillBrush, cachedPathData.FillPath); if (null != cachedPathData.FramePath) g.FillPath(cachedBrushData.FrameBrush, cachedPathData.FramePath); } } g.Restore(gs); // Restore the graphics state }
/// <summary> /// Calculates the brushes. /// </summary> /// <param name="scatterSymbol">ScatterSymbol, already processed via <see cref="CalculateOverriddenScatterSymbol"/></param> /// <param name="plotColor">The current plot color.</param> /// <param name="cachedPathData">The cached path data.</param> /// <param name="cachedBrushData">Cached brush data, which will be filled-in during this call..</param> /// <returns>True if new cached brush data were calculated; false if the cached data were up-to-date.</returns> private bool CalculateBrushes(IScatterSymbol scatterSymbol, NamedColor plotColor, CachedPathData cachedPathData, ref CachedBrushData cachedBrushData) { if (plotColor == cachedBrushData.PlotColor) return false; // cached data valid and could be reused; cachedBrushData.Clear(); cachedBrushData.PlotColor = plotColor; var plotColorInfluence = _overridePlotColorInfluence ?? scatterSymbol.PlotColorInfluence; if (null != cachedPathData.InsetPath) { var insetColor = _overrideInsetColor ?? scatterSymbol.Inset.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorFull)) insetColor = plotColor; else if (plotColorInfluence.HasFlag(PlotColorInfluence.InsetColorPreserveAlpha)) insetColor = plotColor.NewWithAlphaValue(insetColor.Color.A); cachedBrushData.InsetBrush = new SolidBrush(insetColor); } if (null != cachedPathData.FillPath) { var fillColor = _overrideFillColor ?? scatterSymbol.FillColor; if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorFull)) fillColor = plotColor; else if (plotColorInfluence.HasFlag(PlotColorInfluence.FillColorPreserveAlpha)) fillColor = plotColor.NewWithAlphaValue(fillColor.Color.A); cachedBrushData.FillBrush = new SolidBrush(fillColor); } if (null != cachedPathData.FramePath) { var frameColor = _overrideFrameColor ?? scatterSymbol.Frame.Color; if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorFull)) frameColor = plotColor; else if (plotColorInfluence.HasFlag(PlotColorInfluence.FrameColorPreserveAlpha)) frameColor = plotColor.NewWithAlphaValue(frameColor.Color.A); cachedBrushData.FrameBrush = new SolidBrush(frameColor); } return true; }