Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization/3.2/XAxis.cs @ 2830

Last change on this file since 2830 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
RevLine 
[987]1using System.Drawing;
[1964]2using HeuristicLab.Visualization.Drawing;
[1194]3using HeuristicLab.Visualization.LabelProvider;
[987]4
[983]5namespace HeuristicLab.Visualization {
[1038]6  public class XAxis : WorldShape {
[1182]7    public const int PixelsPerInterval = 100;
[1993]8
[1194]9    private ILabelProvider labelProvider = new ContinuousLabelProvider("0.####");
[983]10
[1337]11    private Color color = Color.Blue;
12    private Font font = new Font("Arial", 8);
[1462]13    private bool showLabel = true;
14    private string label = "";
[1337]15
[1182]16    public ILabelProvider LabelProvider {
17      get { return labelProvider; }
18      set { labelProvider = value; }
[1038]19    }
[987]20
[1240]21    public override void Draw(Graphics graphics) {
22      ClearShapes();
[987]23
[1240]24      foreach (double x in AxisTicks.GetTicks(PixelsPerInterval, Parent.Viewport.Width,
[1233]25                                              ClippingArea.Width,
26                                              ClippingArea.X1)) {
[1462]27        TextShape tickLabel = new TextShape(x, ClippingArea.Height - 3,
[1993]28                                            labelProvider.GetLabel(x), Font, Color);
[1462]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);
[1182]38        label.AnchorPositionX = AnchorPositionX.Middle;
[1462]39        label.AnchorPositionY = AnchorPositionY.Bottom;
40
[1240]41        AddShape(label);
[987]42      }
[1038]43
[1240]44      base.Draw(graphics);
[987]45    }
[1337]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    }
[1462]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    }
[983]66  }
67}
Note: See TracBrowser for help on using the repository browser.