Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/28/09 21:21:59 (16 years ago)
Author:
mstoeger
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/XAxis.cs

    r1194 r1233  
    1 using System;
    2 using System.Collections.Generic;
    31using System.Drawing;
    42using HeuristicLab.Visualization.LabelProvider;
     
    75  public class XAxis : WorldShape {
    86    public const int PixelsPerInterval = 100;
     7   
    98    private ILabelProvider labelProvider = new ContinuousLabelProvider("0.####");
    109
     
    1413    }
    1514
    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 
    3415    public override void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
    3516      shapes.Clear();
    3617
    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)) {
    3821        TextShape label = new TextShape(x, ClippingArea.Height - 3,
    3922                                        labelProvider.GetLabel(x));
Note: See TracChangeset for help on using the changeset viewer.