/** * Compute the tree map layout. */ private void layout(NodeItem p, Rectangle2D r) { // create sorted list of children Iterator childIter = p.children(); while ( childIter.hasNext() ) m_kids.add(childIter.next()); Collections.sort(m_kids, s_cmp); // do squarified layout of siblings double w = Math.min(r.getWidth(),r.getHeight()); squarify(m_kids, m_row, w, r); m_kids.clear(); // clear m_kids // recurse childIter = p.children(); while ( childIter.hasNext() ) { NodeItem c = (NodeItem)childIter.next(); if ( c.getChildCount() > 0 && c.getDouble(AREA) > 0 ) { updateArea(c,r); layout(c, r); } } }
/** * Traverse tree descendants. */ private void visitDescendants(NodeItem p, NodeItem skip) { int lIdx = ( skip == null ? 0 : p.getChildIndex(skip) ); Iterator children = p.children(); p.setExpanded(children.hasNext()); for ( int i=0; children.hasNext(); ++i ) { NodeItem c = (NodeItem)children.next(); if ( c == skip ) { continue; } int doi = (int)(p.getDOI()-1); visit(c, c, doi, Math.abs(lIdx-i)); if ( doi > m_threshold ) visitDescendants(c, null); } }
private void firstWalk(NodeItem n) { Params np = getParams(n); np.d = 0; double s = 0; Iterator childIter = n.children(); while ( childIter.hasNext() ) { NodeItem c = (NodeItem)childIter.next(); if ( !c.isVisible() ) continue; firstWalk(c); Params cp = getParams(c); np.d = Math.max(np.d,cp.r); cp.a = Math.atan(((double)cp.r)/(np.d+cp.r)); s += cp.a; } adjustChildren(np, s); setRadius(np); }
/** * Computes relative measures of the angular widths of each * expanded subtree. Node diameters are taken into account * to improve space allocation for variable-sized nodes. * * This method also updates the base angle value for nodes * to ensure proper ordering of nodes. */ private double calcAngularWidth(NodeItem n, int d) { if ( d > m_maxDepth ) m_maxDepth = d; double aw = 0; Rectangle2D bounds = n.getBounds(); double w = bounds.getWidth(), h = bounds.getHeight(); double diameter = d==0 ? 0 : Math.sqrt(w*w+h*h) / d; if ( n.isExpanded() && n.getChildCount() > 0 ) { Iterator childIter = n.children(); while ( childIter.hasNext() ) { NodeItem c = (NodeItem)childIter.next(); aw += calcAngularWidth(c,d+1); } aw = Math.max(diameter, aw); } else { aw = diameter; } ((Params)n.get(PARAMS)).width = aw; return aw; }
private void updateLocations(NodeItem n, double dx, double dy) { double x = n.getX(), y = n.getY(); n.setStartX(x); n.setStartY(y); x += dx; y += dy; n.setX(x); n.setY(y); n.setEndX(x); n.setEndY(y); Iterator children = n.children(); while ( children.hasNext() ) updateLocations((NodeItem)children.next(), dx, dy); }
return n.children();