Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Operator Architecture Refactoring/HeuristicLab.Visualization/3.2/XAxis.cs @ 2173

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

moved the canvas and the basic types of shapes to their own namespace. #498

File size: 2.0 KB
Line 
1
2using System.Drawing;
3using HeuristicLab.Visualization.Drawing;
4using HeuristicLab.Visualization.LabelProvider;
5
6namespace HeuristicLab.Visualization {
7  public class XAxis : WorldShape {
8    public const int PixelsPerInterval = 100;
9   
10    private ILabelProvider labelProvider = new ContinuousLabelProvider("0.####");
11
12    private Color color = Color.Blue;
13    private Font font = new Font("Arial", 8);
14    private bool showLabel = true;
15    private string label = "";
16
17    public ILabelProvider LabelProvider {
18      get { return labelProvider; }
19      set { labelProvider = value; }
20    }
21
22    public override void Draw(Graphics graphics) {
23      ClearShapes();
24
25      foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, Parent.Viewport.Width,
26                                              ClippingArea.Width,
27                                              ClippingArea.X1)) {
28        TextShape tickLabel = new TextShape(x, ClippingArea.Height - 3,
29                                        labelProvider.GetLabel(x), Font, Color);
30        tickLabel.AnchorPositionX = AnchorPositionX.Middle;
31        tickLabel.AnchorPositionY = AnchorPositionY.Top;
32        AddShape(tickLabel);
33      }
34
35      if (showLabel) {
36        TextShape label = new TextShape(ClippingArea.X1 + ClippingArea.Width/2,
37                                        ClippingArea.Y1 + 3,
38                                        this.label);
39        label.AnchorPositionX = AnchorPositionX.Middle;
40        label.AnchorPositionY = AnchorPositionY.Bottom;
41
42        AddShape(label);
43      }
44
45      base.Draw(graphics);
46    }
47
48    public Color Color {
49      get { return color; }
50      set { color = value; }
51    }
52
53    public Font Font {
54      get { return font; }
55      set { font = value; }
56    }
57
58    public bool ShowLabel {
59      get { return showLabel; }
60      set { showLabel = value; }
61    }
62
63    public string Label {
64      get { return label; }
65      set { label = value; }
66    }
67  }
68}
Note: See TracBrowser for help on using the repository browser.