本文整理汇总了Java中prefuse.visual.EdgeItem类的典型用法代码示例。如果您正苦于以下问题:Java EdgeItem类的具体用法?Java EdgeItem怎么用?Java EdgeItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdgeItem类属于prefuse.visual包,在下文中一共展示了EdgeItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurveControlPoints
import prefuse.visual.EdgeItem; //导入依赖的package包/类
@Override
protected void getCurveControlPoints(EdgeItem eitem, Point2D[] cp,
double x1, double y1, double x2, double y2) {
// check if the same object...
if (eitem.getSourceItem().equals(eitem.getTargetItem())) {
cp[0].setLocation(x1-80, y1+80);
cp[1].setLocation(x1+80, y1+80);
/*
cp[0].setLocation(x1+2*dx/3,y1);
cp[1].setLocation(x2-dx/8,y2-dy/8);
*/
return;
}
// TODO Auto-generated method stub
super.getCurveControlPoints(eitem, cp, x1, y1, x2, y2);
}
示例2: 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;
}
示例3: score
import prefuse.visual.EdgeItem; //导入依赖的package包/类
public int score(VisualItem item) {
int result = super.score(item);
double x = 0;
double x2 = 0;
if(item instanceof NodeItem) {
x = item.getX();
x2 = item.getDouble(VisualItem.X2);
} else if (item instanceof EdgeItem) {
EdgeItem edge = ((EdgeItem)item);
x = edge.getTargetItem().getX();
x2 = edge.getSourceItem().getDouble(VisualItem.X2);
}
result += 4096-(int)Math.round(Math.abs(x2-x));
return result;
}
示例4: setBounds
import prefuse.visual.EdgeItem; //导入依赖的package包/类
/**
* Sets the bounds of the item to the bounds of the rectangle.
* @see prefuse.render.Renderer#setBounds(prefuse.visual.VisualItem)
*/
public void setBounds(VisualItem item) {
if(item instanceof EdgeItem) {
NodeItem childNode = ((EdgeItem)item).getSourceItem();
NodeItem parentNode = ((EdgeItem)item).getTargetItem();
if (childNode instanceof VisualItem && parentNode instanceof VisualItem) {
VisualItem child = (VisualItem)childNode;
VisualItem parent = (VisualItem)parentNode;
double outerRadius = (child.getDouble(VisualItem.X2)-parent.getX())/2.0;
int ydirect = parent.getInt(ParentChildNode.DEPTH) % 2 == 1 ? 0 : 1;
item.setBounds(parent.getX(),parent.getY()-ydirect*outerRadius,outerRadius*2,outerRadius);
}
}
}
示例5: itemEntered
import prefuse.visual.EdgeItem; //导入依赖的package包/类
/**
* mouse-over event on a visual item (node item or edge item)
*/
@Override
public void itemEntered(VisualItem item, MouseEvent e) {
// if ctrl is pressed, user zooms -> ignore itemEntered
if (e.getModifiers() == InputEvent.CTRL_MASK) {
ctrlZoom(e);
return;
}
// only mark items as highlighted if the layout process is active
RunLayoutControl rlc = new RunLayoutControl(viewManagerID);
if (rlc.isLayouting()) {
if (item instanceof NodeItem) {
/* set highlight attribute to true, NodeRenderer will change the color */
item.set(ColumnNames.IS_HIGHLIGHTED, true);
}
if (item instanceof EdgeItem) {
/* set highlight attribute to true, EdgeRenderer will change the color */
item.set(ColumnNames.IS_HIGHLIGHTED, true);
}
if (item instanceof TableDecoratorItem) {
/* set highlight attribute to true, EdgeRenderer will change the color */
item.set(ColumnNames.IS_HIGHLIGHTED, true);
}
}
}
示例6: itemExited
import prefuse.visual.EdgeItem; //导入依赖的package包/类
/**
* mouse moves away from a visual item (node item or edge item)
*/
@Override
public void itemExited(VisualItem item, java.awt.event.MouseEvent e) {
// if ctrl is pressed, user zooms -> ignore itemExited
// disable highlight possible but it should be same as zoom by mouse wheel or zoom by prefuse's right click zoom
if (e.getModifiers() == InputEvent.CTRL_MASK) {
ctrlZoom(e);
return;
}
if (item instanceof NodeItem) {
/* set highlight attribute to false, NodeRenderer will change the color */
item.set(ColumnNames.IS_HIGHLIGHTED, false);
}
if (item instanceof EdgeItem) {
/* set highlight attribute to false, EdgeRenderer will change the color */
item.set(ColumnNames.IS_HIGHLIGHTED, false);
}
if (item instanceof TableDecoratorItem) {
/* set highlight attribute to false, EdgeRenderer will change the color */
item.set(ColumnNames.IS_HIGHLIGHTED, false);
}
}
示例7: getSpringLength
import prefuse.visual.EdgeItem; //导入依赖的package包/类
/**
* returns the length of an edge
* 'overrides' the prefuse way of calculating the force abstraction layout length
*
* @param e - EdgeItem
*/
@Override
protected float getSpringLength(EdgeItem e) {
int edgeLengthColumn = e.getColumnIndex(ColumnNames.EDGE_LENGTH);
try {
int edgeLength = (Integer) e.get(edgeLengthColumn);
return edgeLength;
} catch (NullPointerException npe) {
return -1.f;
}
}
示例8: 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));
}
}
}
示例9: getSpringCoefficient
import prefuse.visual.EdgeItem; //导入依赖的package包/类
@Override
protected float getSpringCoefficient(EdgeItem e) {
if (e.canGetFloat("springCoefficient")) {
float f = e.getFloat("springCoefficient");
if (f > 0) {
return(f);
}
}
return super.getSpringCoefficient(e);
}
示例10: getSpringLength
import prefuse.visual.EdgeItem; //导入依赖的package包/类
@Override
protected float getSpringLength(EdgeItem e) {
if (e.canGetFloat("springLength")) {
float f = e.getFloat("springLength");
if (f > 0) {
return(f);
}
}
return super.getSpringLength(e);
}
示例11: 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);
}
}
}
}
}
示例12: 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);
}
}
}
}
示例13: getRenderer
import prefuse.visual.EdgeItem; //导入依赖的package包/类
/**
* Return a Renderer instance for the input VisualItem. The VisualItem
* is matched against the registered Predicates, and if a match is found
* the corresponding Renderer is returned. Predicate matches are evaluated
* in the order in which Predicate/Renderer mappings were added to this
* RendererFactory. If no matches are found, either the default renderer
* (for all VisualItems except EdgeItems) or the default edge renderer (for
* EdgeItems) is returned.
*/
public Renderer getRenderer(VisualItem item) {
Renderer r = (Renderer)m_chain.get(item);
if ( r != null )
return r;
else if ( item instanceof EdgeItem )
return m_edgeRenderer;
else
return m_itemRenderer;
}
示例14: setNeighborHighlight
import prefuse.visual.EdgeItem; //导入依赖的package包/类
/**
* Set the highlighted state of the neighbors of a node.
* @param n the node under consideration
* @param state the highlighting state to apply to neighbors
*/
protected void setNeighborHighlight(NodeItem n, boolean state) {
Iterator iter = n.edges();
while ( iter.hasNext() ) {
EdgeItem eitem = (EdgeItem)iter.next();
NodeItem nitem = eitem.getAdjacentItem(n);
if (eitem.isVisible() || highlightWithInvisibleEdge) {
eitem.setHighlighted(state);
nitem.setHighlighted(state);
}
}
if ( activity != null )
n.getVisualization().run(activity);
}
示例15: visit
import prefuse.visual.EdgeItem; //导入依赖的package包/类
/**
* Visit a specific node and update its degree-of-interest.
*/
private void visit(NodeItem n, NodeItem c, int doi, int ldist) {
PrefuseLib.updateVisible(n, true);
double localDOI = -ldist / Math.min(1000.0, m_divisor);
n.setDOI(doi+localDOI);
if ( c != null ) {
EdgeItem e = (EdgeItem)c.getParentEdge();
e.setDOI(c.getDOI());
PrefuseLib.updateVisible(e, true);
}
}