分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

下面的例子中将获取到JTree中的每一个节点并按树状结构打印出来:

public void testMain(Object[] args)

{

//Turn off Log Viewer for this example

setOption(IOptionName.BRING_UP_LOGVIEWER, false);

//Start Classics Java Application

startApp("ClassicsJavaA");

// Frame: ClassicsCD

tree2().waitForExistence();

//Display available test data types available from tree

System.out.println ("Available Tree Data Types: " + tree2().getTestDataTypes());

//Declare variables for tree

ITestDataTree cdTree;

ITestDataTreeNodes cdTreeNodes;

ITestDataTreeNode[] cdTreeNode;

//Variables to hold tree data

cdTree = (ITestDataTree)tree2().getTestData("tree");

cdTreeNodes = cdTree.getTreeNodes();

cdTreeNode = cdTreeNodes.getRootNodes();

//Print out total number of nodes

System.out.println ("Tree Total Node Count: " + cdTreeNodes.getNodeCount());

System.out.println ("Tree Root Node Count : " + cdTreeNodes.getRootNodeCount());

//Iterate through tree branches; this is a recursive method.

for (int i = 0;i<cdTreeNode.length;++i)

showTree(cdTreeNode[i], 0);

//Shut down Classics Java Application

classicsJava(ANY,MAY_EXIT).close();

}

void showTree(ITestDataTreeNode node, int indent)

{

//Recursive method to print out tree nodes with proper indenting.

//Determine number of tabs to use - to properly indent tree

int tabCount = ( indent < tabs.length() ? indent :

tabs.length() );

//Print out node name + number of children

System.out.println(tabs.substring(0, tabCount) + node.getNode() + " (" + node.getChildCount() + "children)" );

//Determine if node has children; recursively call this same

//method to print out child nodes.

ITestDataTreeNode[] children = node.getChildren();

int childCount = ( children != null ? children.length : 0 );

for ( int i = 0; i < childCount; ++i )

showTree(children[i], indent+1);

}

//String of tabs used to indent tree view

final String tabs = "/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t/t";

输出:

Available Tree Data Types: {selected=选中的树层次结构, tree=树层次结构}

Tree Total Node Count: 20

Tree Root Node Count : 1

Composers (5children)

Schubert (3children)

String Quartets Nos. 4 & 14 (0children)

Die schone Mullerin, Op. 25 (0children)

Symphonies Nos. 5 & 9 (0children)

Haydn (3children)

Symphonies Nos. 99 & 101 (0children)

Symphonies Nos. 94 & 98 (0children)

Violin Concertos (0children)

Bach (2children)

Brandenburg Concertos Nos. 1 & 3 (0children)

Violin Concertos (0children)

Beethoven (3children)

Symphony No. 7 (0children)

Symphony No. 9 (0children)

Symphony No. 5 (0children)

Mozart (3children)

Symphony No. 34 (0children)

Symphony in C, No. 41: Jupiter (0children)

Concerto in D for Piano (0children)

关于ITestDataTree 、 ITestDataTreeNodes 、ItestDataTreeNode的使用方法可参考RFT的帮助文档:

ITestDataTree

All Superinterfaces:

ITestData

public interface ITestDataTree
extends ITestData

The base-level tree verification-point interface. This interface represents a property set and entry points to the tree nodes.

Since:

RFT1.0

Method Summary

 boolean

getOrdered()
          Returns the setting of the Ordered property.

 ITestDataTreeNodes

getTreeNodes()
          Returns the nodes of a tree structure.

 void

setOrdered(boolean ordered)
          Sets the tree to be compared in either an ordered or unordered fashion.

 void

setTreeNodes(ITestDataTreeNodes treeNodes)
          Sets the nodes of a tree structure.

ITestDataTreeNodes

public interface ITestDataTreeNodes

Enables an appropriate display object to be associated with the tree nodes. This is the container class for the Nodes of a tree-type verification point. Without this container class, the generic property display does not know how to display the nodes.

Since:

RFT1.0

Method Summary

 int

getNodeCount()
          Returns the number of nodes in the tree hierarchy.

 int

getRootNodeCount()
          Returns the number of root nodes.

 ITestDataTreeNode[]

getRootNodes()
          Returns the root nodes of a tree structure.

 ITestDataTree

getTree()
          This method returns the reference to tree.

 void

setRootNodes(ITestDataTreeNode[] rootNodes)
          Sets the root nodes of a tree structure.

 void

setTree(ITestDataTree tree)
          This method sets the reference to tree.

ITestDataTreeNode

public interface ITestDataTreeNode

Provides the necessary methods for representing a node in a Tree test-data object.

Since:

RFT1.0

Method Summary

 int

getChildCount()
          Returns the number of child nodes from this node.

 ITestDataTreeNode[]

getChildren()
          Returns the child nodes relative to this node.

 boolean

getMasked()
          Returns true if this node in the tree should be masked from comparison in a verification-point replay.

 java.lang.Object

getNode()
          Returns a description of the node itself.

 ITestDataTreeNode

getParent()
          Returns the parent node of a tree structure.

 ITestDataTree

getTree()
          This method returns the reference to tree.

 void

setChildren(ITestDataTreeNode[] children)
          Sets the child nodes of this node.

 void

setMasked(boolean masked)
          Sets the masked attribute of the element of this node.

 void

