本文整理汇总了Java中prefuse.visual.EdgeItem.getTargetItem方法的典型用法代码示例。如果您正苦于以下问题:Java EdgeItem.getTargetItem方法的具体用法?Java EdgeItem.getTargetItem怎么用?Java EdgeItem.getTargetItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.visual.EdgeItem
的用法示例。
在下文中一共展示了EdgeItem.getTargetItem方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calcAttraction
import prefuse.visual.EdgeItem; //导入方法依赖的package包/类
public void calcAttraction(EdgeItem e) {
NodeItem n1 = e.getSourceItem();
Params n1p = getParams(n1);
NodeItem n2 = e.getTargetItem();
Params n2p = getParams(n2);
double xDelta = n1p.loc[0] - n2p.loc[0];
double yDelta = n1p.loc[1] - n2p.loc[1];
double deltaLength = Math.max(EPSILON,
Math.sqrt(xDelta*xDelta + yDelta*yDelta));
double force = (deltaLength*deltaLength) / forceConstant;
if (Double.isNaN(force)) {
System.err.println("Mathematical error...");
}
double xDisp = (xDelta/deltaLength) * force;
double yDisp = (yDelta/deltaLength) * force;
n1p.disp[0] -= xDisp; n1p.disp[1] -= yDisp;
n2p.disp[0] += xDisp; n2p.disp[1] += yDisp;
}
示例2: initSimulator
import prefuse.visual.EdgeItem; //导入方法依赖的package包/类
/**
* Loads the simulator with all relevant force items and springs.
* @param fsim the force simulator driving this layout
*/
protected void initSimulator(ForceSimulator fsim) {
// make sure we have force items to work with
TupleSet ts = m_vis.getGroup(m_nodeGroup);
if ( ts == null ) return;
try {
ts.addColumns(FORCEITEM_SCHEMA);
} catch ( IllegalArgumentException iae ) { /* ignored */ }
float startX = (referrer == null ? 0f : (float)referrer.getX());
float startY = (referrer == null ? 0f : (float)referrer.getY());
startX = Float.isNaN(startX) ? 0f : startX;
startY = Float.isNaN(startY) ? 0f : startY;
Iterator iter = m_vis.visibleItems(m_nodeGroup);
while ( iter.hasNext() ) {
VisualItem item = (VisualItem)iter.next();
ForceItem fitem = (ForceItem)item.get(FORCEITEM);
fitem.mass = getMassValue(item);
double x = item.getEndX();
double y = item.getEndY();
fitem.location[0] = (Double.isNaN(x) ? startX : (float)x);
fitem.location[1] = (Double.isNaN(y) ? startY : (float)y);
fsim.addItem(fitem);
}
if ( m_edgeGroup != null ) {
iter = m_vis.visibleItems(m_edgeGroup);
while ( iter.hasNext() ) {
EdgeItem e = (EdgeItem)iter.next();
NodeItem n1 = e.getSourceItem();
ForceItem f1 = (ForceItem)n1.get(FORCEITEM);
NodeItem n2 = e.getTargetItem();
ForceItem f2 = (ForceItem)n2.get(FORCEITEM);
float coeff = getSpringCoefficient(e);
float slen = getSpringLength(e);
fsim.addSpring(f1, f2, (coeff>=0?coeff:-1.f), (slen>=0?slen:-1.f));
}
}
}
示例3: collapseAggregate
import prefuse.visual.EdgeItem; //导入方法依赖的package包/类
public static void collapseAggregate(Visualization vis, String nodeType, boolean enable) {
Iterator iter = vis.items(new FieldMatchGroupPredicate("aggregates", "type", nodeType));
while(iter.hasNext()) {
AggregateItem aitem = (AggregateItem)iter.next();
double x = aitem.getBounds().getCenterX();
double y = aitem.getBounds().getCenterY();
// Make all items invisable...
Iterator aiter = aitem.items();
while(aiter.hasNext()) {
NodeItem item = (NodeItem)aiter.next();
item.setVisible(enable);
if (!enable) {
item.setFixed(true);
PrefuseLib.setX(item, null, x);
PrefuseLib.setY(item, null, y);
}
Iterator edges = item.edges();
while(edges.hasNext()) {
EdgeItem e = (EdgeItem)edges.next();
VisualItem target = e.getTargetItem();
VisualItem source = e.getSourceItem();
if (aitem.containsItem(target) && aitem.containsItem(source)) {
e.setVisible(enable);
}
}
}
}
}
示例4: addAggregate
import prefuse.visual.EdgeItem; //导入方法依赖的package包/类
private static void addAggregate(int id, NodeItem node, AggregateItem aitem, boolean enable) {
System.out.println("\t" + node.toString());
aitem.set("id", id);
aitem.set("type", node.getString("type"));
Iterator edges = node.edges();
if (enable) {
aitem.addItem(node);
} else {
aitem.removeItem(node);
}
while(edges.hasNext()) {
EdgeItem e = (EdgeItem)edges.next();
VisualItem target = e.getTargetItem();
VisualItem source = e.getSourceItem();
System.out.println("\t\t-->" + target.toString());
System.out.println("\t\t-->" + source.toString());
aitem.setInt("id", 1);
if (!target.equals(node)) {
if (enable) {
aitem.addItem(target);
} else {
aitem.removeItem(target);
}
}
if (!source.equals(node)) {
if (enable) {
aitem.addItem(source);
} else {
aitem.removeItem(source);
}
}
}
}
示例5: setEdgeHighlight
import prefuse.visual.EdgeItem; //导入方法依赖的package包/类
protected void setEdgeHighlight(EdgeItem e, boolean state) {
NodeItem sourceItem = e.getSourceItem();
NodeItem targetItem = e.getTargetItem();
if (e.isVisible()) {
e.setHighlighted(state);
}
if (sourceItem.isVisible()) {
sourceItem.setHighlighted(state);
}
if (targetItem.isVisible()) {
targetItem.setHighlighted(state);
}
}
示例6: getRawShape
import prefuse.visual.EdgeItem; //导入方法依赖的package包/类
@Override
protected Shape getRawShape(VisualItem item) {
EdgeItem edge = (EdgeItem)item;
VisualItem item1 = edge.getSourceItem();
VisualItem item2 = edge.getTargetItem();
int type = m_edgeType;
getAlignedPoint(m_tmpPoints[0], item1.getBounds(),
m_xAlign1, m_yAlign1);
getAlignedPoint(m_tmpPoints[1], item2.getBounds(),
m_xAlign2, m_yAlign2);
m_curWidth = (float)(m_width * getLineWidth(item));
// create the arrow head, if needed
EdgeItem e = (EdgeItem)item;
if ( e.isDirected() && m_edgeArrow != Constants.EDGE_ARROW_NONE ) {
// get starting and ending edge endpoints
boolean forward = (m_edgeArrow == Constants.EDGE_ARROW_FORWARD);
Point2D start = null, end = null;
start = m_tmpPoints[forward?0:1];
end = m_tmpPoints[forward?1:0];
// compute the intersection with the target bounding box
VisualItem dest = forward ? e.getTargetItem() : e.getSourceItem();
int i = GraphicsLib.intersectLineRectangle(start, end,
dest.getBounds(), m_isctPoints);
if ( i > 0 ) end = m_isctPoints[0];
// create the arrow head shape
AffineTransform at = getArrowTrans(start, end, m_curWidth);
m_curArrow = at.createTransformedShape(m_arrowHead);
// update the endpoints for the edge shape
// need to bias this by arrow head size
Point2D lineEnd = m_tmpPoints[forward?1:0];
lineEnd.setLocation(0, -m_arrowHeight);
at.transform(lineEnd, lineEnd);
} else {
m_curArrow = null;
}
// create the edge shape
Shape shape = null;
double n1x = m_tmpPoints[0].getX();
double n1y = m_tmpPoints[0].getY();
double n2x = m_tmpPoints[1].getX();
double n2y = m_tmpPoints[1].getY();
switch ( type ) {
case Constants.EDGE_TYPE_LINE:
m_line.setLine(n1x, n1y, n2x, n2y);
shape = m_line;
break;
case Constants.EDGE_TYPE_CURVE:
getCurveControlPoints(edge, m_ctrlPoints,n1x,n1y,n2x,n2y);
m_cubic.setCurve(n1x, n1y,
m_ctrlPoints[0].getX(), m_ctrlPoints[0].getY(),
m_ctrlPoints[1].getX(), m_ctrlPoints[1].getY(),
n2x, n2y);
shape = m_cubic;
break;
default:
throw new IllegalStateException("Unknown edge type");
}
// return the edge shape
return shape;
}
示例7: initSimulator
import prefuse.visual.EdgeItem; //导入方法依赖的package包/类
protected void initSimulator(ForceSimulator fsim) {
// make sure we have force items to work with
TupleSet ts = m_vis.getGroup(m_nodeGroup);
if ( ts == null ) return;
try {
ts.addColumns(FORCEITEM_SCHEMA);
} catch ( IllegalArgumentException iae ) { /* ignored */ }
float startX = (referrer == null ? 0f : (float)referrer.getX());
float startY = (referrer == null ? 0f : (float)referrer.getY());
startX = Float.isNaN(startX) ? 0f : startX;
startY = Float.isNaN(startY) ? 0f : startY;
ArrayList<EdgeItem> edges = new ArrayList<EdgeItem>();
Iterator<?> iter = m_vis.items(m_nodeGroup, m_filter);
while ( iter.hasNext() ) {
NodeItem item = (NodeItem)iter.next();
ForceItem fitem = (ForceItem)item.get(FORCEITEM);
fitem.mass = getMassValue(item);
double x = item.getEndX();
double y = item.getEndY();
fitem.location[0] = (Double.isNaN(x) ? startX : (float)x);
fitem.location[1] = (Double.isNaN(y) ? startY : (float)y);
fsim.addItem(fitem);
for (Iterator<?> it=item.outEdges(); it.hasNext();) {
EdgeItem edge = (EdgeItem) it.next();
NodeItem adjacent = edge.getAdjacentItem(item);
if (adjacent.getBoolean("is_local"))
edges.add(edge);
}
}
iter = edges.iterator();
while ( iter.hasNext() ) {
EdgeItem e = (EdgeItem)iter.next();
NodeItem n1 = e.getSourceItem();
ForceItem f1 = (ForceItem)n1.get(FORCEITEM);
NodeItem n2 = e.getTargetItem();
ForceItem f2 = (ForceItem)n2.get(FORCEITEM);
float coeff = getSpringCoefficient(e);
float slen = getSpringLength(e);
fsim.addSpring(f1, f2, (coeff>=0?coeff:-1.f), (slen>=0?slen:-1.f));
}
}
示例8: getRawShape
import prefuse.visual.EdgeItem; //导入方法依赖的package包/类
/**
* @see prefuse.render.AbstractShapeRenderer#getRawShape(prefuse.visual.VisualItem)
*/
protected Shape getRawShape(VisualItem item) {
EdgeItem edge = (EdgeItem)item;
VisualItem item1 = edge.getSourceItem();
VisualItem item2 = edge.getTargetItem();
int type = m_edgeType;
getAlignedPoint(m_tmpPoints[0], item1.getBounds(),
m_xAlign1, m_yAlign1);
getAlignedPoint(m_tmpPoints[1], item2.getBounds(),
m_xAlign2, m_yAlign2);
m_curWidth = (float)(m_width * getLineWidth(item));
// create the arrow head, if needed
EdgeItem e = (EdgeItem)item;
if ( e.isDirected() && m_edgeArrow != Constants.EDGE_ARROW_NONE ) {
// get starting and ending edge endpoints
boolean forward = (m_edgeArrow == Constants.EDGE_ARROW_FORWARD);
Point2D start = null, end = null;
start = m_tmpPoints[forward?0:1];
end = m_tmpPoints[forward?1:0];
// compute the intersection with the target bounding box
VisualItem dest = forward ? e.getTargetItem() : e.getSourceItem();
int i = GraphicsLib.intersectLineRectangle(start, end,
dest.getBounds(), m_isctPoints);
if ( i > 0 ) end = m_isctPoints[0];
// create the arrow head shape
AffineTransform at = getArrowTrans(start, end, m_curWidth);
m_curArrow = at.createTransformedShape(m_arrowHead);
// update the endpoints for the edge shape
// need to bias this by arrow head size
Point2D lineEnd = m_tmpPoints[forward?1:0];
lineEnd.setLocation(0, -m_arrowHeight);
at.transform(lineEnd, lineEnd);
} else {
m_curArrow = null;
}
// create the edge shape
Shape shape = null;
double n1x = m_tmpPoints[0].getX();
double n1y = m_tmpPoints[0].getY();
double n2x = m_tmpPoints[1].getX();
double n2y = m_tmpPoints[1].getY();
switch ( type ) {
case Constants.EDGE_TYPE_LINE:
m_line.setLine(n1x, n1y, n2x, n2y);
shape = m_line;
break;
case Constants.EDGE_TYPE_CURVE:
getCurveControlPoints(edge, m_ctrlPoints,n1x,n1y,n2x,n2y);
m_cubic.setCurve(n1x, n1y,
m_ctrlPoints[0].getX(), m_ctrlPoints[0].getY(),
m_ctrlPoints[1].getX(), m_ctrlPoints[1].getY(),
n2x, n2y);
shape = m_cubic;
break;
default:
throw new IllegalStateException("Unknown edge type");
}
// return the edge shape
return shape;
}