本文整理了Java中com.mxgraph.view.mxGraph.insertEdge()
方法的一些代码示例,展示了mxGraph.insertEdge()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。mxGraph.insertEdge()
方法的具体详情如下:
包路径:com.mxgraph.view.mxGraph
类名称:mxGraph
方法名:insertEdge
[英]Creates and adds a new edge with an empty style.
[中]创建并添加带有空样式的新边。
代码示例来源:origin: Activiti/Activiti
protected void handleAssociations() {
Hashtable<String, Object> edgeStyle = new Hashtable<String, Object>();
edgeStyle.put(mxConstants.STYLE_ORTHOGONAL, true);
edgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.ElbowConnector);
edgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.0);
edgeStyle.put(mxConstants.STYLE_ENTRY_Y, 0.5);
graph.getStylesheet().putCellStyle(STYLE_SEQUENCEFLOW, edgeStyle);
Hashtable<String, Object> boundaryEdgeStyle = new Hashtable<String, Object>();
boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_X, 0.5);
boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_Y, 1.0);
boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.5);
boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_Y, 1.0);
boundaryEdgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.OrthConnector);
graph.getStylesheet().putCellStyle(STYLE_BOUNDARY_SEQUENCEFLOW, boundaryEdgeStyle);
for (Association association : associations.values()) {
Object sourceVertex = generatedVertices.get(association.getSourceRef());
Object targetVertex = generatedVertices.get(association.getTargetRef());
String style = null;
if (handledFlowElements.get(association.getSourceRef()) instanceof BoundaryEvent) {
// Sequence flow out of boundary events are handled in a different way,
// to make them visually appealing for the eye of the dear end user.
style = STYLE_BOUNDARY_SEQUENCEFLOW;
} else {
style = STYLE_SEQUENCEFLOW;
}
Object associationEdge = graph.insertEdge(cellParent, association.getId(), "", sourceVertex, targetVertex, style);
generatedAssociationEdges.put(association.getId(), associationEdge);
}
}
代码示例来源:origin: Activiti/Activiti
Object sequenceFlowEdge = graph.insertEdge(cellParent, sequenceFlow.getId(), "", sourceVertex, targetVertex, style);
generatedSequenceFlowEdges.put(sequenceFlow.getId(), sequenceFlowEdge);
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
/**
* Creates and adds a new edge with an empty style.
*/
public Object insertEdge(Object parent, String id, Object value,
Object source, Object target)
{
return insertEdge(parent, id, value, source, target, null);
}
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
/**
* Creates and adds a new edge with an empty style.
*/
public Object insertEdge(Object parent, String id, Object value,
Object source, Object target)
{
return insertEdge(parent, id, value, source, target, null);
}
代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx
/**
* @param aGraph
* @param numVertices
* Returns a path graph
*/
public void getPathGraph(mxAnalysisGraph aGraph, int numVertices)
{
if (numVertices < 0)
{
throw new IllegalArgumentException();
}
mxGraph graph = aGraph.getGraph();
Object parent = graph.getDefaultParent();
Object[] vertices = new Object[numVertices];
for (int i = 0; i < numVertices; i++)
{
vertices[i] = graph.insertVertex(parent, null, new Integer(i).toString(), 0, 0, 25, 25);
}
for (int i = 0; i < numVertices - 1; i++)
{
graph.insertEdge(parent, null, getNewEdgeValue(aGraph), vertices[i], vertices[i + 1]);
}
};
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
/**
* @param aGraph
* @param numVertices
* Returns a path graph
*/
public void getPathGraph(mxAnalysisGraph aGraph, int numVertices)
{
if (numVertices < 0)
{
throw new IllegalArgumentException();
}
mxGraph graph = aGraph.getGraph();
Object parent = graph.getDefaultParent();
Object[] vertices = new Object[numVertices];
for (int i = 0; i < numVertices; i++)
{
vertices[i] = graph.insertVertex(parent, null, new Integer(i).toString(), 0, 0, 25, 25);
}
for (int i = 0; i < numVertices - 1; i++)
{
graph.insertEdge(parent, null, getNewEdgeValue(aGraph), vertices[i], vertices[i + 1]);
}
};
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
/**
* @param aGraph
* @param numVertices
* Returns a star graph
* Note that minimum vertex number is 4
*/
public void getStarGraph(mxAnalysisGraph aGraph, int numVertices)
{
if (numVertices < 4)
{
throw new IllegalArgumentException();
}
mxGraph graph = aGraph.getGraph();
Object parent = graph.getDefaultParent();
Object[] vertices = new Object[numVertices];
for (int i = 0; i < numVertices; i++)
{
vertices[i] = graph.insertVertex(parent, null, new Integer(i).toString(), 0, 0, 25, 25);
}
int numVertexesInPerimeter = numVertices - 1;
for (int i = 0; i < numVertexesInPerimeter; i++)
{
graph.insertEdge(parent, null, getNewEdgeValue(aGraph), vertices[numVertexesInPerimeter], vertices[i]);
}
};
代码示例来源:origin: org.opensingular/server-commons
private static void addStartTransition(mxGraph graph, MTask<?> taskInicial, Map<String, Object> mapaVertice) {
final Object v = graph.insertVertex(graph.getDefaultParent(), null, null, 20, 20, 20, 20);
setStyle(v, "START");
final Object destino = mapaVertice.get(taskInicial.getAbbreviation());
graph.insertEdge(graph.getDefaultParent(), null, null, v, destino);
}
代码示例来源:origin: org.opensingular/singular-server-commons
private static void addStartTransition(mxGraph graph, STask<?> taskInicial, Map<String, Object> mapaVertice) {
final Object v = graph.insertVertex(graph.getDefaultParent(), null, null, 20, 20, 20, 20);
setStyle(v, "START");
final Object destiny = mapaVertice.get(taskInicial.getAbbreviation());
graph.insertEdge(graph.getDefaultParent(), null, null, v, destiny);
}
代码示例来源:origin: org.opensingular/singular-requirement-commons
private static void addStartTransition(mxGraph graph, STask<?> taskInicial, Map<String, Object> mapaVertice) {
final Object v = graph.insertVertex(graph.getDefaultParent(), null, null, 20, 20, 20, 20);
setStyle(v, "START");
final Object destiny = mapaVertice.get(taskInicial.getAbbreviation());
graph.insertEdge(graph.getDefaultParent(), null, null, v, destiny);
}
代码示例来源:origin: org.opensingular/singular-requirement-module
private static void addStartTransition(mxGraph graph, STask<?> taskInicial, Map<String, Object> mapaVertice) {
final Object v = graph.insertVertex(graph.getDefaultParent(), null, null, 20, 20, 20, 20);
setStyle(v, "START");
final Object destiny = mapaVertice.get(taskInicial.getAbbreviation());
graph.insertEdge(graph.getDefaultParent(), null, null, v, destiny);
}
代码示例来源:origin: arquillian/arquillian-cube
private void createDirectLinks(mxGraph graph, Object parent, Map<String, Object> insertedVertex, CubeContainer cubeContainer, Object currentContainer) {
// create relation to all direct links
if (cubeContainer.getLinks() != null) {
for (Link link : cubeContainer.getLinks()) {
final String linkId = link.getName();
Object linkContainer = null;
if (insertedVertex.containsKey(linkId)) {
linkContainer = insertedVertex.get(linkId);
} else {
linkContainer = graph.insertVertex(parent, null, linkId, 0, 0, 80, 30);
}
graph.updateCellSize(currentContainer);
graph.insertEdge(parent, null, link.getAlias(), currentContainer, linkContainer);
insertedVertex.put(linkId, linkContainer);
}
}
}
代码示例来源:origin: org.opensingular/singular-requirement-module
private static void createTransition(mxGraph graph, STransition transition, String transitionName,
Map<String, Object> mapNodes) {
Object origin = mapNodes.get(transition.getOrigin().getAbbreviation());
Object destiny = mapNodes.get(transition.getDestination().getAbbreviation());
String name = transitionName;
if (transition.getDestination().getName().equals(transitionName)) {
name = null;
}
graph.insertEdge(graph.getDefaultParent(), null, formatName(name), origin, destiny);
}
代码示例来源:origin: org.opensingular/singular-server-commons
private static void createTransition(mxGraph graph, STransition transition, Map<String, Object> mapNodes) {
final Object origin = mapNodes.get(transition.getOrigin().getAbbreviation());
final Object destiny = mapNodes.get(transition.getDestination().getAbbreviation());
String name = transition.getName();
if (transition.getDestination().getName().equals(name)) {
name = null;
} else {
name = formatName(name);
}
graph.insertEdge(graph.getDefaultParent(), null, name, origin, destiny);
}
代码示例来源:origin: org.gdl-lang.gdl-tools/gdl-graph
@Override
public void insertGraphEdge(GraphEdge graphEdge) throws GraphRenderingException {
Object nodeA = getGraphNodeObjectMap().get(graphEdge.getGraphNodeA());
if (nodeA == null) {
throw new GraphRenderingException("First node from edge has not been inserted yet.");
}
Object nodeB = getGraphNodeObjectMap().get(graphEdge.getGraphNodeB());
if (nodeB == null) {
throw new GraphRenderingException("Second node from edge has not been inserted yet.");
}
StringBuilder styleSB = new StringBuilder();
if (graphEdge.getColor() != null) {
styleSB.append(mxConstants.STYLE_STROKECOLOR).append("=").append(graphEdge.getColor()).append(";");
}
if (GraphEdge.Style.DASHED.equals(graphEdge.getStyle())) {
styleSB.append(mxConstants.STYLE_DASHED).append("=true;");
}
styleSB.append(mxConstants.STYLE_ROUNDED).append("=true;");
styleSB.append(mxConstants.STYLE_EDGE).append("=").append(mxConstants.EDGESTYLE_ENTITY_RELATION);
String label = graphEdge.getLabel();
Object edge = getGraph().insertEdge(getGraph().getDefaultParent(), null, label, nodeA, nodeB);
getGraph().getModel().setStyle(edge, styleSB.toString());
}
代码示例来源:origin: org.opensingular/singular-requirement-commons
private static void createTransition(mxGraph graph, STransition transition, Map<String, Object> mapNodes) {
final Object origin = mapNodes.get(transition.getOrigin().getAbbreviation());
final Object destiny = mapNodes.get(transition.getDestination().getAbbreviation());
String name = transition.getName();
if (transition.getDestination().getName().equals(name)) {
name = null;
} else {
name = formatName(name);
}
graph.insertEdge(graph.getDefaultParent(), null, name, origin, destiny);
}
代码示例来源:origin: stackoverflow.com
public class TelaPrincipalController {
@FXML
private SwingNode swingComponentWrapper ;
public void initialize() {
SwingUtilities.invokeLater(this::createMxGraph);
}
private void createMxGraph() {
mxGraph grafo = new mxGraph();
Object parent = grafo.getDefaultParent();
Object v1 = grafo.insertVertex(parent, null, "Brazil", 100, 100, 50, 40);
Object v2 = grafo.insertVertex(parent, null, "Soccer", 240, 150, 50, 40);
Object a1 = grafo.insertEdge(parent, null, "loves", v1, v2);
mxGraphComponent graphComponent = new mxGraphComponent(grafo);
swingComponentWrapper.setContent(graphComponent);
}
@FXML
private void selecionarNo() {
// ...
}
// etc etc...
}
代码示例来源:origin: org.opensingular/server-commons
private static void createTransition(mxGraph graph, MTransition transicao, Map<String, Object> mapaVertice) {
final Object origem = mapaVertice.get(transicao.getOrigin().getAbbreviation());
final Object destino = mapaVertice.get(transicao.getDestination().getAbbreviation());
String nome = transicao.getName();
if (transicao.getDestination().getName().equals(nome)) {
nome = null;
} else {
nome = formatarNome(nome);
}
graph.insertEdge(graph.getDefaultParent(), null, nome, origem, destino);
}
代码示例来源:origin: stackoverflow.com
public static mxGraph makeHelloWorldGraph() {
mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try {
Object v1 = graph.insertVertex(parent, null, "", 20, 20, 80,
30,"opacity=0");
Object v2 = graph.insertVertex(parent, null, "World!", 240, 150,
80, 30);
graph.insertEdge(parent, null, "Edge", v1, v2);
} finally {
graph.getModel().endUpdate();
}
return graph;
}
代码示例来源:origin: stackoverflow.com
import javax.swing.JFrame;
import com.mxgraph.swing.mxGraphComponent;
import com.mxgraph.view.mxGraph;
public class GraphFrame extends JFrame {
public static void main(String[] args) {
mxGraph graph = new mxGraph();
Object parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try {
Object v1 = graph.insertVertex(parent, null, "Hello", 20, 20, 80,
30);
Object v2 = graph.insertVertex(parent, null, "World!", 240, 150,
80, 30);
graph.insertEdge(parent, null, "Edge", v1, v2);
} finally {
graph.getModel().endUpdate();
}
mxGraphComponent graphComponent = new mxGraphComponent(graph);
GraphFrame frame = new GraphFrame();
frame.add(graphComponent);
frame.pack();
frame.setVisible(true);
}
}
内容来源于网络,如有侵权,请联系作者删除!