Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/XAxis.cs @ 1122

Last change on this file since 1122 was 1046, checked in by shofstad, 16 years ago

Legend implementation finished (#407)

File size: 1.0 KB
Line 
1using System.Collections.Generic;
2using System.Drawing;
3
4namespace HeuristicLab.Visualization {
5
6  public class XAxis : WorldShape {
7    private readonly IDictionary<int, TextShape> labels = new Dictionary<int, TextShape>();
8
9    public XAxis(RectangleD clippingArea, RectangleD boundingBox)
10      : base(clippingArea, boundingBox) {}
11
12    public void ClearLabels() {
13      labels.Clear();
14    }
15
16    public void SetLabel(int i, string text) {
17      labels[i] = new TextShape(i, 0, text);
18    }
19
20    public override void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
21      shapes.Clear();
22
23      for (int i = (int)(ClippingArea.X1 - 1); i <= ClippingArea.X2 + 1; i++) {
24        TextShape label;
25
26        if (labels.ContainsKey(i)) {
27          label = labels[i];
28        } else {
29          label = new TextShape(i, 0, i.ToString());
30        }
31
32        label.Y = ClippingArea.Height - 3;
33
34        shapes.Add(label);
35      }
36
37      base.Draw(graphics, viewport, clippingArea);
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.