Marker.vala created #1
This commit is contained in:
parent
94ed3ecabb
commit
6e577891ae
|
@ -212,50 +212,6 @@ namespace CairoChart {
|
||||||
|
|
||||||
public double marker_size = 8.0;
|
public double marker_size = 8.0;
|
||||||
|
|
||||||
public virtual void draw_marker_at_pos (Series.MarkerType marker_type,
|
|
||||||
double x, double y) {
|
|
||||||
context.move_to (x, y);
|
|
||||||
switch (marker_type) {
|
|
||||||
case Series.MarkerType.SQUARE:
|
|
||||||
context.rectangle (x - marker_size / 2, y - marker_size / 2,
|
|
||||||
marker_size, marker_size);
|
|
||||||
context.fill();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Series.MarkerType.CIRCLE:
|
|
||||||
context.arc (x, y, marker_size / 2, 0, 2*Math.PI);
|
|
||||||
context.fill();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Series.MarkerType.TRIANGLE:
|
|
||||||
context.move_to (x - marker_size / 2, y - marker_size / 2);
|
|
||||||
context.line_to (x + marker_size / 2, y - marker_size / 2);
|
|
||||||
context.line_to (x, y + marker_size / 2);
|
|
||||||
context.line_to (x - marker_size / 2, y - marker_size / 2);
|
|
||||||
context.fill();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Series.MarkerType.PRICLE_SQUARE:
|
|
||||||
context.rectangle (x - marker_size / 2, y - marker_size / 2,
|
|
||||||
marker_size, marker_size);
|
|
||||||
context.stroke();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Series.MarkerType.PRICLE_CIRCLE:
|
|
||||||
context.arc (x, y, marker_size / 2, 0, 2*Math.PI);
|
|
||||||
context.stroke();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Series.MarkerType.PRICLE_TRIANGLE:
|
|
||||||
context.move_to (x - marker_size / 2, y - marker_size / 2);
|
|
||||||
context.line_to (x + marker_size / 2, y - marker_size / 2);
|
|
||||||
context.line_to (x, y + marker_size / 2);
|
|
||||||
context.line_to (x - marker_size / 2, y - marker_size / 2);
|
|
||||||
context.stroke();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Line.Style selection_style = Line.Style ();
|
public Line.Style selection_style = Line.Style ();
|
||||||
|
|
||||||
public virtual void draw_selection (double x0, double y0, double x1, double y1) {
|
public virtual void draw_selection (double x0, double y0, double x1, double y1) {
|
||||||
|
@ -994,7 +950,7 @@ namespace CairoChart {
|
||||||
var x = get_scr_x(s, points[i].x);
|
var x = get_scr_x(s, points[i].x);
|
||||||
var y = get_scr_y(s, points[i].y);
|
var y = get_scr_y(s, points[i].y);
|
||||||
if (point_in_plot_area (Point (x, y)))
|
if (point_in_plot_area (Point (x, y)))
|
||||||
draw_marker_at_pos(s.marker_type, x, y);
|
Marker.draw_at_pos(this, s.marker_type, x, y, marker_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,11 @@ namespace CairoChart {
|
||||||
s.line_style.set(chart);
|
s.line_style.set(chart);
|
||||||
chart.context.rel_line_to (line_length, 0);
|
chart.context.rel_line_to (line_length, 0);
|
||||||
chart.context.stroke();
|
chart.context.stroke();
|
||||||
chart.draw_marker_at_pos (s.marker_type, x + line_length / 2, y - title_sz.height / 2);
|
Marker.draw_at_pos (chart,
|
||||||
|
s.marker_type,
|
||||||
|
x + line_length / 2,
|
||||||
|
y - title_sz.height / 2,
|
||||||
|
chart.marker_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
namespace CairoChart {
|
||||||
|
|
||||||
|
public class Marker {
|
||||||
|
|
||||||
|
public static void draw_at_pos (Chart chart,
|
||||||
|
Series.MarkerType marker_type,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
double marker_size = 8.0) {
|
||||||
|
chart.context.move_to (x, y);
|
||||||
|
switch (marker_type) {
|
||||||
|
case Series.MarkerType.SQUARE:
|
||||||
|
chart.context.rectangle (x - marker_size / 2, y - marker_size / 2,
|
||||||
|
marker_size, marker_size);
|
||||||
|
chart.context.fill();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Series.MarkerType.CIRCLE:
|
||||||
|
chart.context.arc (x, y, marker_size / 2, 0, 2*Math.PI);
|
||||||
|
chart.context.fill();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Series.MarkerType.TRIANGLE:
|
||||||
|
chart.context.move_to (x - marker_size / 2, y - marker_size / 2);
|
||||||
|
chart.context.line_to (x + marker_size / 2, y - marker_size / 2);
|
||||||
|
chart.context.line_to (x, y + marker_size / 2);
|
||||||
|
chart.context.line_to (x - marker_size / 2, y - marker_size / 2);
|
||||||
|
chart.context.fill();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Series.MarkerType.PRICLE_SQUARE:
|
||||||
|
chart.context.rectangle (x - marker_size / 2, y - marker_size / 2,
|
||||||
|
marker_size, marker_size);
|
||||||
|
chart.context.stroke();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Series.MarkerType.PRICLE_CIRCLE:
|
||||||
|
chart.context.arc (x, y, marker_size / 2, 0, 2*Math.PI);
|
||||||
|
chart.context.stroke();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Series.MarkerType.PRICLE_TRIANGLE:
|
||||||
|
chart.context.move_to (x - marker_size / 2, y - marker_size / 2);
|
||||||
|
chart.context.line_to (x + marker_size / 2, y - marker_size / 2);
|
||||||
|
chart.context.line_to (x, y + marker_size / 2);
|
||||||
|
chart.context.line_to (x - marker_size / 2, y - marker_size / 2);
|
||||||
|
chart.context.stroke();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue