< prev index next >
src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java
Print this page
rev 1527 : 6727662: Code improvement and warnings removing from swing packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: malenkov
@@ -54,11 +54,11 @@
public class VariableHeightLayoutCache extends AbstractLayoutCache {
/**
* The array of nodes that are currently visible, in the order they
* are displayed.
*/
- private Vector visibleNodes;
+ private Vector<Object> visibleNodes;
/**
* This is set to true if one of the entries has an invalid size.
*/
private boolean updateNodeSizes;
@@ -77,24 +77,24 @@
private Rectangle boundsBuffer;
/**
* Maps from <code>TreePath</code> to a <code>TreeStateNode</code>.
*/
- private Hashtable treePathMapping;
+ private Hashtable<TreePath, TreeStateNode> treePathMapping;
/**
* A stack of stacks.
*/
- private Stack tempStacks;
+ private Stack<Stack<TreePath>> tempStacks;
public VariableHeightLayoutCache() {
super();
- tempStacks = new Stack();
- visibleNodes = new Vector();
+ tempStacks = new Stack<Stack<TreePath>>();
+ visibleNodes = new Vector<Object>();
boundsBuffer = new Rectangle();
- treePathMapping = new Hashtable();
+ treePathMapping = new Hashtable<TreePath, TreeStateNode>();
}
/**
* Sets the <code>TreeModel</code> that will provide the data.
*
@@ -702,11 +702,11 @@
/**
* Returns the node previously added for <code>path</code>. This may
* return null, if you to create a node use getNodeForPath.
*/
private TreeStateNode getMapping(TreePath path) {
- return (TreeStateNode)treePathMapping.get(path);
+ return treePathMapping.get(path);
}
/**
* Retursn the bounds for row, <code>row</code> by reference in
* <code>placeIn</code>. If <code>placeIn</code> is null a new
@@ -822,17 +822,17 @@
return null;
return node;
}
// Check all the parent paths, until a match is found.
- Stack paths;
+ Stack<TreePath> paths;
if(tempStacks.size() == 0) {
- paths = new Stack();
+ paths = new Stack<TreePath>();
}
else {
- paths = (Stack)tempStacks.pop();
+ paths = tempStacks.pop();
}
try {
paths.push(path);
path = path.getParentPath();
@@ -841,11 +841,11 @@
node = getMapping(path);
if(node != null) {
// Found a match, create entries for all paths in
// paths.
while(node != null && paths.size() > 0) {
- path = (TreePath)paths.pop();
+ path = paths.pop();
node.getLoadedChildren(shouldCreate);
int childIndex = treeModel.
getIndexOfChild(node.getUserObject(),
path.getLastPathComponent());
< prev index next >