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