Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1772: Improved the LineageExplorerView, added generation labels in the GenealogyGraphChart, added new visual component VisualGenealogyGraphTextLabel.

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