Cairo-Chart/src/Area.vala

115 lines
1.9 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.
*/
public double width {
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.
*/
public double height {
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-20 20:07:06 +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;
}
/**
* 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-20 20:07:06 +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``.
*/
public Area copy () {
return new Area.with_area(this);
}
}
}