Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HL-3.2-MonoMigration/HeuristicLab.Visualization/RectangleD.cs @ 4042

Last change on this file since 4042 was 635, checked in by mstoeger, 16 years ago

Imported charting framework sources into HeuristicLab.Visualization (#294)

File size: 2.1 KB
Line 
1namespace HeuristicLab.Visualization {
2  public struct RectangleD {
3    public static readonly RectangleD Empty = new RectangleD();
4
5    private PointD bottomLeft;
6    private PointD topRight;
7
8    private double width;
9    private double height;
10
11    public RectangleD(double x1, double y1, double x2, double y2) {
12      bottomLeft = PointD.Empty;
13      topRight = PointD.Empty;
14
15      bottomLeft.X = x1;
16      bottomLeft.Y = y1;
17
18      topRight.X = x2;
19      topRight.Y = y2;
20
21      width = x2 - x1;
22      height = y2 - y1;
23    }
24
25    public PointD BottomLeft {
26      get { return bottomLeft; }
27      set {
28        bottomLeft = value;
29        width = topRight.X - bottomLeft.X;
30        height = topRight.Y - bottomLeft.Y;
31      }
32    }
33
34    public PointD TopRight {
35      get { return topRight; }
36      set {
37        topRight = value;
38        width = topRight.X - bottomLeft.X;
39        height = topRight.Y - bottomLeft.Y;
40      }
41    }
42
43    public double X1 {
44      get { return bottomLeft.X; }
45      set {
46        bottomLeft.X = value;
47        width = topRight.X - bottomLeft.X;
48      }
49    }
50
51    public double X2 {
52      get { return topRight.X; }
53      set {
54        topRight.X = value;
55        width = topRight.X - bottomLeft.X;
56      }
57    }
58
59    public double Y1 {
60      get { return bottomLeft.Y; }
61      set {
62        bottomLeft.Y = value;
63        height = topRight.Y - bottomLeft.Y;
64      }
65    }
66
67    public double Y2 {
68      get { return topRight.Y; }
69      set {
70        topRight.Y = value;
71        height = topRight.Y - bottomLeft.Y;
72      }
73    }
74
75    public double Width {
76      get { return width; }
77      set {
78        width = value;
79        topRight.X = bottomLeft.X + width;
80      }
81    }
82
83    public double Height {
84      get { return height; }
85      set {
86        height = value;
87        topRight.Y = bottomLeft.Y + height;
88      }
89    }
90
91    public override string ToString() {
92      return (string.Format("{{X1={0},Y1={1},Width={2},Height={3}}}", X1, Y1, Width, Height));
93    }
94  }
95}
Note: See TracBrowser for help on using the repository browser.