/** * 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); }
public Object clone() { Params p = new Params(); p.width = this.width; p.angle = this.angle; return p; } }
/** * @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); }
private void secondWalk(NodeItem n, NodeItem p, double m, int depth) { Params np = getParams(n); setBreadth(n, p, np.prelim + m); setDepth(n, p, m_depths[depth]); if ( n.isExpanded() ) { depth += 1; for ( NodeItem c = (NodeItem)n.getFirstChild(); c != null; c = (NodeItem)c.getNextSibling() ) { secondWalk(c, n, m + np.mod, depth); } } np.clear(); }
/** * @see prefuse.action.Action#run(double) */ public void run(double frac) { Graph g = (Graph)m_vis.getGroup(m_group); initSchema(g.getNodes()); Point2D anchor = getLayoutAnchor(); NodeItem n = getLayoutRoot(); layout(n,anchor.getX(),anchor.getY()); }
/** * Returns the Forces model Layout. */ public ForceDirectedLayout getForceDirectedLayout(String group){ return new ForceDirectedLayout(group); }
private void setBreadth(NodeItem n, NodeItem p, double b) { switch ( m_orientation ) { case Constants.ORIENT_LEFT_RIGHT: case Constants.ORIENT_RIGHT_LEFT: setY(n, p, m_ay + b); break; case Constants.ORIENT_TOP_BOTTOM: case Constants.ORIENT_BOTTOM_TOP: setX(n, p, m_ax + b); break; default: throw new IllegalStateException(); } }
private void layout(NodeItem n, double x, double y) { firstWalk(n); secondWalk(n,null,x,y,1,0); }
/** * Set the position of the given node, given in polar co-ordinates. * @param n the NodeItem to set the position * @param p the referrer parent NodeItem * @param r the radius * @param t the angle theta */ protected void setPolarLocation(NodeItem n, NodeItem p, double r, double t) { setX(n, p, m_origin.getX() + r*Math.cos(t)); setY(n, p, m_origin.getY() + r*Math.sin(t)); }
/** * Clears references to graph tuples. The group and visualization are * retained. */ public void reset() { super.reset(); m_prevRoot = null; }
private Params getParams(VisualItem item) { Params rp = (Params)item.get(PARAMS); if ( rp == null ) { rp = new Params(); item.set(PARAMS, rp); } return rp; }
private Params getParams(NodeItem n) { Params np = (Params)n.get(PARAMS); if ( np == null ) { np = new Params(); n.set(PARAMS, np); } return np; }
private void setDepth(NodeItem n, NodeItem p, double d) { switch ( m_orientation ) { case Constants.ORIENT_LEFT_RIGHT: setX(n, p, m_ax + d); break; case Constants.ORIENT_RIGHT_LEFT: setX(n, p, m_ax - d); break; case Constants.ORIENT_TOP_BOTTOM: setY(n, p, m_ay + d); break; case Constants.ORIENT_BOTTOM_TOP: setY(n, p, m_ay - d); break; default: throw new IllegalStateException(); } }
private void executeShifts(NodeItem n) { double shift = 0, change = 0; for ( NodeItem c = (NodeItem)n.getLastChild(); c != null; c = (NodeItem)c.getPreviousSibling() ) { Params cp = getParams(c); cp.prelim += shift; cp.mod += shift; change += cp.change; shift += cp.shift + change; } }
private NodeItem nextLeft(NodeItem n) { NodeItem c = null; if ( n.isExpanded() ) c = (NodeItem)n.getFirstChild(); return ( c != null ? c : getParams(n).thread ); }
private NodeItem nextRight(NodeItem n) { NodeItem c = null; if ( n.isExpanded() ) c = (NodeItem)n.getLastChild(); return ( c != null ? c : getParams(n).thread ); }
private NodeItem ancestor(NodeItem vim, NodeItem v, NodeItem a) { NodeItem p = (NodeItem)v.getParent(); Params vimp = getParams(vim); if ( vimp.ancestor.getParent() == p ) { return vimp.ancestor; } else { return a; } }