/** * @see prefuse.action.Action#run(double) */ public void run(double frac) { // setup NodeItem root = getLayoutRoot(); Rectangle2D b = getLayoutBounds(); m_r.setRect(b.getX(), b.getY(), b.getWidth()-1, b.getHeight()-1); // process size values computeAreas(root); // layout root node setX(root, null, 0); setY(root, null, 0); root.setBounds(0, 0, m_r.getWidth(), m_r.getHeight()); // layout the tree updateArea(root, m_r); layout(root, m_r); }
/** * Creates a new SquarifiedTreeMapLayout with the specified spacing between * parent areas and their enclosed children. * @param frame the amount of desired framing space between * parent areas and their enclosed children. * @param group the data group to layout. Must resolve to a Graph instance. */ public SquarifiedTreeMapLayout(String group, double frame) { super(group); setFrameWidth(frame); }
/** * 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); } } }
NodeItem p = (NodeItem)n.getParent(); if ( horiz ) { setX(n, p, x+d); setY(n, p, y); } else { setX(n, p, x); setY(n, p, y+d); setNodeDimensions(n,nw,h); d += nw; } else { setNodeDimensions(n,h,nw); d += nw;
Rectangle2D b = getLayoutBounds(); double area = (b.getWidth()-1)*(b.getHeight()-1); double scale = area/root.getDouble(AREA);