1 | using System.Drawing;
|
---|
2 | using HeuristicLab.Visualization.Drawing;
|
---|
3 | using HeuristicLab.Visualization.LabelProvider;
|
---|
4 |
|
---|
5 | namespace 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 | } |
---|