-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathasIconClass.m
82 lines (65 loc) · 2.49 KB
/
asIconClass.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
% Copyright (C) 2009-2013 Biomedizinische NMR Forschungs GmbH
% http://www.biomednmr.mpg.de
% Author: Tilman Johannes Sumpf <[email protected]>
%
% Distributed under the Boost Software License, Version 1.0.
% (See accompanying file LICENSE_1_0.txt or copy at
% http://www.boost.org/LICENSE_1_0.txt)
classdef (Sealed) asIconClass <handle
% the icon class is implemented as a singleton class to load the icons
% only once per session
properties (SetAccess = private, GetAccess = public)
% each entry represents an icon which is loaded from an equally
% named png file during object construction.
asBrowse
colorbar
dontSend
download
lineup
magnify
pause
play
refresh
rotLeft
rotRight
send
lock
squeeze
upload
wsObj
filter
showMarker
end
% private constructor
methods (Access = private)
function obj = asIconClass
end
end
methods (Static)
% public method to get an instance of the iconClass
function obj = getInstance(iconPath)
% persistent variable (stays in memory even after the calling
% arrayShow object has been closed)
persistent localObj
% if this is the first call, actually construct the object...
% if not, just return the previous instance
if isempty(localObj) || ~isvalid(localObj)
localObj = asIconClass;
% determine property names of this class
iconNames = properties(mfilename);
iconPaths = cellfun(@(x)[iconPath,filesep,x,'.png'],iconNames,...
'UniformOutput',false);
% load pngs
for i = 1 : length(iconNames)
localObj.(iconNames{i}) = iconRead(iconPaths{i});
end
% workaround for linux pcs with apparently sometimes different background colors
if ~ispc()
defaultBg = get(0,'defaultuicontrolbackgroundcolor');
localObj.send = imread(fullfile(iconPath,'send.png'),'Background',defaultBg);
end
end
obj = localObj;
end
end
end