本文整理汇总了Java中prefuse.visual.NodeItem.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java NodeItem.getParent方法的具体用法?Java NodeItem.getParent怎么用?Java NodeItem.getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.visual.NodeItem
的用法示例。
在下文中一共展示了NodeItem.getParent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: layoutRow
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Rectangle2D layoutRow(List row, double w, Rectangle2D r) {
double s = 0; // sum of row areas
Iterator rowIter = row.iterator();
while ( rowIter.hasNext() )
s += ((VisualItem)rowIter.next()).getDouble(AREA);
double x = r.getX(), y = r.getY(), d = 0;
double h = w==0 ? 0 : s/w;
boolean horiz = (w == r.getWidth());
// set node positions and dimensions
rowIter = row.iterator();
while ( rowIter.hasNext() ) {
NodeItem n = (NodeItem)rowIter.next();
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);
}
double nw = n.getDouble(AREA)/h;
if ( horiz ) {
setNodeDimensions(n,nw,h);
d += nw;
} else {
setNodeDimensions(n,h,nw);
d += nw;
}
}
// update space available in rectangle r
if ( horiz )
r.setRect(x,y+h,r.getWidth(),r.getHeight()-h);
else
r.setRect(x+h,y,r.getWidth()-h,r.getHeight());
return r;
}
示例2: getPoint
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Point2D getPoint(NodeItem n, boolean start) {
// find the visible ancestor
NodeItem p = (NodeItem)n.getParent();
if ( start )
for (; p!=null && !p.isStartVisible(); p=(NodeItem)p.getParent());
else
for (; p!=null && !p.isEndVisible(); p=(NodeItem)p.getParent());
if ( p == null ) {
m_point.setLocation(n.getX(), n.getY());
return m_point;
}
// get the vanishing/appearing point
double x = start ? p.getStartX() : p.getEndX();
double y = start ? p.getStartY() : p.getEndY();
Rectangle2D b = p.getBounds();
switch ( m_orientation ) {
case Constants.ORIENT_LEFT_RIGHT:
m_point.setLocation(x+b.getWidth(), y);
break;
case Constants.ORIENT_RIGHT_LEFT:
m_point.setLocation(x-b.getWidth(), y);
break;
case Constants.ORIENT_TOP_BOTTOM:
m_point.setLocation(x, y+b.getHeight());
break;
case Constants.ORIENT_BOTTOM_TOP:
m_point.setLocation(x, y-b.getHeight());
break;
case Constants.ORIENT_CENTER:
m_point.setLocation(x, y);
break;
}
return m_point;
}
示例3: ancestor
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
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;
}
}
示例4: layoutRow
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Rectangle2D layoutRow(List<NodeItem> row, double w, Rectangle2D r) {
double s = 0; // sum of row areas
Iterator<NodeItem> rowIter = row.iterator();
while ( rowIter.hasNext() )
s += rowIter.next().getDouble(AREA);
double x = r.getX(), y = r.getY(), d = 0;
double h = w==0 ? 0 : s/w;
boolean horiz = (w == r.getWidth());
// set node positions and dimensions
rowIter = row.iterator();
while ( rowIter.hasNext() ) {
NodeItem n = rowIter.next();
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);
}
double nw = n.getDouble(AREA)/h;
if ( horiz ) {
setNodeDimensions(n,nw,h);
d += nw;
} else {
setNodeDimensions(n,h,nw);
d += nw;
}
}
// update space available in rectangle r
if ( horiz )
r.setRect(x,y+h,r.getWidth(),r.getHeight()-h);
else
r.setRect(x+h,y,r.getWidth()-h,r.getHeight());
return r;
}
示例5: calcAngularBounds
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
/**
* Calculates the angular bounds of the layout, attempting to
* preserve the angular orientation of the display across transitions.
*/
private void calcAngularBounds(NodeItem r) {
if ( m_prevRoot == null || !m_prevRoot.isValid() || r == m_prevRoot )
{
m_prevRoot = r;
return;
}
// try to find previous parent of root
NodeItem p = m_prevRoot;
while ( true ) {
NodeItem pp = (NodeItem)p.getParent();
if ( pp == r ) {
break;
} else if ( pp == null ) {
m_prevRoot = r;
return;
}
p = pp;
}
// compute offset due to children's angular width
double dt = 0;
Iterator iter = sortedChildren(r);
while ( iter.hasNext() ) {
Node n = (Node)iter.next();
if ( n == p ) break;
dt += ((Params)n.get(PARAMS)).width;
}
double rw = ((Params)r.get(PARAMS)).width;
double pw = ((Params)p.get(PARAMS)).width;
dt = -MathLib.TWO_PI * (dt+pw/2)/rw;
// set angular bounds
m_theta1 = dt + Math.atan2(p.getY()-r.getY(), p.getX()-r.getX());
m_theta2 = m_theta1 + MathLib.TWO_PI;
m_prevRoot = r;
}
示例6: sortedChildren
import prefuse.visual.NodeItem; //导入方法依赖的package包/类
private Iterator sortedChildren(final NodeItem n) {
double base = 0;
// update base angle for node ordering
NodeItem p = (NodeItem)n.getParent();
if ( p != null ) {
base = normalize(Math.atan2(p.getY()-n.getY(), p.getX()-n.getX()));
}
int cc = n.getChildCount();
if ( cc == 0 ) return null;
NodeItem c = (NodeItem)n.getFirstChild();
// TODO: this is hacky and will break when filtering
// how to know that a branch is newly expanded?
// is there an alternative property we should check?
if ( !c.isStartVisible() ) {
// use natural ordering for previously invisible nodes
return n.children();
}
double angle[] = new double[cc];
final int idx[] = new int[cc];
for ( int i=0; i<cc; ++i, c=(NodeItem)c.getNextSibling() ) {
idx[i] = i;
angle[i] = normalize(-base +
Math.atan2(c.getY()-n.getY(), c.getX()-n.getX()));
}
ArrayLib.sort(angle, idx);
// return iterator over sorted children
return new Iterator() {
int cur = 0;
public Object next() {
return n.getChild(idx[cur++]);
}
public boolean hasNext() {
return cur < idx.length;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}