private void setNodeDimensions(NodeItem n, double w, double h) { n.setBounds(n.getX(), n.getY(), w, h); }
private void arrangeChildVertically( NodeItem parent ) { double maxW = 0; for( int i = 0; i < parent.getChildCount(); i++ ) { NodeItem node = (NodeItem) parent.getChild( i ); Rectangle2D bounds = node.getBounds(); maxW = Math.max( maxW, bounds.getWidth() ); } for( int i = 0; i < parent.getChildCount(); i++ ) { NodeItem node = (NodeItem) parent.getChild( i ); Rectangle2D bounds = node.getBounds(); node.setBounds( bounds.getX(), bounds.getY(), maxW, bounds.getHeight() ); } }
private void arrangeChildHorizontally( NodeItem parent ) { double maxH = 0; for( int i = 0; i < parent.getChildCount(); i++ ) { NodeItem node = (NodeItem) parent.getChild( i ); Rectangle2D bounds = node.getBounds(); maxH = Math.max( maxH, bounds.getHeight() ); } for( int i = 0; i < parent.getChildCount(); i++ ) { NodeItem node = (NodeItem) parent.getChild( i ); Rectangle2D bounds = node.getBounds(); node.setBounds( bounds.getX(), bounds.getY(), bounds.getWidth(), maxH ); } } }
/** * @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); }