本文整理匯總了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;
}