Free cookie consent management tool by TermsFeed Policy Generator

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

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