OK In progress...

This commit is contained in:
Kolan Sh 2018-01-21 14:14:57 +03:00
parent 94734a26fc
commit dd7ee462c8
3 changed files with 210 additions and 96 deletions

View File

@ -5,88 +5,35 @@ namespace CairoChart {
*/ */
public class Area { 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. * Left bound.
*/ */
public double x0 { public double x0 = 0;
get {
return _x0;
}
set {
zx0 = _x0 = value;
}
}
/** /**
* Top bound. * Top bound.
*/ */
public double y0 { public double x1 = 1;
get {
return _y0;
}
set {
zy0 = _y0 = value;
}
}
/** /**
* Right bound. * Right bound.
*/ */
public double x1 { public double y0 = 0;
get {
return _x1;
}
set {
zx1 = _x1 = value;
}
}
/** /**
* Bottom bound. * Bottom bound.
*/ */
public double y1 { public double y1 = 1;
get {
return _y1;
}
set {
zy1 = _y1 = value;
}
}
/** /**
* ``Area`` width. * ``Area`` width.
*/ */
public double width { public double width {
get { get {
return _x1 - _x0; return x1 - x0;
} }
set { set {
zx1 = _x1 = _x0 + value; x1 = x0 + value;
} }
} }
@ -95,34 +42,10 @@ namespace CairoChart {
*/ */
public double height { public double height {
get { get {
return _y1 - _y0; return y1 - y0;
} }
set { set {
zy1 = _y1 = _y0 + value; 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;
} }
} }
@ -187,15 +110,5 @@ namespace CairoChart {
public Area copy () { public Area copy () {
return new Area.with_area(this); return new Area.with_area(this);
} }
/**
* Unzooms ``Area``.
*/
public void unzoom () {
zx0 = x0;
zy0 = y0;
zx1 = x1;
zy1 = y1;
}
} }
} }

201
src/Place.vala Normal file
View File

@ -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;
}
}
}

View File

@ -15,7 +15,7 @@ namespace CairoChart {
public Axis axis_x = new Axis(); public Axis axis_x = new Axis();
public Axis axis_y = new Axis(); public Axis axis_y = new Axis();
public Area place = new Area(); public Place place = new Place();
public Text title = new Text (); public Text title = new Text ();
public Marker marker = new Marker (); public Marker marker = new Marker ();