コード例 #1
0
        private void CreateTicks()
        {
            TickCountChange result = TickCountChange.OK;
            TickCountChange prevResult;

            int prevActualTickCount = -1;

            int tickCount = previousTickCount;
            int iteration = 0;

            do
            {
                Verify.IsTrue(++iteration < maxTickArrangeIterations);

                ticksInfo = ticksProvider.GetTicks(range, tickCount);
                ticks     = ticksInfo.Ticks;

                if (ticks.Length == prevActualTickCount)
                {
                    result = TickCountChange.OK;
                    break;
                }

                prevActualTickCount = ticks.Length;

                labels = labelProvider.CreateLabels(ticksInfo);

                prevResult = result;
                result     = CheckLabelsArrangement(labels, ticks);

                if (prevResult == TickCountChange.Decrease && result == TickCountChange.Increase)
                {
                    // stop tick number oscillating
                    result = TickCountChange.OK;
                }

                if (result != TickCountChange.OK)
                {
                    int prevTickCount = tickCount;
                    if (result == TickCountChange.Decrease)
                    {
                        tickCount = ticksProvider.DecreaseTickCount(tickCount);
                    }
                    else
                    {
                        tickCount = ticksProvider.IncreaseTickCount(tickCount);
                        //DebugVerify.Is(tickCount >= prevTickCount);
                    }

                    // ticks provider could not create less ticks or tick number didn't change
                    if (tickCount == 0 || prevTickCount == tickCount)
                    {
                        tickCount = prevTickCount;
                        result    = TickCountChange.OK;
                    }
                }
            } while (result != TickCountChange.OK);

            previousTickCount = tickCount;
        }
コード例 #2
0
        public int DecreaseTickCount(int ticksCount)
        {
            if (majorTicks.Length > 0)
            {
                ticksCount /= majorTicks.Length;
            }

            int minorTicksCount = provider.DecreaseTickCount(ticksCount);

            if (majorTicks.Length > 0)
            {
                minorTicksCount *= majorTicks.Length;
            }

            return(minorTicksCount);
        }
コード例 #3
0
 public int DecreaseTickCount(int ticksCount)
 {
     return(MinorTicksProvider.DecreaseTickCount(ticksCount));
 }
コード例 #4
0
        private void DoDrawMinorTicks(GeometryGroup geomGroup)
        {
            ITicksProvider <T> minorTicksProvider = ticksProvider.MinorProvider;

            if (minorTicksProvider != null)
            {
                int            minorTicksCount      = DefaultTicksProvider.DefaultTicksCount;
                int            prevActualTicksCount = -1;
                ITicksInfo <T> minorTicks;
                TickChange     result = TickChange.OK;
                TickChange     prevResult;
                int            iteration = 0;
                //PerformanceCounter.startStopwatch("Minor ticks: computing tickCounts");
                do
                {
                    Verify.IsTrue(++iteration < maxTickArrangeIterations);

                    minorTicks = minorTicksProvider.GetTicks(range, minorTicksCount);

                    prevActualTicksCount = minorTicks.Ticks.Length;
                    prevResult           = result;
                    result = CheckMinorTicksArrangement(minorTicks);
                    if (prevResult == TickChange.Decrease && result == TickChange.Increase)
                    {
                        // stop tick number oscillating
                        result = TickChange.OK;
                    }
                    if (result == TickChange.Decrease)
                    {
                        int newMinorTicksCount = minorTicksProvider.DecreaseTickCount(minorTicksCount);
                        if (newMinorTicksCount == minorTicksCount)
                        {
                            result = TickChange.OK;
                        }
                        minorTicksCount = newMinorTicksCount;
                    }
                    else if (result == TickChange.Increase)
                    {
                        int newCount = minorTicksProvider.IncreaseTickCount(minorTicksCount);
                        if (newCount == minorTicksCount)
                        {
                            result = TickChange.OK;
                        }
                        minorTicksCount = newCount;
                    }
                } while (result != TickChange.OK);
                //PerformanceCounter.stopStopwatch("Minor ticks: computing tickCounts");

                minorTicks = minorTicksProvider.GetTicks(range, minorTicksCount);


                double[] sizes = minorTicks.TickSizes;

                double[] screenCoords = minorTicks.Ticks.Select(
                    coord => getCoordinate(createDataPoint(convertToDouble(coord)).
                                           ToScreen(converter))).ToArray();

                minorScreenTicks = new MinorTickInfo <double> [screenCoords.Length];
                for (int i = 0; i < screenCoords.Length; i++)
                {
                    minorScreenTicks[i] = new MinorTickInfo <double>(sizes[i], screenCoords[i]);
                }

                for (int i = 0; i < screenCoords.Length; i++)
                {
                    double screenCoord = screenCoords[i];
                    if (i + usedTicks < allocatedTicks)
                    {
                        //PerformanceCounter.startStopwatch("Minor ticks: getting allocated lines");
                        LineGeometry line = allocatedTicksList[i + usedTicks];
                        //PerformanceCounter.stopStopwatch("Minor ticks: getting allocated lines");
                        //PerformanceCounter.startStopwatch("Minor ticks: renewing allocated lines");
                        line.StartPoint = createScreenPoint1(screenCoord);;
                        line.EndPoint   = createScreenPoint2(screenCoord, sizes[i]);
                        //PerformanceCounter.stopStopwatch("Minor ticks: renewing allocated lines");
                    }
                    else
                    {
                        //PerformanceCounter.startStopwatch("Minor ticks: creating new lines");
                        LineGeometry line = new LineGeometry();
                        line.StartPoint = createScreenPoint1(screenCoord);;
                        line.EndPoint   = createScreenPoint2(screenCoord, sizes[i]);
                        geomGroup.Children.Add(line);
                        allocatedTicksList.Add(line);
                        //PerformanceCounter.stopStopwatch("Minor ticks: creating new lines");
                    }
                }
                usedTicks += screenCoords.Length;
            }
        }
