Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/YAxis.cs @ 1457

Last change on this file since 1457 was 1457, checked in by mstoeger, 15 years ago

Implement Y-Axis Position (left/right) (#554)

File size: 1.6 KB
Line 
1using System;
2using System.Drawing;
3using HeuristicLab.Visualization.LabelProvider;
4using HeuristicLab.Visualization.Test;
5
6namespace HeuristicLab.Visualization {
7  public class YAxis : WorldShape {
8    public const int PixelsPerInterval = 75;
9
10    private ILabelProvider labelProvider = new ContinuousLabelProvider("e4");
11    private AxisPosition position = AxisPosition.Left;
12
13    public ILabelProvider LabelProvider {
14      get { return labelProvider; }
15      set { labelProvider = value; }
16    }
17
18    public AxisPosition Position {
19      get { return position; }
20      set { position = value; }
21    }
22
23    public override void Draw(Graphics graphics) {
24      ClearShapes();
25
26      foreach (double y in AxisTicks.GetTicks(PixelsPerInterval, Parent.Viewport.Height,
27                                              ClippingArea.Height,
28                                              ClippingArea.Y1)) {
29        double x;
30        AnchorPositionX anchorPositionX;
31
32        switch (position) {
33          case AxisPosition.Left:
34            x = ClippingArea.X2 - 3;
35            anchorPositionX = AnchorPositionX.Right;
36            break;
37          case AxisPosition.Right:
38            x = ClippingArea.X1 + 3;
39            anchorPositionX = AnchorPositionX.Left;
40            break;
41          default:
42            throw new NotImplementedException();
43        }
44       
45        TextShape label = new TextShape(x, y, labelProvider.GetLabel(y));
46        label.AnchorPositionX = anchorPositionX;
47        label.AnchorPositionY = AnchorPositionY.Middle;
48        AddShape(label);
49      }
50
51      base.Draw(graphics);
52    }
53  }
54}
Note: See TracBrowser for help on using the repository browser.