/// <summary>
 /// Creates a new instance of EditorSettings
 /// </summary>
 public EditorSettings()
 {
     _hsl = true;
     _useColor = true;
     _startColor = Global.ColorFromHSL(5, .7, .7);
     _endColor = Global.ColorFromHSL(345, .8, .8);
     _maxSampleCount = 10000;
     _intervalMethod = IntervalMethods.EqualInterval;
     _rampColors = true;
     _intervalSnapMethod = IntervalSnapMethods.Rounding;
     _intervalRoundingDigits = 0;
     _numBreaks = 5;
 }
示例#2
0
 /// <summary>
 /// Applies the snapping rule directly to the categories, instead of the breaks.
 /// </summary>
 public void ApplySnapping(IntervalSnapMethods method, int numDigits, List<double> values)
 {
     switch (method)
     {
         case IntervalSnapMethods.None:
             break;
         case IntervalSnapMethods.SignificantFigures:
             if (Maximum != null)
             {
                 int digits = numDigits;
                 double max = (double)Maximum;
                 int md = (int)Math.Ceiling(Math.Log10(max));
                 md -= digits;
                 double norm = Math.Pow(10, md);
                 double val = (double)Maximum;
                 Maximum = norm * Math.Round(val / norm);
             }
             if (Minimum != null)
             {
                 int digits = numDigits;
                 double min = (double)Minimum;
                 int md = (int)Math.Ceiling(Math.Log10(min));
                 md -= digits;
                 double norm = Math.Pow(10, md);
                 double val = (double)Minimum;
                 Minimum = norm * Math.Round(val / norm);
             }
             break;
         case IntervalSnapMethods.Rounding:
             if (Maximum != null)
             {
                 Maximum = Math.Round((double)Maximum, numDigits);
             }
             if (Minimum != null)
             {
                 Minimum = Math.Round((double)Minimum, numDigits);
             }
             break;
         case IntervalSnapMethods.DataValue:
             if (Maximum != null)
             {
                 Maximum = NearestValue((double)Maximum, values);
             }
             if (Minimum != null)
             {
                 Minimum = NearestValue((double)Minimum, values);
             }
             break;
     }
 }
示例#3
0
 private string Format(double value, IntervalSnapMethods method, int digits)
 {
     if (method == IntervalSnapMethods.None)
     {
         return value.ToString();
     }
     if (method == IntervalSnapMethods.DataValue)
     {
         return value.ToString();
     }
     if (method == IntervalSnapMethods.Rounding)
     {
         return value.ToString("N" + digits);
     }
     if (method == IntervalSnapMethods.SignificantFigures)
     {
         int dig = (int)Math.Ceiling(Math.Log10(value));
         dig = digits - dig;
         if (dig < 0) dig = 0;
         if (dig > 10)
         {
             return value.ToString("E" + digits);
         }
         return value.ToString("N" + dig);
     }
     return value.ToString("N");
 }
示例#4
0
 /// <summary>
 /// This is a slightly more complex specification where the numeric formatting
 /// controls how the generated string will appear.
 /// </summary>
 /// <param name="method">The interval snap method</param>
 /// <param name="digits">This is only used for rounding or significant figures, but controls those options</param>
 /// <returns>A string equivalent of this range, but using a number format.</returns>
 public string ToString(IntervalSnapMethods method, int digits)
 {
     
     if (_minimum == null && _maximum == null)
     {
         return "[All Values]";
     }
     if (_minimum == null)
     {
         string max = Format(_maximum.Value, method, digits);
         return _maxIsInclusive ? "<= " + max : "< " + max;
     }
     if (_maximum == null)
     {
         string min = Format(_minimum.Value, method, digits);
         return _minIsInclusive ? ">= " + min : "> " + min;
     }
     return Format(_minimum.Value, method, digits) + " - " + Format(_maximum.Value, method, digits);
 }
示例#5
0
 /// <summary>
 ///  Returns this Number as a string.
 /// </summary>
 /// <param name="method">Specifies how the numbers are modified so that the numeric text can be cleaned up.</param>
 /// <param name="digits">An integer clarifying digits for rounding or significant figure situations.</param>
 /// <returns>A string with the formatted number.</returns>
 public virtual string ToString(IntervalSnapMethods method, int digits)
 {
     return _range.ToString(method, digits);
 }