コード例 #1
0
		public NumericLabelFormattingAuto(NumericLabelFormattingAuto from)
			: base(from) // everything is done here, since CopyFrom is virtual
		{
		}
コード例 #2
0
        public override IMeasuredLabelItem[] GetMeasuredItems(IGraphicsContext3D g, FontX3D font, AltaxoVariant[] items)
        {
            var litems = new MeasuredLabelItem[items.Length];

            var localfont1 = font;
            var localfont2 = font.WithSize(font.Size * 2 / 3);

            string[] firstp = new string[items.Length];
            string[] middel = new string[items.Length];
            string[] expos  = new string[items.Length];
            double[] mants  = new double[items.Length];

            double maxexposize  = 0;
            int    firstpartmin = int.MaxValue;
            int    firstpartmax = int.MinValue;

            for (int i = 0; i < items.Length; ++i)
            {
                string firstpart, exponent;
                if (items[i].IsType(Altaxo.Data.AltaxoVariant.Content.VDouble))
                {
                    SplitInFirstPartAndExponent(items[i], out firstpart, out mants[i], out middel[i], out exponent);
                    if (exponent.Length > 0)
                    {
                        firstpartmin = Math.Min(firstpartmin, firstpart.Length);
                        firstpartmax = Math.Max(firstpartmax, firstpart.Length);
                    }
                }
                else
                {
                    firstpart = items[i].ToString();
                    middel[i] = string.Empty;
                    exponent  = string.Empty;
                }
                firstp[i]   = firstpart;
                expos[i]    = exponent;
                maxexposize = Math.Max(maxexposize, g.MeasureString(exponent, localfont2, PointD3D.Empty).X);
            }

            if (firstpartmax > 0 && firstpartmax > firstpartmin) // then we must use special measures to equilibrate the mantissa
            {
                firstp = NumericLabelFormattingAuto.FormatItems(mants);
            }

            for (int i = 0; i < items.Length; ++i)
            {
                string mid = string.Empty;
                if (!string.IsNullOrEmpty(expos[i]))
                {
                    if (string.IsNullOrEmpty(firstp[i]))
                    {
                        mid = "10";
                    }
                    else
                    {
                        mid = "\u00D710";
                    }
                }
                litems[i] = new MeasuredLabelItem(g, localfont1, localfont2, _prefix + firstp[i] + mid, expos[i], _suffix, maxexposize);
            }

            return(litems);
        }
コード例 #3
0
 public NumericLabelFormattingAuto(NumericLabelFormattingAuto from)
     : base(from) // everything is done here, since CopyFrom is virtual
 {
 }