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