2018-01-20 14:43:21 +03:00
|
|
|
namespace CairoChart {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Area rectangle.
|
|
|
|
*/
|
|
|
|
public class Area {
|
|
|
|
|
2018-01-21 12:34:57 +03:00
|
|
|
double _x0 = 0;
|
|
|
|
double _x1 = 1;
|
|
|
|
double _y0 = 0;
|
|
|
|
double _y1 = 1;
|
|
|
|
|
2018-01-20 14:43:21 +03:00
|
|
|
/**
|
2018-01-21 12:55:03 +03:00
|
|
|
* Zoomed Left bound.
|
2018-01-20 14:43:21 +03:00
|
|
|
*/
|
2018-01-21 12:55:03 +03:00
|
|
|
public double zx0 = 0;
|
2018-01-20 14:43:21 +03:00
|
|
|
|
|
|
|
/**
|
2018-01-21 12:55:03 +03:00
|
|
|
* Zoomed Top bound.
|
2018-01-20 14:43:21 +03:00
|
|
|
*/
|
2018-01-21 12:55:03 +03:00
|
|
|
public double zx1 = 1;
|
2018-01-20 14:43:21 +03:00
|
|
|
|
|
|
|
/**
|
2018-01-21 12:55:03 +03:00
|
|
|
* Zoomed Right bound.
|
2018-01-20 14:43:21 +03:00
|
|
|
*/
|
2018-01-21 12:55:03 +03:00
|
|
|
public double zy0 = 0;
|
2018-01-20 14:43:21 +03:00
|
|
|
|
|
|
|
/**
|
2018-01-21 12:55:03 +03:00
|
|
|
* Zoomed Bottom bound.
|
2018-01-20 14:43:21 +03:00
|
|
|
*/
|
2018-01-21 12:55:03 +03:00
|
|
|
public double zy1 = 1;
|
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 12:55:03 +03:00
|
|
|
public double x0 {
|
2018-01-21 12:34:57 +03:00
|
|
|
get {
|
2018-01-21 12:55:03 +03:00
|
|
|
return _x0;
|
2018-01-21 12:34:57 +03:00
|
|
|
}
|
|
|
|
set {
|
2018-01-21 12:55:03 +03:00
|
|
|
zx0 = _x0 = value;
|
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 12:55:03 +03:00
|
|
|
public double y0 {
|
2018-01-21 12:34:57 +03:00
|
|
|
get {
|
2018-01-21 12:55:03 +03:00
|
|
|
return _y0;
|
2018-01-21 12:34:57 +03:00
|
|
|
}
|
|
|
|
set {
|
2018-01-21 12:55:03 +03:00
|
|
|
zy0 = _y0 = value;
|
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 12:55:03 +03:00
|
|
|
public double x1 {
|
2018-01-21 12:34:57 +03:00
|
|
|
get {
|
2018-01-21 12:55:03 +03:00
|
|
|
return _x1;
|
2018-01-21 12:34:57 +03:00
|
|
|
}
|
|
|
|
set {
|
2018-01-21 12:55:03 +03:00
|
|
|
zx1 = _x1 = value;
|
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 12:55:03 +03:00
|
|
|
public double y1 {
|
2018-01-21 12:34:57 +03:00
|
|
|
get {
|
2018-01-21 12:55:03 +03:00
|
|
|
return _y1;
|
2018-01-21 12:34:57 +03:00
|
|
|
}
|
|
|
|
set {
|
2018-01-21 12:55:03 +03:00
|
|
|
zy1 = _y1 = value;
|
2018-01-21 12:34:57 +03:00
|
|
|
}
|
|
|
|
}
|
2018-01-20 14:43:21 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ``Area`` width.
|
|
|
|
*/
|
|
|
|
public double width {
|
|
|
|
get {
|
2018-01-21 12:34: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 12:55:03 +03:00
|
|
|
zx1 = _x1 = _x0 + value;
|
2018-01-20 14:43:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ``Area`` height.
|
|
|
|
*/
|
|
|
|
public double height {
|
|
|
|
get {
|
2018-01-21 12:34:57 +03:00
|
|
|
return _y1 - _y0;
|
|
|
|
}
|
|
|
|
set {
|
2018-01-21 12:55:03 +03:00
|
|
|
zy1 = _y1 = _y0 + value;
|
2018-01-21 12:34:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ``Area`` zoomed width.
|
|
|
|
*/
|
|
|
|
public double zwidth {
|
|
|
|
get {
|
2018-01-21 12:55:03 +03:00
|
|
|
return zx1 - zx0;
|
2018-01-21 12:34:57 +03:00
|
|
|
}
|
|
|
|
set {
|
2018-01-21 13:04:02 +03:00
|
|
|
zx1 = zx0 + value;
|
2018-01-21 12:34:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ``Area`` zoomed height.
|
|
|
|
*/
|
|
|
|
public double zheight {
|
|
|
|
get {
|
2018-01-21 12:55:03 +03:00
|
|
|
return zy1 - zy0;
|
2018-01-20 14:43:21 +03:00
|
|
|
}
|
2018-01-20 14:51:26 +03:00
|
|
|
set {
|
2018-01-21 13:04:02 +03:00
|
|
|
zy1 = zy0 + 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);
|
|
|
|
}
|
2018-01-21 12:34:57 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unzooms ``Area``.
|
|
|
|
*/
|
|
|
|
public void unzoom () {
|
2018-01-21 12:55:03 +03:00
|
|
|
zx0 = x0;
|
|
|
|
zy0 = y0;
|
|
|
|
zx1 = x1;
|
|
|
|
zy1 = y1;
|
2018-01-21 12:34:57 +03:00
|
|
|
}
|
2018-01-20 14:43:21 +03:00
|
|
|
}
|
|
|
|
}
|