Home > m > gui > ao_browser > ltpda_uitreenode.m

ltpda_uitreenode

PURPOSE ^

WARNING: This feature is not supported in MATLAB

SYNOPSIS ^

function node = ltpda_uitreenode(value, string, icon, isLeaf)

DESCRIPTION ^

 WARNING: This feature is not supported in MATLAB
 and the API and functionality may change in a future release.

   UITREENODE(Value, Description, Icon, Leaf)
   creates a tree node object for the uitree with the specified
   properties. All properties must be specified for the successful
   creation of a node object.

   Value can be a string or handle represented by this node.
   Description is a string which is used to identify the node.
   Icon can be a qualified pathname to an image to be used as an icon
   for this node. It may be set to [] to use default icons.
   Leaf can be true or false to denote whether this node has children.

   Example:
     t = uitree('Root', 'D:\')

     %Creates a uitree widget in a figure window with which acts as a
     %directory browser with the D: drive as the root node.

     surf(peaks)
     f = figure
     t = uitree(f, 'Root', 0)

     %Creates a uitree object in the specified figure window which acts as
     %a MATLAB hierarchy browser with the MATLAB root (0) as the root node.

     root = uitreenode('S:\', 'S', [], false);
     t = uitree('Root', root, 'ExpandFcn', @myExpfcn, ...
                'SelectionChangeFcn', 'disp(''Selection Changed'')');

     %Creates a uitree object with the specified root node and a custom
     %function to return child nodes for any given node. The function
     %myExpfcn is a user defined m-file in the MATLAB path.

     % This function should be added to the path
     % ---------------------------------------------
     function nodes = myExpfcn(tree, value)

     try
         count = 0;
         ch = dir(value);

         for i=1:length(ch)
             if (any(strcmp(ch(i).name, {'.', '..', ''})) == 0)
                 count = count + 1;
                 if ch(i).isdir
                     iconpath = [matlabroot, '/toolbox/matlab/icons/foldericon.gif'];
                 else
                     iconpath = [matlabroot, '/toolbox/matlab/icons/pageicon.gif'];
                 end
                 nodes(count) = uitreenode([value, ch(i).name, filesep], ...
                     ch(i).name, iconpath, ~ch(i).isdir);
             end
         end
     catch
         error(['The uitree node type is not recognized. You may need to ', ...
             'define an ExpandFcn for the nodes.']);
     end

     if (count == 0)
         nodes = [];
     end
     % ---------------------------------------------
       
   See also UITREE, UITABLE, JAVACOMPONENT

 Copyright 2003-2006 The MathWorks, Inc.

 Adapted for LTPDA

 $Id: ltpda_uitreenode.m,v 1.2 2008/01/22 20:45:22 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function node = ltpda_uitreenode(value, string, icon, isLeaf)
0002 % WARNING: This feature is not supported in MATLAB
0003 % and the API and functionality may change in a future release.
0004 %
0005 %   UITREENODE(Value, Description, Icon, Leaf)
0006 %   creates a tree node object for the uitree with the specified
0007 %   properties. All properties must be specified for the successful
0008 %   creation of a node object.
0009 %
0010 %   Value can be a string or handle represented by this node.
0011 %   Description is a string which is used to identify the node.
0012 %   Icon can be a qualified pathname to an image to be used as an icon
0013 %   for this node. It may be set to [] to use default icons.
0014 %   Leaf can be true or false to denote whether this node has children.
0015 %
0016 %   Example:
0017 %     t = uitree('Root', 'D:\')
0018 %
0019 %     %Creates a uitree widget in a figure window with which acts as a
0020 %     %directory browser with the D: drive as the root node.
0021 %
0022 %     surf(peaks)
0023 %     f = figure
0024 %     t = uitree(f, 'Root', 0)
0025 %
0026 %     %Creates a uitree object in the specified figure window which acts as
0027 %     %a MATLAB hierarchy browser with the MATLAB root (0) as the root node.
0028 %
0029 %     root = uitreenode('S:\', 'S', [], false);
0030 %     t = uitree('Root', root, 'ExpandFcn', @myExpfcn, ...
0031 %                'SelectionChangeFcn', 'disp(''Selection Changed'')');
0032 %
0033 %     %Creates a uitree object with the specified root node and a custom
0034 %     %function to return child nodes for any given node. The function
0035 %     %myExpfcn is a user defined m-file in the MATLAB path.
0036 %
0037 %     % This function should be added to the path
0038 %     % ---------------------------------------------
0039 %     function nodes = myExpfcn(tree, value)
0040 %
0041 %     try
0042 %         count = 0;
0043 %         ch = dir(value);
0044 %
0045 %         for i=1:length(ch)
0046 %             if (any(strcmp(ch(i).name, {'.', '..', ''})) == 0)
0047 %                 count = count + 1;
0048 %                 if ch(i).isdir
0049 %                     iconpath = [matlabroot, '/toolbox/matlab/icons/foldericon.gif'];
0050 %                 else
0051 %                     iconpath = [matlabroot, '/toolbox/matlab/icons/pageicon.gif'];
0052 %                 end
0053 %                 nodes(count) = uitreenode([value, ch(i).name, filesep], ...
0054 %                     ch(i).name, iconpath, ~ch(i).isdir);
0055 %             end
0056 %         end
0057 %     catch
0058 %         error(['The uitree node type is not recognized. You may need to ', ...
0059 %             'define an ExpandFcn for the nodes.']);
0060 %     end
0061 %
0062 %     if (count == 0)
0063 %         nodes = [];
0064 %     end
0065 %     % ---------------------------------------------
0066 %
0067 %   See also UITREE, UITABLE, JAVACOMPONENT
0068 %
0069 % Copyright 2003-2006 The MathWorks, Inc.
0070 %
0071 % Adapted for LTPDA
0072 %
0073 % $Id: ltpda_uitreenode.m,v 1.2 2008/01/22 20:45:22 hewitson Exp $
0074 %
0075 
0076 import com.mathworks.hg.peer.UITreeNode;
0077 node = handle(UITreeNode(value, string, icon, isLeaf));
0078 schema.prop(node, 'UserData', 'MATLAB array');

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003