Cairo-Chart/src/Area.vala

129 lines
2.2 KiB
Vala
Raw Normal View History

2018-01-20 14:43:21 +03:00
namespace CairoChart {
/**
* Area rectangle.
*/
public class Area {
2018-01-21 12:34:57 +03:00
/**
2018-01-21 12:55:03 +03:00
* Left bound.
2018-01-21 12:34:57 +03:00
*/
2018-01-21 14:14:57 +03:00
public double x0 = 0;
2018-01-21 12:34:57 +03:00
/**
2018-01-21 12:55:03 +03:00
* Top bound.
2018-01-21 12:34:57 +03:00
*/
2018-01-21 14:14:57 +03:00
public double x1 = 1;
2018-01-21 12:34:57 +03:00
/**
2018-01-21 12:55:03 +03:00
* Right bound.
2018-01-21 12:34:57 +03:00
*/
2018-01-21 14:14:57 +03:00
public double y0 = 0;
2018-01-21 12:34:57 +03:00
/**
2018-01-21 12:55:03 +03:00
* Bottom bound.
2018-01-21 12:34:57 +03:00
*/
2018-01-21 14:14:57 +03:00
public double y1 = 1;
2018-01-20 14:43:21 +03:00
/**
* ``Area`` width.
*/
2018-01-22 12:25:17 +03:00
public virtual double width {
2018-01-20 14:43:21 +03:00
get {
2018-01-21 14:14:57 +03:00
return x1 - x0;
2018-01-20 14:43:21 +03:00
}
2018-01-20 14:51:26 +03:00
set {
2018-01-21 14:14:57 +03:00
x1 = x0 + value;
2018-01-20 14:43:21 +03:00
}
}
/**
* ``Area`` height.
*/
2018-01-22 12:25:17 +03:00
public virtual double height {
2018-01-20 14:43:21 +03:00
get {
2018-01-21 14:14:57 +03:00
return y1 - y0;
2018-01-21 12:34:57 +03:00
}
set {
2018-01-21 14:14:57 +03:00
y1 = y0 + value;
2018-01-20 14:43:21 +03:00
}
}
/**
* Constructs a new ``Area``.
*/
2018-01-20 20:07:06 +03:00
public Area () { }
2018-01-20 14:43:21 +03:00
2018-01-21 13:04:02 +03:00
/**
* Constructs a new ``Area`` by other ``Area``.
* @param area ``Area`` instance.
*/
public Area.with_area (Area area) {
this.x0 = area.x0;
this.y0 = area.y0;
this.x1 = area.x1;
this.y1 = area.y1;
}
2018-01-20 14:43:21 +03:00
/**
* Constructs a new ``Area`` with absolute coordinates.
* @param x0 left bound.
* @param y0 top bound.
* @param x1 right bound.
* @param y1 bottom bound.
*/
2018-01-22 13:39:26 +03:00
public Area.with_abs (double x0, double y0,
double x1, double y1) {
2018-01-20 14:43:21 +03:00
this.x0 = x0;
this.y0 = y0;
this.x1 = x1;
this.y1 = y1;
}
2018-01-22 13:26:58 +03:00
/**
* Constructs a new ``Area`` by 2 points.
* @param p0 top left position.
* @param p1 bottom right position.
*/
public Area.with_points (Point p0, Point p1) {
this.x0 = p0.x;
this.y0 = p0.y;
this.x1 = p1.x;
this.y1 = p1.y;
}
2018-01-20 14:43:21 +03:00
/**
* Constructs a new ``Area`` with relative coordinates.
* @param x0 left bound.
* @param y0 top bound.
* @param width ``Area`` width.
* @param height ``Area`` height.
*/
2018-01-22 13:39:26 +03:00
public Area.with_rel (double x0, double y0,
double width, double height) {
2018-01-20 14:43:21 +03:00
this.x0 = x0;
this.y0 = y0;
this.width = width;
this.height = height;
}
/**
* Constructs a new ``Area`` by ``Cairo.Rectangle``.
* @param rectangle ``Cairo.Rectangle`` instance.
*/
2018-01-20 20:07:06 +03:00
public Area.with_rectangle (Cairo.Rectangle rectangle) {
2018-01-20 14:43:21 +03:00
this.x0 = rectangle.x;
this.y0 = rectangle.y;
this.width = rectangle.width;
this.height = rectangle.height;
}
/**
* Gets a copy of the ``Chart``.
*/
2018-01-22 12:25:17 +03:00
public virtual Area copy () {
2018-01-20 14:43:21 +03:00
return new Area.with_area(this);
}
}
}