Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/VisualGenealogyGraphTextLabel.cs @ 12002

Last change on this file since 12002 was 9963, checked in by bburlacu, 11 years ago

#1772: Merged changes from the trunk and other branches. Added new ExtendedSymbolicExpressionTreeCanvas control for the visual exploration of tree genealogies. Reorganized some files and folders.

File size: 1.7 KB
Line 
1using System.Drawing;
2using HeuristicLab.Visualization;
3using Rectangle = HeuristicLab.Visualization.Rectangle;
4
5namespace HeuristicLab.EvolutionaryTracking.Views {
6  public class VisualGenealogyGraphTextLabel : Rectangle {
7    private string text;
8    public string Text { get { return text; } set { text = value; } }
9
10    private Font font;
11    public Font Font { get { return font; } set { font = value; } }
12
13    private Brush fontBrush;
14    public Brush FontBrush { get { return fontBrush; } set { fontBrush = value; } }
15
16    public VisualGenealogyGraphTextLabel(IChart chart, PointD lowerLeft, PointD upperRight)
17      : base(chart, lowerLeft, upperRight) {
18    }
19    public VisualGenealogyGraphTextLabel(IChart chart, double x1, double y1, double x2, double y2)
20      : this(chart, new PointD(x1, y1), new PointD(x2, y2)) {
21    }
22    public VisualGenealogyGraphTextLabel(IChart chart, PointD lowerLeft, PointD upperRight, Pen pen, Brush brush)
23      : base(chart, lowerLeft, upperRight, pen, brush) {
24    }
25    public VisualGenealogyGraphTextLabel(IChart chart, double x1, double y1, double x2, double y2, Pen pen, Brush brush)
26      : this(chart, new PointD(x1, y1), new PointD(x2, y2), pen, brush) {
27    }
28
29    public override void Draw(Graphics graphics) {
30      Point p = Chart.TransformWorldToPixel(new PointD(LowerLeft.X, LowerLeft.Y + Size.Height));
31      Size s = Chart.TransformWorldToPixel(Size);
32
33      float fontSize = s.Height;
34      font = new Font(font.Name, fontSize, Font.Style, GraphicsUnit.Pixel);
35      graphics.DrawString(text, font, fontBrush, p.X, p.Y);
36    }
37
38    protected override void OnUpdate() {
39      if ((UpdateEnabled)) {
40        base.OnUpdate();
41      }
42    }
43  }
44}
Note: See TracBrowser for help on using the repository browser.