Home > . > plot_text.m

# plot_text

## PURPOSE

'plot_text': function for displaying the content of a Matlab structure in a figure

## SYNOPSIS

function hdisplay=plot_text(FieldData,hdisplay_in)

## DESCRIPTION

    'plot_text': function for displaying the content of a Matlab structure in a figure
    ------------------------------------------------------------------------
     function hdisplay=plot_text(FieldData,hdisplay_in)

     OUTPUT:
     hdisplay: handle of the display edit box

      INPUT:
     FieldData: input Matlab structure
     hdisplay_in: handles of the display box, if it is not defined create a new figure

    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
      Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
         This file is part of the toolbox UVMAT.

         UVMAT is free software; you can redistribute it and/or modify
         it under the terms of the GNU General Public License as published by
         the Free Software Foundation; either version 2 of the License, or
         (at your option) any later version.

         UVMAT is distributed in the hope that it will be useful,
         but WITHOUT ANY WARRANTY; without even the implied warranty of
         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         GNU General Public License (file UVMAT/COPYING.txt) for more details.
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

## CROSS-REFERENCE INFORMATION

This function calls:

- cell2tab 'cell2tab': transform a Matlab cell in a character array suitable for display in a table

This function is called by:

- plot_field 'plot_field': plot any field with the structure defined in the uvmat package

## SOURCE CODE

    0001 %'plot_text': function for displaying the content of a Matlab structure in a figure
    0002 %------------------------------------------------------------------------
    0003 % function hdisplay=plot_text(FieldData,hdisplay_in)
    0004 %
    0005 % OUTPUT:
    0006 % hdisplay: handle of the display edit box
    0007 %
    0008 %  INPUT:
    0009 % FieldData: input Matlab structure
    0010 % hdisplay_in: handles of the display box, if it is not defined create a new figure
    0011 %
    0012 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    0013 %  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
    0014 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    0015 %     This file is part of the toolbox UVMAT.
    0016 %
    0017 %     UVMAT is free software; you can redistribute it and/or modify
    0018 %     it under the terms of the GNU General Public License as published by
    0019 %     the Free Software Foundation; either version 2 of the License, or
    0020 %     (at your option) any later version.
    0021 %
    0022 %     UVMAT is distributed in the hope that it will be useful,
    0023 %     but WITHOUT ANY WARRANTY; without even the implied warranty of
    0024 %     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0025 %     GNU General Public License (file UVMAT/COPYING.txt) for more details.
    0026 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    0027
    0028 function hdisplay=plot_text(FieldData,hdisplay_in)
    0029
    0030 if exist('hdisplay_in','var') & ishandle(hdisplay_in) & isequal(get(hdisplay_in,'Type'),'uicontrol')
    0031     hdisplay=hdisplay_in;
    0032 else
    0033     figure;%create new figure
    0034     hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced');
    0035 end
    0036
    0037 ff=fields(FieldData);%list of field names
    0038 vv=struct2cell(FieldData);%list of field values
    0039
    0040 for icell=1:length(vv)
    0041     Tabcell{icell,1}=ff{icell};
    0042     ss=vv{icell};
    0043     sizss=size(ss);
    0044     if isnumeric(ss)
    0045         if sizss(1)<=1 & length(ss)<5
    0046             displ{icell}=num2str(ss);
    0047         else
    0048             displ{icell}=[class(ss) ', size ' num2str(size(ss))];
    0049         end
    0050     elseif ischar(ss)
    0051         displ{icell}=ss;
    0052     elseif iscell(ss)
    0053         sizcell=size(ss);
    0054         if sizcell(1)==1 & length(sizcell)==2 %line cell
    0055            ssline='{''';
    0056            for icolumn=1:sizcell(2)
    0057                if isnumeric(ss{icolumn})
    0058                    if size(ss{icolumn},1)<=1 & length(ss{icolumn})<5
    0059                       sscolumn=num2str(ss{icolumn});%line vector
    0060                    else
    0061                       sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))];
    0062                    end
    0063                elseif ischar(ss{icolumn})
    0064                    sscolumn=ss{icolumn};
    0065                else
    0066                    sscolumn=class(ss{icolumn});
    0067                end
    0068                if icolumn==1
    0069                    ssline=[ssline sscolumn];
    0070                else
    0071                    ssline=[ssline ''',''' sscolumn];
    0072                end
    0073            end
    0074            displ{icell}=[ssline '''}'];
    0075         else
    0076            displ{icell}=[class(ss) ', size ' num2str(sizcell)];
    0077         end
    0078     else
    0079         displ{icell}=class(ss);
    0080     end
    0081     Tabcell{icell,2}=displ{icell};
    0082 end
    0083 Tabchar=cell2tab(Tabcell,': ');
    0084 set(hdisplay,'String', Tabchar)
    0085
    0086