TreeLayout { public Map<TreeNode, Rectangle2D.Double> getNodeBounds() { if (nodeBounds == null) { nodeBounds = this.useIdentity ? new IdentityHashMap<TreeNode, Rectangle2D.Double>() : new HashMap<TreeNode, Rectangle2D.Double>(); for (Entry<TreeNode, Point2D> entry : positions.entrySet()) { TreeNode node = entry.getKey(); Point2D pos = entry.getValue(); double w = getNodeWidth(node); double h = getNodeHeight(node); double x = pos.getX() - w / 2; double y = pos.getY() - h / 2; nodeBounds.put(node, new Rectangle2D.Double(x, y, w, h)); } } return nodeBounds; } TreeLayout(TreeForTreeLayout<TreeNode> tree,
			NodeExtentProvider<TreeNode> nodeExtentProvider,
			Configuration<TreeNode> configuration, boolean useIdentity);  TreeLayout(TreeForTreeLayout<TreeNode> tree,
			NodeExtentProvider<TreeNode> nodeExtentProvider,
			Configuration<TreeNode> configuration); TreeForTreeLayout<TreeNode> getTree(); NodeExtentProvider<TreeNode> getNodeExtentProvider(); Configuration<TreeNode> getConfiguration(); Rectangle2D getBounds(); int getLevelCount(); double getSizeOfLevel(int level); Map<TreeNode, Rectangle2D.Double> getNodeBounds(); void checkTree(); void dumpTree(PrintStream printStream, DumpConfiguration dumpConfiguration); void dumpTree(PrintStream printStream);  }
@Test public void testGetNodeBoundsIsCached() { StringTreeNode root = new StringTreeNode("root"); StringTreeAsTreeForTreeLayout tree = new StringTreeAsTreeForTreeLayout( root); FixedNodeExtentProvider<StringTreeNode> nodeExtentProvider = new FixedNodeExtentProvider<StringTreeNode>(); DefaultConfiguration<StringTreeNode> config = new DefaultConfiguration<StringTreeNode>( 10, 20); TreeLayout<StringTreeNode> layout = new TreeLayout<StringTreeNode>( tree, nodeExtentProvider, config); Map<StringTreeNode, Double> nodeBounds = layout.getNodeBounds(); assertEquals(nodeBounds, layout.getNodeBounds()); }