Пример #1
0
        private NumericSequence CalculateElementSequence(ScaleElementDefinition element, NumericScaleUnit defaultUnit)
        {
            double?interval = Scale <double, double, NumericScaleUnit> .GetInterval(element);

            double?intervalOffset = Scale <double, double, NumericScaleUnit> .GetIntervalOffset(element);

            NumericScaleUnit?intervalUnit = Scale <double, double, NumericScaleUnit> .GetIntervalUnit(element);

            NumericScaleUnit numericScaleUnit = intervalUnit.HasValue ? intervalUnit.Value : defaultUnit;
            int?maxCount1 = Scale <double, double, NumericScaleUnit> .GetMaxCount(element);

            int             maxCount2       = maxCount1.HasValue ? maxCount1.Value : this.MaxCount;
            NumericSequence numericSequence = (NumericSequence)null;

            switch (numericScaleUnit)
            {
            case NumericScaleUnit.Number:
                numericSequence = NumericSequence.Calculate(new NumericRangeInfo((DoubleR10)this.ActualViewMinimum, (DoubleR10)this.ActualViewMaximum), interval, intervalOffset, maxCount2, int.MinValue, (DoubleR10[])null, true, 1.0);
                break;

            case NumericScaleUnit.MajorInterval:
                numericSequence = interval.HasValue || intervalOffset.HasValue ? (NumericSequence)RelativeSequence.Calculate(this._majorSequence, interval, intervalOffset, 1.0) : this._majorSequence;
                break;

            case NumericScaleUnit.MinorInterval:
                numericSequence = interval.HasValue || intervalOffset.HasValue ? (NumericSequence)RelativeSequence.Calculate(this._minorSequence, interval, intervalOffset, 1.0) : this._minorSequence;
                break;
            }
            return(numericSequence);
        }
Пример #2
0
        public override void Recalculate()
        {
            this.CalculateActualProperties();
            this.RealizeCategories();
            NumericRangeInfo range = new NumericRangeInfo((DoubleR10)this.ActualViewMinimum, (DoubleR10)this.ActualViewMaximum);

            this._majorSequence = NumericSequence.Calculate(range, new double?(this.ActualMajorInterval), new double?(this.ActualMajorIntervalOffset), 1000, int.MinValue, (DoubleR10[])null, true, 1.0);
            this._minorSequence = NumericSequence.Calculate(range, new double?(this.ActualMinorInterval), new double?(this.ActualMinorIntervalOffset + 0.5), 1000, int.MinValue, (DoubleR10[])null, true, 1.0);
            base.Recalculate();
        }
Пример #3
0
        private void CalculateMajorSequence(int maxCount, double maxAllowedMargin)
        {
            switch (this.ActualMajorIntervalUnit)
            {
            case NumericScaleUnit.Number:
                this._majorSequence = NumericSequence.Calculate(this._rangeInfo, this.MajorInterval, this.MajorIntervalOffset, maxCount, this.GetMinPower(), (DoubleR10[])null, true, maxAllowedMargin);
                break;

            case NumericScaleUnit.MajorInterval:
                this._majorSequence = NumericSequence.Calculate(this._rangeInfo, new double?(), new double?(), maxCount, int.MinValue, (DoubleR10[])null, true, 1.0);
                this._majorSequence = (NumericSequence)RelativeSequence.Calculate(this._majorSequence, this.MajorInterval, this.MajorIntervalOffset, 1.0);
                break;

            case NumericScaleUnit.MinorInterval:
                this._majorSequence = (NumericSequence)RelativeSequence.Calculate(this._minorSequence, this.MajorInterval, this.MajorIntervalOffset, 5.0);
                break;
            }
        }
