-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcustomStringEntry.m
62 lines (57 loc) · 1.71 KB
/
customStringEntry.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
classdef (Abstract) customStringEntry < handle
%CUSTOMSTRINGENTRY: Abstract class for holding and manipulating custom string
%entries in the plotBrowser class
properties (Dependent)
Visible;
origString;
end
properties (Abstract, Dependent)
String;
ParentPosition;
UserData;
end
methods
function cobj = copyobj(l, ax)
cobj = text(ax, 0, .5, l.origString);
end
function s = get.Visible(l)
s = l.getVisible;
end
function set.Visible(l, s)
l.setVisible(s)
end
function o = get.origString(l)
o = l.UserData.origString;
end
function set.origString(l, o)
if isempty(l.UserData) || ...
isempty(l.UserData.origString) || ...
all(strcmp(strrep(l.UserData.origString, ' ', ''), '{}'))
l.UserData.origString = o;
end
end
end
methods (Access = 'protected')
function s = getVisible(l)
if strcmp(strrep(l.String, ' ', ''), '{}')
s = 'off';
else
s = 'on';
end
end
function setVisible(l, s)
pos = l.ParentPosition;
if strcmp(s, 'on')
l.String = l.origString;
else
l.origString = l.String;
str = ['{', repmat(' ', 1, numel(l.origString)), '}'];
l.String = str;
end
l.ParentPosition = pos;
end
end
methods (Abstract, Static)
s = getElementName;
end
end