Changeset 1233 for trunk/sources/HeuristicLab.Visualization/XAxis.cs
- Timestamp:
- 02/28/09 21:21:59 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization/XAxis.cs
r1194 r1233 1 using System;2 using System.Collections.Generic;3 1 using System.Drawing; 4 2 using HeuristicLab.Visualization.LabelProvider; … … 7 5 public class XAxis : WorldShape { 8 6 public const int PixelsPerInterval = 100; 7 9 8 private ILabelProvider labelProvider = new ContinuousLabelProvider("0.####"); 10 9 … … 14 13 } 15 14 16 public static IEnumerable<double> GetTicks(int pixelsPerInterval, int screenSize, double worldSize, double worldStart) {17 int intervals = screenSize/pixelsPerInterval;18 19 if (intervals > 0) {20 double step = worldSize/intervals;21 step = Math.Pow(10, Math.Floor(Math.Log10(step)));22 if (worldSize/(step*5) > intervals)23 step = step*5;24 else if (worldSize/(step*2) > intervals)25 step = step*2;26 27 for (double x = Math.Floor(worldStart/step)*step;28 x <= worldStart + worldSize;29 x += step)30 yield return x;31 }32 }33 34 15 public override void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) { 35 16 shapes.Clear(); 36 17 37 foreach (double x in GetTicks(PixelsPerInterval, viewport.Width, ClippingArea.Width, ClippingArea.X1)) { 18 foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, viewport.Width, 19 ClippingArea.Width, 20 ClippingArea.X1)) { 38 21 TextShape label = new TextShape(x, ClippingArea.Height - 3, 39 22 labelProvider.GetLabel(x));
Note: See TracChangeset
for help on using the changeset viewer.