Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.2/sources/HeuristicLab.Visualization/3.2/XAxis.cs @ 12448

Last change on this file since 12448 was 1993, checked in by mstoeger, 16 years ago

added many new persisted properties.
removed useless comments.
added XmlSupport class since the code for setting xml attributes is always the same.
#639

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