本文整理汇总了Java中org.jgraph.graph.DefaultEdge.setSource方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultEdge.setSource方法的具体用法?Java DefaultEdge.setSource怎么用?Java DefaultEdge.setSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jgraph.graph.DefaultEdge
的用法示例。
在下文中一共展示了DefaultEdge.setSource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testJGraph
import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
@Test
public void testJGraph() throws Exception {
GraphModel model = new DefaultGraphModel();
GraphLayoutCache view = new GraphLayoutCache(model, new DefaultCellViewFactory());
JGraph graph = new JGraph(model, view);
DefaultGraphCell[] cells = new DefaultGraphCell[3];
cells[0] = createCell("hello", true);
cells[1] = createCell("world", false);
DefaultEdge edge = new DefaultEdge();
GraphConstants.setLineStyle(edge.getAttributes(), GraphConstants.ARROW_LINE);
edge.setSource(cells[0].getChildAt(0));
edge.setTarget(cells[1].getChildAt(0));
cells[2] = edge;
graph.getGraphLayoutCache().insert(cells);
JOptionPane.showMessageDialog(null, new JScrollPane(graph));
}
示例2: addEdge
import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
public void addEdge( int source, int target){
//System.out.println("adding edge: "+source+"->"+ target+ "to cell "+cellCount);
DefaultEdge edge = new DefaultEdge();
edge.setSource(cells[source].getChildAt(0));
edge.setTarget(cells[target].getChildAt(0));
int arrow = GraphConstants.ARROW_CLASSIC;
GraphConstants.setLineEnd(edge.getAttributes(), arrow);
GraphConstants.setEndFill(edge.getAttributes(), true);
// Node s = (Node)cells[source].getUserObject();
// Node t = (Node)cells[target].getUserObject();
/* _edge.arrow_x=(int)(s.x+t.x)/2;
_edge.arrow_y=(int)(s.y+t.y)/2;*/
cells[cellCount] = edge;
edgeCount++;
cellCount++;
}
示例3: createEdge
import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
/**
* Creates a new edge in JGraph.
*
* @param source DefaultGraphCell that is the source for the edge.
* @param target DefaultGraphCell that is the target for the edge.
* @return DefaultGraphCell that was generated to connect the source with
* the target.
* @throws Exception
*/
public static DefaultGraphCell createEdge(DefaultGraphCell source,
DefaultGraphCell target) throws Exception {
DefaultEdge edge = new DefaultEdge();
source.addPort();
edge.setSource(source.getChildAt(source.getChildCount() - 1));
target.addPort();
edge.setTarget(target.getChildAt(target.getChildCount() - 1));
return edge;
}
示例4: createConnection
import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
private DefaultEdge createConnection(DefaultGraphCell cell) {
DefaultEdge edge = new DefaultEdge();
edge.setSource(stack.peek().getChildAt(0));
edge.setTarget(cell);
// Set Arrow Style for edge
int arrow = GraphConstants.ARROW_TECHNICAL;
GraphConstants.setLineEnd(edge.getAttributes(), arrow);
GraphConstants.setEndFill(edge.getAttributes(), true);
return edge;
}
示例5: insertLink
import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
private void insertLink(GraphVertex sourceVertex, GraphVertex targetVertex, Link type, DataBean sourceDataBean) {
if (type.equals(DataBean.Link.GROUPING)) {
if (sourceVertex.getGroup() != null && targetVertex.getGroup() != null) {
// both are grouped
if (sourceVertex.getGroup() == targetVertex.getGroup()) {
// already in the same group, ignore
return;
} else {
throw new IllegalArgumentException("beans already have different groups");
}
}
if (sourceVertex.getGroup() == null && targetVertex.getGroup() == null) {
createGroup(sourceVertex.getData()); // create group for the source and add target next
}
// other is grouped, other not => group the ungrouped one
if (sourceVertex.getGroup() != null) {
sourceVertex.getGroup().addChildVertex(targetVertex);
} else {
targetVertex.getGroup().addChildVertex(sourceVertex);
}
} else if (type.equals(DataBean.Link.ANNOTATION) || type.equals(DataBean.Link.DERIVATION) || type.equals(DataBean.Link.MODIFICATION)) {
DefaultEdge linkEdge = new NoLabelEdge(type);
linkEdge.setSource(sourceVertex.getChildAt(0));
linkEdge.setTarget(targetVertex.getChildAt(0));
switch (type) {
case ANNOTATION:
setAnnotationEdgeStyle(linkEdge);
break;
case DERIVATION:
setDerivationEdgeStyle(linkEdge);
break;
case MODIFICATION:
setModificationEdgeStyle(linkEdge);
break;
}
this.getGraphLayoutCache().insert(linkEdge);
if (type.equals(DataBean.Link.DERIVATION) || type.equals(DataBean.Link.MODIFICATION)) {
layoutManager.updateLayout(sourceVertex, sourceDataBean); // update position if this was made child of other bean
graphPanel.autoZoom();
scrollCellToVisibleAnimated(sourceVertex);
repaint();
} else if (type.equals(DataBean.Link.ANNOTATION)) {
moveCloseToAnnotated(sourceVertex.getData());
}
} else {
throw new IllegalArgumentException("unsupported link type: " + type);
}
}
示例6: createWeightedEdge
import org.jgraph.graph.DefaultEdge; //导入方法依赖的package包/类
/**
* Creates a new weighted edge in JGraph.
*
* @param source DefaultGraphCell that is the source for the edge.
* @param target DefaultGraphCell that is the target for the edge.
* @param weight Double that is the weight of the edge.
* @return DefaultGraphCell that was generated to connect the source with
* the target, with the specified weight.
* @throws Exception
*/
public static DefaultGraphCell createWeightedEdge(DefaultGraphCell source,
DefaultGraphCell target, double weight) throws Exception {
DefaultEdge edge = new DefaultEdge((new Double(weight)).toString());
source.addPort();
edge.setSource(source.getChildAt(source.getChildCount() - 1));
target.addPort();
edge.setTarget(target.getChildAt(target.getChildCount() - 1));
return edge;
}