Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/AxisTicks.cs @ 1352

Last change on this file since 1352 was 1233, checked in by mstoeger, 16 years ago

General housekeeping (#498) Removed some old unused Z-Order values. Replaced some var types by concrete types. Renamed some LineShape properties. Added caching of Pens and Brushes in LineShape and RectangleShape. Put axis tick calculation algorithm into its own class.

File size: 765 bytes
Line 
1using System;
2using System.Collections.Generic;
3
4namespace HeuristicLab.Visualization {
5  public static class AxisTicks {
6    public static IEnumerable<double> GetTicks(int pixelsPerInterval, int screenSize, double worldSize, double worldStart) {
7      int intervals = screenSize/pixelsPerInterval;
8
9      if (intervals > 0) {
10        double step = worldSize/intervals;
11        step = Math.Pow(10, Math.Floor(Math.Log10(step)));
12        if (worldSize/(step*5) > intervals)
13          step = step*5;
14        else if (worldSize/(step*2) > intervals)
15          step = step*2;
16
17        for (double x = Math.Floor(worldStart/step)*step;
18             x <= worldStart + worldSize;
19             x += step)
20          yield return x;
21      }
22    }
23  }
24}
Note: See TracBrowser for help on using the repository browser.