From dd7ee462c8afd6f2d8063f965c7abc3f87052f63 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Sun, 21 Jan 2018 14:14:57 +0300 Subject: [PATCH] OK In progress... --- src/Area.vala | 103 ++----------------------- src/Place.vala | 201 ++++++++++++++++++++++++++++++++++++++++++++++++ src/Series.vala | 2 +- 3 files changed, 210 insertions(+), 96 deletions(-) create mode 100644 src/Place.vala diff --git a/src/Area.vala b/src/Area.vala index e0048e9..46dfd01 100644 --- a/src/Area.vala +++ b/src/Area.vala @@ -5,88 +5,35 @@ namespace CairoChart { */ public class Area { - double _x0 = 0; - double _x1 = 1; - double _y0 = 0; - double _y1 = 1; - - /** - * Zoomed Left bound. - */ - public double zx0 = 0; - - /** - * Zoomed Top bound. - */ - public double zx1 = 1; - - /** - * Zoomed Right bound. - */ - public double zy0 = 0; - - /** - * Zoomed Bottom bound. - */ - public double zy1 = 1; - /** * Left bound. */ - public double x0 { - get { - return _x0; - } - set { - zx0 = _x0 = value; - } - } + public double x0 = 0; /** * Top bound. */ - public double y0 { - get { - return _y0; - } - set { - zy0 = _y0 = value; - } - } + public double x1 = 1; /** * Right bound. */ - public double x1 { - get { - return _x1; - } - set { - zx1 = _x1 = value; - } - } + public double y0 = 0; /** * Bottom bound. */ - public double y1 { - get { - return _y1; - } - set { - zy1 = _y1 = value; - } - } + public double y1 = 1; /** * ``Area`` width. */ public double width { get { - return _x1 - _x0; + return x1 - x0; } set { - zx1 = _x1 = _x0 + value; + x1 = x0 + value; } } @@ -95,34 +42,10 @@ namespace CairoChart { */ public double height { get { - return _y1 - _y0; + return y1 - y0; } set { - zy1 = _y1 = _y0 + value; - } - } - - /** - * ``Area`` zoomed width. - */ - public double zwidth { - get { - return zx1 - zx0; - } - set { - zx1 = zx0 + value; - } - } - - /** - * ``Area`` zoomed height. - */ - public double zheight { - get { - return zy1 - zy0; - } - set { - zy1 = zy0 + value; + y1 = y0 + value; } } @@ -187,15 +110,5 @@ namespace CairoChart { public Area copy () { return new Area.with_area(this); } - - /** - * Unzooms ``Area``. - */ - public void unzoom () { - zx0 = x0; - zy0 = y0; - zx1 = x1; - zy1 = y1; - } } } diff --git a/src/Place.vala b/src/Place.vala new file mode 100644 index 0000000..9a1f3f5 --- /dev/null +++ b/src/Place.vala @@ -0,0 +1,201 @@ +namespace CairoChart { + + /** + * Place rectangle. + */ + public class Place { + + double _x0 = 0; + double _x1 = 1; + double _y0 = 0; + double _y1 = 1; + + /** + * Zoomed Left bound. + */ + public double zx0 = 0; + + /** + * Zoomed Top bound. + */ + public double zx1 = 1; + + /** + * Zoomed Right bound. + */ + public double zy0 = 0; + + /** + * Zoomed Bottom bound. + */ + public double zy1 = 1; + + /** + * Left bound. + */ + public double x0 { + get { + return _x0; + } + set { + zx0 = _x0 = value; + } + } + + /** + * Top bound. + */ + public double y0 { + get { + return _y0; + } + set { + zy0 = _y0 = value; + } + } + + /** + * Right bound. + */ + public double x1 { + get { + return _x1; + } + set { + zx1 = _x1 = value; + } + } + + /** + * Bottom bound. + */ + public double y1 { + get { + return _y1; + } + set { + zy1 = _y1 = value; + } + } + + /** + * ``Place`` width. + */ + public double width { + get { + return _x1 - _x0; + } + set { + zx1 = _x1 = _x0 + value; + } + } + + /** + * ``Place`` height. + */ + public double height { + get { + return _y1 - _y0; + } + set { + zy1 = _y1 = _y0 + value; + } + } + + /** + * ``Place`` zoomed width. + */ + public double zwidth { + get { + return zx1 - zx0; + } + set { + zx1 = zx0 + value; + } + } + + /** + * ``Place`` zoomed height. + */ + public double zheight { + get { + return zy1 - zy0; + } + set { + zy1 = zy0 + value; + } + } + + /** + * Constructs a new ``Place``. + */ + public Place () { } + + /** + * Constructs a new ``Place`` by other ``Place``. + * @param place ``Place`` instance. + */ + public Place.with_place (Place place) { + this.x0 = place.x0; + this.y0 = place.y0; + this.x1 = place.x1; + this.y1 = place.y1; + } + + /** + * Constructs a new ``Place`` with absolute coordinates. + * @param x0 left bound. + * @param y0 top bound. + * @param x1 right bound. + * @param y1 bottom bound. + */ + public Place.with_abs (double x0, double y0, double x1, double y1) { + this.x0 = x0; + this.y0 = y0; + this.x1 = x1; + this.y1 = y1; + } + + /** + * Constructs a new ``Place`` with relative coordinates. + * @param x0 left bound. + * @param y0 top bound. + * @param width ``Place`` width. + * @param height ``Place`` height. + */ + public Place.with_rel (double x0, double y0, double width, double height) { + this.x0 = x0; + this.y0 = y0; + this.width = width; + this.height = height; + } + + /** + * Constructs a new ``Place`` by ``Cairo.Rectangle``. + * @param rectangle ``Cairo.Rectangle`` instance. + */ + public Place.with_rectangle (Cairo.Rectangle rectangle) { + this.x0 = rectangle.x; + this.y0 = rectangle.y; + this.width = rectangle.width; + this.height = rectangle.height; + } + + /** + * Gets a copy of the ``Chart``. + */ + public Place copy () { + return new Place.with_place(this); + } + + /** + * Unzooms ``Place``. + */ + public void unzoom () { + zx0 = x0; + zy0 = y0; + zx1 = x1; + zy1 = y1; + } + } +} diff --git a/src/Series.vala b/src/Series.vala index 255166f..792b480 100644 --- a/src/Series.vala +++ b/src/Series.vala @@ -15,7 +15,7 @@ namespace CairoChart { public Axis axis_x = new Axis(); public Axis axis_y = new Axis(); - public Area place = new Area(); + public Place place = new Place(); public Text title = new Text (); public Marker marker = new Marker ();