Rev | Line | |
---|
[1046] | 1 | using System.Drawing;
|
---|
| 2 |
|
---|
| 3 | namespace HeuristicLab.Visualization {
|
---|
| 4 | public class TextShape : IShape {
|
---|
| 5 | private Font font;
|
---|
| 6 | private Brush brush;
|
---|
| 7 | private Color color;
|
---|
| 8 | private string text;
|
---|
| 9 | private double x;
|
---|
| 10 | private double y;
|
---|
| 11 |
|
---|
| 12 | public TextShape(double x, double y, string text) : this(x, y, text, 8) {}
|
---|
| 13 |
|
---|
| 14 | public TextShape(double x, double y, string text, int fontSize) {
|
---|
| 15 | this.x = x;
|
---|
| 16 | this.y = y;
|
---|
| 17 | this.text = text;
|
---|
| 18 | font = new Font("Arial", fontSize);
|
---|
| 19 |
|
---|
| 20 | Color = Color.Blue;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | public string Text {
|
---|
| 24 | get { return text; }
|
---|
| 25 | set { text = value; }
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | public double X {
|
---|
| 29 | get { return x; }
|
---|
| 30 | set { x = value; }
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | public double Y {
|
---|
| 34 | get { return y; }
|
---|
| 35 | set { y = value; }
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | public Color Color {
|
---|
| 39 | get { return color; }
|
---|
| 40 | set {
|
---|
| 41 | color = value;
|
---|
| 42 | brush = new SolidBrush(color);
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | #region IShape Members
|
---|
| 47 |
|
---|
| 48 | public void Draw(Graphics graphics, Rectangle viewport, RectangleD clippingArea) {
|
---|
| 49 | int screenX = Transform.ToScreenX(x, viewport, clippingArea);
|
---|
| 50 | int screenY = Transform.ToScreenY(y, viewport, clippingArea);
|
---|
| 51 |
|
---|
| 52 | graphics.DrawString(text, font, brush, screenX, screenY);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | public RectangleD BoundingBox {
|
---|
| 56 | get { return RectangleD.Empty; }
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | #endregion
|
---|
| 60 | }
|
---|
| 61 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.