Analyzer.DConnectorMotifDetector.SetDConnectorMotifSpanScale C# (CSharp) Method

SetDConnectorMotifSpanScale() protected method

protected SetDConnectorMotifSpanScale ( ICollection oDConnectorMotifs ) : void
oDConnectorMotifs ICollection
return void
        protected void SetDConnectorMotifSpanScale (ICollection<Motif> oDConnectorMotifs)
        {
            Debug.Assert(oDConnectorMotifs != null);

            // The SpanScale property is the DConnectorMotif's span count scaled
            // between 0 and 1.0, based on the minimum and maximum span counts
            // among all DConnectorMotifs.

            Int32 iMinimumSpanCount = 0;
            Int32 iMaximumSpanCount = 0;

            if (oDConnectorMotifs.Count > 0)
            {
                iMinimumSpanCount = oDConnectorMotifs.Min(
                    oMotif => ((DConnectorMotif)oMotif).SpanVertices.Count);

                iMaximumSpanCount = oDConnectorMotifs.Max(
                    oMotif => ((DConnectorMotif)oMotif).SpanVertices.Count);
            }

            foreach (DConnectorMotif oDConnectorMotif in oDConnectorMotifs)
            {
                Single fSpanScale;

                if (iMinimumSpanCount == iMaximumSpanCount)
                {
                    // All the span counts are the same.  Arbitrarily set the
                    // SpanScale property to the center of the range.

                    fSpanScale = 0.5F;
                }
                else
                {
                    fSpanScale = MathUtil.TransformValueToRange(
                        oDConnectorMotif.SpanVertices.Count,
                        iMinimumSpanCount, iMaximumSpanCount,
                        0F, 1.0F
                        );
                }

                oDConnectorMotif.SpanScale = fSpanScale;
            }
        }