-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawer.m
83 lines (70 loc) · 1.92 KB
/
drawer.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
% Authors: Alejandro R. Mosteo, Danilo Tardioli, Eduardo Montijano
% Copyright 2018-9999 Monmostar
% Licensed under GPLv3 https://www.gnu.org/licenses/gpl-3.0.en.html
%
% Class to encapsulate updates instead of drawing from scratch
classdef drawer < handle
properties
h = []
end
methods
function delete(this) % DESTRUCTOR
if ~isempty(this.h)
delete(this.h);
end
end
function bring_to_front(this)
if ~isempty(this.h)
uistack(this.h, 'top');
end
end
function fill(this, ax, x, y, color, varargin)
return
axes(ax);
if isempty(this.h)
this.h = fill(x, y, color, varargin{:});
else
this.h.Vertices(:,1) = x;
this.h.Vertices(:,2) = y;
this.h.FaceColor = color;
this.update(varargin{:});
end
end
function plot(this, axis, x, y, varargin)
if isempty(this.h)
this.h = plot(axis, x, y, varargin{:});
else
this.h.XData = x;
this.h.YData = y;
this.update(varargin{:});
end
end
function text(this, axis, x, y, txt, varargin)
if isempty(this.h)
this.h = text(axis, x, y, txt, varargin{:});
else
this.h.Position(1) = x;
this.h.Position(2) = y;
this.h.String = txt;
this.update(varargin{:});
end
end
function show(this, visible)
if nargin < 2
visible = true;
end
if ~isempty(this.h)
if visible && isvalid(this.h)
this.h.Visible = 'On';
else
this.h.Visible = 'Off';
end
end
end
function update(this, varargin)
for i = 1:2:numel(varargin)
this.h.(varargin{i}) = varargin{i+1};
end
end
end
end