2018-01-10 11:32:51 +03:00
|
|
|
namespace CairoChart {
|
|
|
|
|
|
|
|
public class Marker {
|
|
|
|
|
2018-01-10 12:58:35 +03:00
|
|
|
public enum Type {
|
|
|
|
NONE = 0, // default
|
|
|
|
SQUARE,
|
|
|
|
CIRCLE,
|
|
|
|
TRIANGLE,
|
|
|
|
PRICLE_SQUARE,
|
|
|
|
PRICLE_CIRCLE,
|
|
|
|
PRICLE_TRIANGLE
|
|
|
|
}
|
|
|
|
|
|
|
|
public Type type = Type.NONE;
|
|
|
|
public double size = 8.0;
|
|
|
|
|
2018-01-19 20:34:08 +03:00
|
|
|
public Marker (Type type = Type.NONE,
|
|
|
|
double size = 8.0
|
|
|
|
) {
|
2018-01-10 12:58:35 +03:00
|
|
|
this.type = type;
|
|
|
|
this.size = size;
|
|
|
|
}
|
|
|
|
|
2018-01-15 12:05:21 +03:00
|
|
|
public virtual Marker copy () {
|
2018-01-10 12:58:35 +03:00
|
|
|
return new Marker (type, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void draw_at_pos (Chart chart, double x, double y) {
|
2018-01-17 10:36:10 +03:00
|
|
|
chart.ctx.move_to (x, y);
|
2018-01-10 12:58:35 +03:00
|
|
|
switch (type) {
|
|
|
|
case Type.SQUARE:
|
2018-01-17 10:36:10 +03:00
|
|
|
chart.ctx.rectangle (x - size / 2, y - size / 2, size, size);
|
|
|
|
chart.ctx.fill();
|
2018-01-10 11:32:51 +03:00
|
|
|
break;
|
|
|
|
|
2018-01-10 12:58:35 +03:00
|
|
|
case Type.CIRCLE:
|
2018-01-17 10:36:10 +03:00
|
|
|
chart.ctx.arc (x, y, size / 2, 0, 2 * GLib.Math.PI);
|
|
|
|
chart.ctx.fill();
|
2018-01-10 11:32:51 +03:00
|
|
|
break;
|
|
|
|
|
2018-01-10 12:58:35 +03:00
|
|
|
case Type.TRIANGLE:
|
2018-01-17 10:36:10 +03:00
|
|
|
chart.ctx.move_to (x - size / 2, y - size / 2);
|
|
|
|
chart.ctx.line_to (x + size / 2, y - size / 2);
|
|
|
|
chart.ctx.line_to (x, y + size / 2);
|
|
|
|
chart.ctx.line_to (x - size / 2, y - size / 2);
|
|
|
|
chart.ctx.fill();
|
2018-01-10 11:32:51 +03:00
|
|
|
break;
|
|
|
|
|
2018-01-10 12:58:35 +03:00
|
|
|
case Type.PRICLE_SQUARE:
|
2018-01-17 10:36:10 +03:00
|
|
|
chart.ctx.rectangle (x - size / 2, y - size / 2,
|
2018-01-10 12:58:35 +03:00
|
|
|
size, size);
|
2018-01-17 10:36:10 +03:00
|
|
|
chart.ctx.stroke();
|
2018-01-10 11:32:51 +03:00
|
|
|
break;
|
|
|
|
|
2018-01-10 12:58:35 +03:00
|
|
|
case Type.PRICLE_CIRCLE:
|
2018-01-17 10:36:10 +03:00
|
|
|
chart.ctx.arc (x, y, size / 2, 0, 2 * GLib.Math.PI);
|
|
|
|
chart.ctx.stroke();
|
2018-01-10 11:32:51 +03:00
|
|
|
break;
|
|
|
|
|
2018-01-10 12:58:35 +03:00
|
|
|
case Type.PRICLE_TRIANGLE:
|
2018-01-17 10:36:10 +03:00
|
|
|
chart.ctx.move_to (x - size / 2, y - size / 2);
|
|
|
|
chart.ctx.line_to (x + size / 2, y - size / 2);
|
|
|
|
chart.ctx.line_to (x, y + size / 2);
|
|
|
|
chart.ctx.line_to (x - size / 2, y - size / 2);
|
|
|
|
chart.ctx.stroke();
|
2018-01-10 11:32:51 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|