本文整理汇总了Java中javax.swing.tree.MutableTreeNode类的典型用法代码示例。如果您正苦于以下问题:Java MutableTreeNode类的具体用法?Java MutableTreeNode怎么用?Java MutableTreeNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MutableTreeNode类属于javax.swing.tree包,在下文中一共展示了MutableTreeNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
private void refresh(DefaultTreeModel m,
ServerStatus.ModuleSummary[] modules) {
final MutableTreeNode root = (MutableTreeNode) m.getRoot();
totalPlayers = 0;
while (root.getChildCount() > 0) {
m.removeNodeFromParent((MutableTreeNode) root.getChildAt(0));
}
if (modules.length == 0) {
final DefaultMutableTreeNode n = new DefaultMutableTreeNode(
Resources.getString("Chat.no_connections")); //$NON-NLS-1$
n.setAllowsChildren(false);
}
else {
for (ServerStatus.ModuleSummary s : modules) {
m.insertNodeInto(createNode(s), root, root.getChildCount());
}
}
// append total number of players on server to root node
root.setUserObject(
Resources.getString(Resources.VASSAL) + " (" + totalPlayers + ")");
}
示例2: sortNodesDescending
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
/**
* Sort nodes descending.
*
* @param node the node
* @param treeModel the tree model
*/
private void sortNodesDescending(DefaultMutableTreeNode node, DefaultTreeModel treeModel) {
boolean unsorted = true;
while (unsorted) {
unsorted = false;
for (int i = 0; i < node.getChildCount() - 1; i++) {
ThreadInfoStorageAgent tiaFirst = (ThreadInfoStorageAgent) ((DefaultMutableTreeNode) node.getChildAt(i)).getUserObject();
ThreadInfoStorageAgent tiaSecond = (ThreadInfoStorageAgent) ((DefaultMutableTreeNode) node.getChildAt(i+1)).getUserObject();
if (tiaFirst.getXYSeriesMap().get("TOTAL_CPU_SYSTEM_TIME").getMaxY() < tiaSecond.getXYSeriesMap().get("TOTAL_CPU_SYSTEM_TIME").getMaxY()) {
treeModel.insertNodeInto((MutableTreeNode) node.getChildAt(i+1), node, i);
unsorted = true;
}
}
}
}
示例3: rangeAxisConfigAdded
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
private void rangeAxisConfigAdded(int index, RangeAxisConfig rangeAxis) {
RangeAxisConfigTreeNode newChild = new RangeAxisConfigTreeNode(rangeAxis);
insertNodeInto(newChild, (MutableTreeNode) root, index + NUMBER_OF_PERMANENT_DIMENSIONS);
List<ValueSource> rangeAxisValueSources = rangeAxis.getValueSources();
if (rangeAxis.getValueSources().size() > 0) {
int idx = 0;
// add new value source child nodes
for (ValueSource source : rangeAxisValueSources) {
valueSourceAdded(idx, source, rangeAxis);
++idx;
}
} else {
// change selection path
TreePath pathToNewChild = new TreePath(getPathToRoot(newChild));
makeVisibleAndSelect(pathToNewChild);
}
}
示例4: rangeAxisConfigRemoved
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
private void rangeAxisConfigRemoved(int index, RangeAxisConfig rangeAxis) {
removeNodeFromParent((MutableTreeNode) root.getChildAt(index + NUMBER_OF_PERMANENT_DIMENSIONS));
reload();
plotConfigTree.expandAll();
// Acquire new selection element
int childCount = root.getChildCount();
Object newSelection = null;
if (childCount > NUMBER_OF_PERMANENT_DIMENSIONS) {
newSelection = root.getChildAt(childCount - 1);
} else {
newSelection = root;
}
// change selection path
TreePath path = new TreePath(getPathToRoot((TreeNode) newSelection));
makeVisibleAndSelect(path);
}
示例5: hasMain
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
/**
* A method to check whether the file has a main method in it or not
* @param file a parameter to take the file to check
* @return true if the file has a main method; false, if it hasn't
*/
public boolean hasMain( File file) {
int index = getRow( file);
if (index != -1) {
MutableTreeNode node = ((MutableTreeNode) rootNode.getChildAt(index));
if (node instanceof ClassNode) {
for (int i = 0; i < ((ClassNode) node).getChildCount(); i++) {
TreeNode treeNode = (((ClassNode) node).getChildAt(i));
if (treeNode instanceof MethodNode) {
MethodDeclaration metDec = ((MethodNode) treeNode).metDec;
if (metDec.getNameAsString().equals("main") &&
metDec.isPublic() && metDec.isStatic()) {
ArrayList<Parameter> parameters = new ArrayList<Parameter>(metDec.getParameters());
if (parameters.size() == 1 && parameters.get(0).toString().startsWith("String[]"))
return true;
}
}
}
}
}
return false;
}
示例6: sort
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
public static void sort(DefaultMutableTreeNode parent) {
int n = parent.getChildCount();
for (int i = 0; i < n - 1; i++) {
int min = i;
for (int j = i + 1; j < n; j++) {
if (tnc.compare((DefaultMutableTreeNode) parent.getChildAt(min), (DefaultMutableTreeNode) parent.getChildAt(j)) > 0) {
min = j;
}
}
if (i != min) {
MutableTreeNode a = (MutableTreeNode) parent.getChildAt(i);
MutableTreeNode b = (MutableTreeNode) parent.getChildAt(min);
parent.insert(b, i);
parent.insert(a, min);
updateTree = true;
}
}
}
示例7: insertSorted
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
/**
* Insert child node using a sorting based on the name of the child node (toString)
* Uses a natural ordering sort
* @param child Child node to insert.
*/
public void insertSorted(MutableTreeNode child) {
Comparator<TreeNode> comparator = this.comparator;
// binary search for the right position to insert
int lower = 0;
int upper = getChildCount();
while (lower < upper) {
int mid = (lower + upper) / 2;
TreeNode midChild = getChildAt(mid);
if (comparator.compare(child, midChild) < 0) {
upper = mid;
} else {
lower = mid + 1;
}
}
insert(child, lower);
}
示例8: insertInOrder
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void insertInOrder(MutableTreeNode newChild)
{
if( !Check.isEmpty(children) )
{
List<MutableTreeNode> mtns = new ArrayList<MutableTreeNode>(children);
mtns.add(newChild);
Collections.sort(mtns, new NumberStringComparator<MutableTreeNode>());
removeAllChildren();
for( MutableTreeNode mtn : mtns )
{
add(mtn);
}
}
else
{
add(newChild);
}
}
示例9: display
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
/**
* Method to display graphically the Trie by means of a TreeModel
* @param model TreeModel when we want to insert the Trie nodes
* @param p TreeNode for the TreeModel
*/
private static void display(Trie frequentAtomsTrie, DefaultTreeModel model, MutableTreeNode p) {
List<TrieNode> nodes = frequentAtomsTrie.nodes;
if (nodes != null) {
//For each node
for (int i = 0; i < nodes.size(); i++) {
TrieNode node = nodes.get(i);
Trie child = node.getChild();
//We create a new TreeNode composed of the pair and the list of appearances
DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(node.getPair().toString()+" ("+child.getSupport()+")");
//And we insert it in the TreeModel
model.insertNodeInto(currentNode, p, i);
//And we go on doing the same process with the child
j++;
if(j <3) {
display(child, model, currentNode);
}
j--;
}
}
}
示例10: display
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
/**
* Method to display graphically the Trie by means of a TreeModel
* @param model TreeModel when we want to insert the Trie nodes
* @param p TreeNode for the TreeModel
*/
private void display(DefaultTreeModel model, MutableTreeNode p) {
if (nodes != null) {
//For each node
for (int i = 0; i < nodes.size(); i++) {
TrieNode node = nodes.get(i);
Trie child = node.getChild();
//We create a new TreeNode composed of the pair and the list of appearances
DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(node.getPair().toString() + child.appearingIn);
//And we insert it in the TreeModel
model.insertNodeInto(currentNode, p, i);
//And we go on doing the same process with the child
child.display(model, currentNode);
}
}
}
示例11: ServerDirectoryTreeModel
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
public ServerDirectoryTreeModel (MutableTreeNode root, DirectoryType[] dList)
{
super(root);
int currentIndex = 0;
dirList = dList;
/*
System.out.println("create directory list .................");
for (int i=0; i<dList.length; i++) {
System.out.print("[ " + i + " ] " + dList[i].nodeName);
for (int j=0; j<dList[i].childnodeNames.length; j++)
System.out.print(":" + dList[i].childnodeNames[j]);
System.out.println("");
}
*/
for (int i=0; i<dirList[0].childnodeNames.length; i++) {
currentIndex = addNewNode(root, dirList[0].childnodeNames[i], currentIndex);
}
}
示例12: insert
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
public void insert(MutableTreeNode newChild, int childIndex)
{
if(newChild == null)
return;
if(mappedNodes == null) {
mappedNodes = createNodeMap();
}
else if(mappedNodes.indexOf(newChild) != -1)
return;
super.insert(newChild, childIndex);
if (newChild instanceof NameTreeNode)
mappedNodes.add((NameTreeNode)newChild);
}
示例13: setParent
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
public void setParent(MutableTreeNode newParent)
{
super.setParent(newParent);
setToolTipText(null);
if(isLeaf())
return;
Enumeration<?> descendants = breadthFirstEnumeration();
while(descendants.hasMoreElements()) {
MutableTreeNode descendant =
(MutableTreeNode)descendants.nextElement();
if(descendant instanceof AbstractNameTreeNode) {
((AbstractNameTreeNode<?>)descendant).setToolTipText(null);
}
}
}
示例14: removeAllChildren
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
protected void removeAllChildren(MutableTreeNode parentNode,
DefaultTreeModel tree)
{
Enumeration<?> enm = parentNode.children();
MutableTreeNode[] toRemove =
new MutableTreeNode[parentNode.getChildCount()];
int i = 0;
while(enm.hasMoreElements()) {
toRemove[i++] =
(MutableTreeNode)enm.nextElement();
}
for(i = 0; i < toRemove.length; i++) {
tree.removeNodeFromParent(toRemove[i]);
toRemove[i] = null;
}
toRemove = null;
}
示例15: checkForDuplicateThreadItem
import javax.swing.tree.MutableTreeNode; //导入依赖的package包/类
private boolean checkForDuplicateThreadItem(Map directChildMap, DefaultMutableTreeNode node1) {
ThreadInfo mi1 = (ThreadInfo) node1.getUserObject();
String name1 = mi1.getName();
for (Iterator iter2 = directChildMap.entrySet().iterator(); iter2.hasNext();) {
DefaultMutableTreeNode node2 = (DefaultMutableTreeNode) ((Map.Entry) iter2.next()).getValue();
if (node1 == node2) {
continue;
}
ThreadInfo mi2 = (ThreadInfo) node2.getUserObject();
if (name1.equals(mi2.getName()) && node2.getChildCount() > 0) {
node1.add((MutableTreeNode) node2.getFirstChild());
iter2.remove();
return true;
}
}
return false;
}