コード例 #5
0
        private void DoDrawMinorTicks(GeometryGroup geomGroup)
        {
            ITicksProvider <T> minorTicksProvider = ticksProvider.MinorProvider;

            if (minorTicksProvider != null)
            {
                int             minorTicksCount      = prevMinorTicksCount;
                int             prevActualTicksCount = -1;
                ITicksInfo <T>  minorTicks;
                TickCountChange result = TickCountChange.OK;
                TickCountChange prevResult;
                int             iteration = 0;
                do
                {
                    Verify.IsTrue(++iteration < maxTickArrangeIterations);

                    minorTicks = minorTicksProvider.GetTicks(range, minorTicksCount);

                    prevActualTicksCount = minorTicks.Ticks.Length;
                    prevResult           = result;
                    result = CheckMinorTicksArrangement(minorTicks);
                    if (prevResult == TickCountChange.Decrease && result == TickCountChange.Increase)
                    {
                        // stop tick number oscillating
                        result = TickCountChange.OK;
                    }
                    if (result == TickCountChange.Decrease)
                    {
                        int newMinorTicksCount = minorTicksProvider.DecreaseTickCount(minorTicksCount);
                        if (newMinorTicksCount == minorTicksCount)
                        {
                            result = TickCountChange.OK;
                        }
                        minorTicksCount = newMinorTicksCount;
                    }
                    else if (result == TickCountChange.Increase)
                    {
                        int newCount = minorTicksProvider.IncreaseTickCount(minorTicksCount);
                        if (newCount == minorTicksCount)
                        {
                            result = TickCountChange.OK;
                        }
                        minorTicksCount = newCount;
                    }
                } while (result != TickCountChange.OK);
                prevMinorTicksCount = minorTicksCount;

                double[] sizes = minorTicks.TickSizes;

                double[] screenCoords = minorTicks.Ticks.Select(
                    coord => getCoordinate(createDataPoint(convertToDouble(coord)).
                                           DataToScreen(transform))).ToArray();

                minorScreenTicks = new MinorTickInfo <double> [screenCoords.Length];
                for (int i = 0; i < screenCoords.Length; i++)
                {
                    minorScreenTicks[i] = new MinorTickInfo <double>(sizes[i], screenCoords[i]);
                }

                for (int i = 0; i < screenCoords.Length; i++)
                {
                    double screenCoord = screenCoords[i];

                    Point p1 = createScreenPoint1(screenCoord);
                    Point p2 = createScreenPoint2(screenCoord, sizes[i]);

                    LineGeometry line = new LineGeometry(p1, p2);
                    geomGroup.Children.Add(line);
                }
            }
        }
コード例 #6
0
        private void CreateTicks()
        {
            TickChange result = TickChange.OK;
            TickChange prevResult;

            int prevActualTickCount = -1;

            int  tickCount            = DefaultTicksProvider.DefaultTicksCount;
            int  iteration            = 0;
            bool stopTicksCountTuning = false;

            do
            {
                Verify.IsTrue(++iteration < maxTickArrangeIterations);

                ticksInfo = ticksProvider.GetTicks(range, tickCount);
                ticks     = ticksInfo.Ticks;

                if (ticks.Length == prevActualTickCount)
                {
                    result = TickChange.OK;
                    break;
                }

                prevActualTickCount = ticks.Length;

                labels = labelProvider.CreateLabels(ticksInfo);

                prevResult = result;
                if (tickCount > TicksUpperConstraint)
                {
                    result = TickChange.Decrease;
                }
                else
                {
                    result = CheckLabelsArrangement(labels, ticks);
                }

                if (prevResult == TickChange.Decrease && result == TickChange.Increase)
                {
                    // stop tick number oscillating
                    result = TickChange.OK;
                }

                if (result != TickChange.OK)
                {
                    int prevTickCount = tickCount;
                    if (result == TickChange.Decrease)
                    {
                        tickCount = ticksProvider.DecreaseTickCount(tickCount);
                    }
                    else
                    {
                        tickCount = ticksProvider.IncreaseTickCount(tickCount);
                        DebugVerify.Is(tickCount >= prevTickCount);
                    }

                    // ticks provider cannot create less ticks or tick number didn't change
                    if (tickCount == 0 || prevTickCount == tickCount)
                    {
                        tickCount = prevTickCount;
                        result    = TickChange.OK;
                    }
                }
                ticksGenNumber = tickCount;
            } while (result != TickChange.OK && !stopTicksCountTuning);
        }