1212
1313 methods (Static )
1414 function alignstring(uielement , alignment )
15+ alignment = lower(alignment );
16+ mlapptools .validatealignmentstr(alignment )
1517 mlapptools .togglewarnings(' off' )
16- drawnow ;
18+
1719 rez = ' ' ;
1820 while ~strcmp(rez , sprintf(' "%s "' , alignment ))
1921 try
@@ -22,12 +24,12 @@ function alignstring(uielement, alignment)
2224 % 2. Find which element of the DOM we want to edit (as before):
2325 data_tag = char(struct(uielement ).Controller.ProxyView.PeerNode.getId);
2426 % 3. Manipulate the DOM via a JS command
25- JSstr = sprintf(' dojo.style(dojo.query("[data-tag^=''%s'' ]")[0],"textAlign","%s ")' , ...
27+ JSstr = sprintf(' dojo.style(dojo.query("[data-tag^=''%s'' ]")[0], "textAlign", "%s ")' , ...
2628 data_tag , alignment );
2729 rez = win .executeJS(JSstr );
2830 catch
2931 % TODO: See if an infinite loop condition is possible
30- pause(0.5 ); % Give the figure (webpage) some more time to load
32+ pause(1 ); % Give the figure (webpage) some more time to load
3133 end
3234 end
3335 mlapptools .togglewarnings(' on' )
@@ -47,5 +49,19 @@ function togglewarnings(togglestr)
4749 % Do nothing
4850 end
4951 end
52+
53+ function validatealignmentstr(alignment )
54+ if ~ischar(alignment )
55+ msgID = ' mlapptools:alignstring:InvalidInputIype' ;
56+ error(msgID , ' Expected ''%s'' , inputs of type ''%s'' not supported' , ...
57+ class(' Dev-il' ), class(alignment ));
58+ end
59+
60+ validstr = {' left' , ' right' , ' center' , ' justify' };
61+ if ~any(ismember(validstr , alignment ))
62+ msgID = ' mlapptools:alignstring:InvalidAlignmentString' ;
63+ error(msgID , ' Invalid string alignment specified: ''%s'' ' , alignment );
64+ end
65+ end
5066 end
5167end
0 commit comments