using System.Drawing; using HeuristicLab.Visualization; using Rectangle = HeuristicLab.Visualization.Rectangle; namespace HeuristicLab.EvolutionaryTracking.Views { public class VisualGenealogyGraphTextLabel : Rectangle { private string text; public string Text { get { return text; } set { text = value; } } private Font font; public Font Font { get { return font; } set { font = value; } } private Brush fontBrush; public Brush FontBrush { get { return fontBrush; } set { fontBrush = value; } } public VisualGenealogyGraphTextLabel(IChart chart, PointD lowerLeft, PointD upperRight) : base(chart, lowerLeft, upperRight) { } public VisualGenealogyGraphTextLabel(IChart chart, double x1, double y1, double x2, double y2) : this(chart, new PointD(x1, y1), new PointD(x2, y2)) { } public VisualGenealogyGraphTextLabel(IChart chart, PointD lowerLeft, PointD upperRight, Pen pen, Brush brush) : base(chart, lowerLeft, upperRight, pen, brush) { } public VisualGenealogyGraphTextLabel(IChart chart, double x1, double y1, double x2, double y2, Pen pen, Brush brush) : this(chart, new PointD(x1, y1), new PointD(x2, y2), pen, brush) { } public override void Draw(Graphics graphics) { Point p = Chart.TransformWorldToPixel(new PointD(LowerLeft.X, LowerLeft.Y + Size.Height)); Size s = Chart.TransformWorldToPixel(Size); float fontSize = s.Height; font = new Font(font.Name, fontSize, Font.Style, GraphicsUnit.Pixel); graphics.DrawString(text, font, fontBrush, p.X, p.Y); } protected override void OnUpdate() { if ((UpdateEnabled)) { base.OnUpdate(); } } } }