Add copy() method to classes.

This commit is contained in:
Kolan Sh 2017-08-28 18:16:48 +03:00
parent accddc2b79
commit 82aa857a35
7 changed files with 109 additions and 16 deletions

View File

@ -62,9 +62,28 @@ namespace Gtk.CairoChart {
}
public FontStyle font_style = FontStyle ();
public Color color = Color ();
public LineStyle line_style = new LineStyle ();
public LineStyle line_style = LineStyle ();
public double font_indent = 5;
public Axis copy () {
var axis = new Axis ();
axis._date_format = this._date_format;
axis._dsec_signs = this._dsec_signs;
axis._format = this._format;
axis._time_format = this._time_format;
axis.color = this.color;
axis.font_indent = this.font_indent;
axis.font_style = this.font_style;
axis.line_style = this.line_style;
axis.max = this.max;
axis.min = this.min;
axis.position = this.position;
axis.scale_type = this.scale_type;
axis.title = this.title.copy();
axis.type = this.type;
return axis;
}
public Axis () {}
}
}

View File

@ -16,7 +16,7 @@ namespace Gtk.CairoChart {
public Series[] series = {};
protected LineStyle selection_style = new LineStyle ();
protected LineStyle selection_style = LineStyle ();
public Chart () {
bg_color = Color (1, 1, 1);
@ -957,5 +957,46 @@ namespace Gtk.CairoChart {
// TODO:
protected virtual void draw_cursors () {
}
public Chart copy () {
var chart = new Chart ();
chart.axis_rec_npoints = this.axis_rec_npoints;
chart.bg_color = this.bg_color;
chart.border_color = this.border_color;
chart.common_x_axes = this.common_x_axes;
chart.common_y_axes = this.common_y_axes;
chart.context = this.context;
chart.cur_x_max = this.cur_x_max;
chart.cur_x_min = this.cur_x_min;
chart.cur_y_max = this.cur_y_max;
chart.cur_y_min = this.cur_y_min;
chart.height = this.height;
chart.legend = this.legend.copy();
chart.legend_height = this.legend_height;
chart.legend_line_length = this.legend_line_length;
chart.legend_text_hspace = this.legend_text_hspace;
chart.legend_text_vspace = this.legend_text_vspace;
chart.legend_width = this.legend_width;
chart.marker_size = this.marker_size;
chart.max_font_heights = this.max_font_heights.copy();
chart.plot_area_x_max = this.plot_area_x_max;
chart.plot_area_x_min = this.plot_area_x_min;
chart.plot_area_y_max = this.plot_area_y_max;
chart.plot_area_y_min = this.plot_area_y_min;
chart.selection_style = this.selection_style;
chart.series = this.series.copy();
chart.show_legend = this.show_legend;
chart.title = this.title.copy().copy();
chart.title_height = this.title_height;
chart.title_vindent = this.title_vindent;
chart.title_width = this.title_width;
chart.width = this.width;
chart.zoom = this.zoom;
chart.zoom_x0 = this.zoom_x0;
chart.zoom_x1 = this.zoom_x1;
chart.zoom_y0 = this.zoom_y0;
chart.zoom_y1 = this.zoom_y1;
return chart;
}
}
}

View File

@ -6,7 +6,14 @@ namespace Gtk.CairoChart {
}*/
public Color color = Color (0, 0, 0, 0.1);
public LineStyle line_style = new LineStyle ();
public LineStyle line_style = LineStyle ();
public Grid copy () {
var grid = new Grid ();
grid.color = this.color;
grid.line_style = this.line_style;
return grid;
}
public Grid () {
line_style.dashes = {2, 3};

View File

@ -1,8 +1,8 @@
namespace Gtk.CairoChart {
public class LabelStyle {
FontStyle font_style = FontStyle();
LineStyle frame_line_style = new LineStyle();
Color bg_color = Color();
Color frame_color = Color();
public struct LabelStyle {
FontStyle font_style;
LineStyle frame_line_style;
Color bg_color;
Color frame_color;
}
}

View File

@ -9,9 +9,18 @@ namespace Gtk.CairoChart {
public Position position = Position.TOP;
public FontStyle font_style = FontStyle();
public Color bg_color = Color(1, 1, 1);
public LineStyle border_style = new LineStyle ();
public LineStyle border_style = LineStyle ();
public double indent = 5;
public Legend copy () {
var legend = new Legend ();
legend.position = this.position;
legend.font_style = this.font_style;
legend.bg_color = this.bg_color;
legend.indent = this.indent;
return legend;
}
public Legend () {
border_style.color = Color (0, 0, 0, 0.3);
}

View File

@ -25,14 +25,14 @@ namespace Gtk.CairoChart {
PRICLE_TRIANGLE
}
public Place place = new Place();
public Place place = Place();
public Text title = new Text ();
public MarkerType marker_type = MarkerType.SQUARE;
public Grid grid = new Grid ();
public GLib.List<Float128?> cursors = new List<Float128?> ();
public LineStyle line_style = new LineStyle ();
public LineStyle line_style = LineStyle ();
protected Color _color = Color (0.0, 0.0, 0.0, 1.0);
public Color color {
@ -50,8 +50,23 @@ namespace Gtk.CairoChart {
default = Color (0.0, 0.0, 0.0, 1.0);
}
public Series () {
public Series copy () {
var series = new Series ();
series._color = this._color;
series.axis_x = this.axis_x.copy ();
series.axis_y = this.axis_y.copy ();
series.cursors = this.cursors.copy ();
series.grid = this.grid.copy ();
series.line_style = this.line_style;
series.marker_type = this.marker_type;
series.place = this.place;
series.points = this.points.copy();
series.sort = this.sort;
series.title = this.title.copy();
return series;
}
public Series () {
}
}
}

View File

@ -47,10 +47,12 @@ namespace Gtk.CairoChart {
this.color = color;
}
public Text.by_instance (Text text) {
this.text = text.text;
this.style = text.style;
this.color = text.color;
public Text copy () {
var text = new Text ();
text.text = this.text;
text.style = this.style;
text.color = this.color;
return text;
}
}
}