setNode(java.lang.Object node)
          Sets a description of the node itself.

 void

setParent(ITestDataTreeNode parent)
          Sets the parent node of a tree structure.

 void

setTree(ITestDataTree tree)
          This method sets the reference to tree.

分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

如何遍历JTree的每一个节点相关推荐

  1. 二叉树中序遍历的下一个节点

    题目描述: 给定一棵二叉树和其中的一个节点,如何找出中序遍历序列的下一个节点?树中的节点除了有两个分别指向左.右子节点的指针,还有一个指向父节点的指针. 解题思路: 这道题意即:给定一个节点,按照中序 ...

  2. 算法练习day10——190328(二叉树的先序、 中序、 后序遍历, 包括递归方式和非递归方式、找到一个节点的后继节点、二叉树的序列化和反序列化)

    1.实现二叉树的先序. 中序. 后序遍历, 包括递归方式和非递归方式 1.1 访问节点的顺序 节点访问顺序如下图所示: 访问顺序:1 2 4 4 4 2 5 5 5 2 1 3 6 6 6 3 7 7 ...

  3. 【二叉树】剑指offer:二叉树中序遍历的下一个节点

    思路一:vector存放中序遍历,然后查找输出 注意: pNode是待查找节点,因为要通过父节点遍历二叉树,所以首先要找到父节点 TreeNode *temp=t; TreeNode *root; w ...

  4. react 递归遍历四层树结构 遍历分支中的最后一个节点_图解:数据结构中的 6 种树,你心中有数吗?...

    (给算法爱好者加星标,修炼编程内功) 来源:LemonCoder/后端技术学堂(本文来自作者投稿) 数据结构这门课程是计算机相关专业的基础课,数据结构指的是数据在计算机中的存储.组织方式. 我们在学习 ...

  5. 链表相关操作:创建链表、遍历链表、求链表长度、链表中删除一个节点、链表中插入一个节点、反转单链表...

    1 #include<iostream> 2 #include<stdlib.h> 3 4 typedef struct node 5 { 6 int data; 7 stru ...

  6. 剑指offer:二叉树的下一个节点

    题目描述 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回.注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针. /* struct TreeLinkNode {int ...

  7. 在单链表的第i个位置后插入一个节点(阿里+腾讯等面试题总结)

    时间:2014.04.26 地点:基地 ------------------------- 一.题目 题目是非常easy和基础,就是在单链表的第i个位置后插入一个节点.要求写代码,5分钟之内完毕.面腾 ...

  8. 如何删除链表的最后一个节点_面试:删除链表的节点

    给定单向链表的头指针和一个要删除的节点的值,定义一个函数删除该节点.返回删除后的链表的头节点.注意:此题对比原题有改动示例 1:输入: head = [4,5,1,9], val = 5 输出: [4 ...

  9. 每天一道LeetCode-----计算二叉树的最大路径和,路径只需要从一个节点到达另一个节点,无其他要求

    Binary Tree Maximum Path Sum 原题链接Binary Tree Maximum Path Sum 给定一个二叉树,计算二叉树中最长的路径和,路径只需要从一个节点到另一个节点, ...

  10. 每天一道LeetCode-----为二叉树增加next节点,指向同一层的下一个节点

    Populating Next Right Pointers in Each Node 原题链接Populating Next Right Pointers in Each Node 将完全二叉树每个 ...

最新文章

  1. 关于Google Map API V2 版本的定位与导航
  2. Scrumban-拉动企业渐进式变革的利器
  3. ADO.NET学习笔记--数据分组
  4. linux 怎么配置apache,在Linux下配置Apache Web服务
  5. 机器学习偏差方差_机器学习101 —偏差方差难题
  6. Hadoop3.0 WordCount测试一直Accept 状态,Nodes of the cluster 页面node列表个数为0
  7. JS逆向笔记-记录某测试论坛的js逆向练习
  8. 多实例多进程网络编程PHP,php socket网络编程基础知识(四):多进程
  9. apk、ipa包size优化晋级手段
  10. android 球形进度,android仿360手机卫士的自定义波浪球形进度View 滚动痕迹
  11. c语言高斯法解方程,用C语言实现解线性方程组的高斯消去法
  12. [微信]微信小程序开发--用户昵称中带有emoji表情的处理方法
  13. 微信定位真的泄露了你的精确位置
  14. 南京航空航天大学计算机考研经验分享,南京航空航天大学计算机考研试题.pdf...
  15. 图论:图的四种最短路径算法
  16. 3.java 模拟保皇游戏开始的发牌过程
  17. Ubuntu20.04 idea/pycharm 搜狗中文输入法不跟随光标问题
  18. Microsoft Query:基本操作
  19. root精灵无法root,Root精灵
  20. 计算机硬盘和内存特点,电脑内存和硬盘的区别

热门文章

  1. C#- XPath教程
  2. R与Python手牵手:多格式文件导入与爬虫
  3. 定量论文:探究「健康水平、婚姻状况」对幸福感的影响
  4. The Game Of Life – 数据结构与算法的敲门砖
  5. 什么是restful api
  6. ios中input输入无效
  7. fastdfs5.10 centos6.9 安装配置
  8. c++中的c_str()函数
  9. 面向对象-java控制台计算器简单实现[50行]
  10. mongodb(分片)