Пример #4
0
        public static DateTimeSequence CalculateCenturies(Range <DateTime> range, int?interval, int?intervalOffset, int maxCount)
        {
            NumericRangeInfo range1 = new NumericRangeInfo((DoubleR10)range.Minimum.Year, (DoubleR10)range.Maximum.Year);
            int?   nullable1        = interval;
            double?interval1        = nullable1.HasValue ? new double?((double)nullable1.GetValueOrDefault()) : new double?();
            int?   nullable2        = intervalOffset;
            double?intervalOffset1  = nullable2.HasValue ? new double?((double)nullable2.GetValueOrDefault()) : new double?();
            int    maxCount1        = maxCount;
            int    minPower         = 2;

            DoubleR10[] steps = new DoubleR10[3]
            {
                (DoubleR10)1,
                (DoubleR10)2,
                (DoubleR10)5
            };
            int              num = 1;
            double           maxAllowedMargin = 1.0;
            NumericSequence  numericSequence  = NumericSequence.Calculate(range1, interval1, intervalOffset1, maxCount1, minPower, steps, num != 0, maxAllowedMargin);
            DateTimeSequence dateTimeSequence = new DateTimeSequence(DateTimeScaleUnit.Years);

            try
            {
                foreach (DoubleR10 doubleR10 in numericSequence)
                {
                    int year = (int)doubleR10;
                    if (year > 0)
                    {
                        dateTimeSequence.Add(new DateTime(year, 1, 1));
                    }
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
            }
            dateTimeSequence.Interval       = numericSequence.Interval;
            dateTimeSequence.IntervalOffset = numericSequence.IntervalOffset;
            return(dateTimeSequence);
        }
Пример #5
0
        private IEnumerable <ScalePosition> Project(IList <Category> categories, ScaleElementDefinition element, CategoryScaleUnit defaultUnit)
        {
            this.RecalculateIfEmpty();
            double?interval1 = Scale <double, double, CategoryScaleUnit> .GetInterval(element);

            double?intervalOffset = Scale <double, double, CategoryScaleUnit> .GetIntervalOffset(element);

            CategoryScaleUnit?intervalUnit = Scale <double, double, CategoryScaleUnit> .GetIntervalUnit(element);

            double            interval2         = interval1.HasValue ? interval1.Value : 1.0;
            double            num1              = intervalOffset.HasValue ? intervalOffset.Value : 0.0;
            CategoryScaleUnit categoryScaleUnit = intervalUnit.HasValue ? intervalUnit.Value : defaultUnit;
            double            num2              = defaultUnit == CategoryScaleUnit.MinorInterval ? 0.5 : 0.0;
            NumericSequence   numericSequence   = defaultUnit == CategoryScaleUnit.MinorInterval ? this._minorSequence : this._majorSequence;
            NumericSequence   sequence          = (NumericSequence)null;
            NumericRangeInfo  range             = new NumericRangeInfo((DoubleR10)this.ActualMinimum, (DoubleR10)this.ActualMaximum);

            switch (categoryScaleUnit)
            {
            case CategoryScaleUnit.Index:
                sequence = interval2 != this.ActualMajorInterval || num1 != this.ActualMinorIntervalOffset ? NumericSequence.Calculate(range, new double?(interval2), new double?(num1 + num2), 100, int.MinValue, (DoubleR10[])null, true, 1.0) : numericSequence;
                break;

            case CategoryScaleUnit.MajorInterval:
                sequence = interval2 != this.ActualMajorInterval || num1 != this.ActualMajorIntervalOffset ? (NumericSequence)RelativeSequence.Calculate(this._majorSequence, new double?(interval2), new double?(num1), 1.0) : this._majorSequence;
                break;

            case CategoryScaleUnit.MinorInterval:
                sequence = interval2 != this.ActualMinorInterval || num1 != this.ActualMinorIntervalOffset ? (NumericSequence)RelativeSequence.Calculate(this._minorSequence, new double?(interval2), new double?(num1 + 0.5), 1.0) : this._minorSequence;
                break;
            }
            return(this.Project(categories, sequence, interval2));
        }