com.mxgraph.view.mxGraph.insertEdge()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中com.mxgraph.view.mxGraph.insertEdge()方法的一些代码示例,展示了mxGraph.insertEdge()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。mxGraph.insertEdge()方法的具体详情如下:
包路径:com.mxgraph.view.mxGraph
类名称:mxGraph
方法名:insertEdge

mxGraph.insertEdge介绍

[英]Creates and adds a new edge with an empty style.
[中]创建并添加带有空样式的新边。

代码示例

代码示例来源:origin: Activiti/Activiti

  1. protected void handleAssociations() {
  2. Hashtable<String, Object> edgeStyle = new Hashtable<String, Object>();
  3. edgeStyle.put(mxConstants.STYLE_ORTHOGONAL, true);
  4. edgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.ElbowConnector);
  5. edgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.0);
  6. edgeStyle.put(mxConstants.STYLE_ENTRY_Y, 0.5);
  7. graph.getStylesheet().putCellStyle(STYLE_SEQUENCEFLOW, edgeStyle);
  8. Hashtable<String, Object> boundaryEdgeStyle = new Hashtable<String, Object>();
  9. boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_X, 0.5);
  10. boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_Y, 1.0);
  11. boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.5);
  12. boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_Y, 1.0);
  13. boundaryEdgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.OrthConnector);
  14. graph.getStylesheet().putCellStyle(STYLE_BOUNDARY_SEQUENCEFLOW, boundaryEdgeStyle);
  15. for (Association association : associations.values()) {
  16. Object sourceVertex = generatedVertices.get(association.getSourceRef());
  17. Object targetVertex = generatedVertices.get(association.getTargetRef());
  18. String style = null;
  19. if (handledFlowElements.get(association.getSourceRef()) instanceof BoundaryEvent) {
  20. // Sequence flow out of boundary events are handled in a different way,
  21. // to make them visually appealing for the eye of the dear end user.
  22. style = STYLE_BOUNDARY_SEQUENCEFLOW;
  23. } else {
  24. style = STYLE_SEQUENCEFLOW;
  25. }
  26. Object associationEdge = graph.insertEdge(cellParent, association.getId(), "", sourceVertex, targetVertex, style);
  27. generatedAssociationEdges.put(association.getId(), associationEdge);
  28. }
  29. }

代码示例来源:origin: Activiti/Activiti

  1. Object sequenceFlowEdge = graph.insertEdge(cellParent, sequenceFlow.getId(), "", sourceVertex, targetVertex, style);
  2. generatedSequenceFlowEdges.put(sequenceFlow.getId(), sequenceFlowEdge);

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. /**
  2. * Creates and adds a new edge with an empty style.
  3. */
  4. public Object insertEdge(Object parent, String id, Object value,
  5. Object source, Object target)
  6. {
  7. return insertEdge(parent, id, value, source, target, null);
  8. }

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. * Creates and adds a new edge with an empty style.
  3. */
  4. public Object insertEdge(Object parent, String id, Object value,
  5. Object source, Object target)
  6. {
  7. return insertEdge(parent, id, value, source, target, null);
  8. }

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

  1. /**
  2. * @param aGraph
  3. * @param numVertices
  4. * Returns a path graph
  5. */
  6. public void getPathGraph(mxAnalysisGraph aGraph, int numVertices)
  7. {
  8. if (numVertices < 0)
  9. {
  10. throw new IllegalArgumentException();
  11. }
  12. mxGraph graph = aGraph.getGraph();
  13. Object parent = graph.getDefaultParent();
  14. Object[] vertices = new Object[numVertices];
  15. for (int i = 0; i < numVertices; i++)
  16. {
  17. vertices[i] = graph.insertVertex(parent, null, new Integer(i).toString(), 0, 0, 25, 25);
  18. }
  19. for (int i = 0; i < numVertices - 1; i++)
  20. {
  21. graph.insertEdge(parent, null, getNewEdgeValue(aGraph), vertices[i], vertices[i + 1]);
  22. }
  23. };

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. * @param aGraph
  3. * @param numVertices
  4. * Returns a path graph
  5. */
  6. public void getPathGraph(mxAnalysisGraph aGraph, int numVertices)
  7. {
  8. if (numVertices < 0)
  9. {
  10. throw new IllegalArgumentException();
  11. }
  12. mxGraph graph = aGraph.getGraph();
  13. Object parent = graph.getDefaultParent();
  14. Object[] vertices = new Object[numVertices];
  15. for (int i = 0; i < numVertices; i++)
  16. {
  17. vertices[i] = graph.insertVertex(parent, null, new Integer(i).toString(), 0, 0, 25, 25);
  18. }
  19. for (int i = 0; i < numVertices - 1; i++)
  20. {
  21. graph.insertEdge(parent, null, getNewEdgeValue(aGraph), vertices[i], vertices[i + 1]);
  22. }
  23. };

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

  1. /**
  2. * @param aGraph
  3. * @param numVertices
  4. * Returns a star graph
  5. * Note that minimum vertex number is 4
  6. */
  7. public void getStarGraph(mxAnalysisGraph aGraph, int numVertices)
  8. {
  9. if (numVertices < 4)
  10. {
  11. throw new IllegalArgumentException();
  12. }
  13. mxGraph graph = aGraph.getGraph();
  14. Object parent = graph.getDefaultParent();
  15. Object[] vertices = new Object[numVertices];
  16. for (int i = 0; i < numVertices; i++)
  17. {
  18. vertices[i] = graph.insertVertex(parent, null, new Integer(i).toString(), 0, 0, 25, 25);
  19. }
  20. int numVertexesInPerimeter = numVertices - 1;
  21. for (int i = 0; i < numVertexesInPerimeter; i++)
  22. {
  23. graph.insertEdge(parent, null, getNewEdgeValue(aGraph), vertices[numVertexesInPerimeter], vertices[i]);
  24. }
  25. };

代码示例来源:origin: org.opensingular/server-commons

  1. private static void addStartTransition(mxGraph graph, MTask<?> taskInicial, Map<String, Object> mapaVertice) {
  2. final Object v = graph.insertVertex(graph.getDefaultParent(), null, null, 20, 20, 20, 20);
  3. setStyle(v, "START");
  4. final Object destino = mapaVertice.get(taskInicial.getAbbreviation());
  5. graph.insertEdge(graph.getDefaultParent(), null, null, v, destino);
  6. }

代码示例来源:origin: org.opensingular/singular-server-commons

  1. private static void addStartTransition(mxGraph graph, STask<?> taskInicial, Map<String, Object> mapaVertice) {
  2. final Object v = graph.insertVertex(graph.getDefaultParent(), null, null, 20, 20, 20, 20);
  3. setStyle(v, "START");
  4. final Object destiny = mapaVertice.get(taskInicial.getAbbreviation());
  5. graph.insertEdge(graph.getDefaultParent(), null, null, v, destiny);
  6. }

代码示例来源:origin: org.opensingular/singular-requirement-commons

  1. private static void addStartTransition(mxGraph graph, STask<?> taskInicial, Map<String, Object> mapaVertice) {
  2. final Object v = graph.insertVertex(graph.getDefaultParent(), null, null, 20, 20, 20, 20);
  3. setStyle(v, "START");
  4. final Object destiny = mapaVertice.get(taskInicial.getAbbreviation());
  5. graph.insertEdge(graph.getDefaultParent(), null, null, v, destiny);
  6. }

代码示例来源:origin: org.opensingular/singular-requirement-module

  1. private static void addStartTransition(mxGraph graph, STask<?> taskInicial, Map<String, Object> mapaVertice) {
  2. final Object v = graph.insertVertex(graph.getDefaultParent(), null, null, 20, 20, 20, 20);
  3. setStyle(v, "START");
  4. final Object destiny = mapaVertice.get(taskInicial.getAbbreviation());
  5. graph.insertEdge(graph.getDefaultParent(), null, null, v, destiny);
  6. }

代码示例来源:origin: arquillian/arquillian-cube

  1. private void createDirectLinks(mxGraph graph, Object parent, Map<String, Object> insertedVertex, CubeContainer cubeContainer, Object currentContainer) {
  2. // create relation to all direct links
  3. if (cubeContainer.getLinks() != null) {
  4. for (Link link : cubeContainer.getLinks()) {
  5. final String linkId = link.getName();
  6. Object linkContainer = null;
  7. if (insertedVertex.containsKey(linkId)) {
  8. linkContainer = insertedVertex.get(linkId);
  9. } else {
  10. linkContainer = graph.insertVertex(parent, null, linkId, 0, 0, 80, 30);
  11. }
  12. graph.updateCellSize(currentContainer);
  13. graph.insertEdge(parent, null, link.getAlias(), currentContainer, linkContainer);
  14. insertedVertex.put(linkId, linkContainer);
  15. }
  16. }
  17. }

代码示例来源:origin: org.opensingular/singular-requirement-module

  1. private static void createTransition(mxGraph graph, STransition transition, String transitionName,
  2. Map<String, Object> mapNodes) {
  3. Object origin = mapNodes.get(transition.getOrigin().getAbbreviation());
  4. Object destiny = mapNodes.get(transition.getDestination().getAbbreviation());
  5. String name = transitionName;
  6. if (transition.getDestination().getName().equals(transitionName)) {
  7. name = null;
  8. }
  9. graph.insertEdge(graph.getDefaultParent(), null, formatName(name), origin, destiny);
  10. }

代码示例来源:origin: org.opensingular/singular-server-commons

  1. private static void createTransition(mxGraph graph, STransition transition, Map<String, Object> mapNodes) {
  2. final Object origin = mapNodes.get(transition.getOrigin().getAbbreviation());
  3. final Object destiny = mapNodes.get(transition.getDestination().getAbbreviation());
  4. String name = transition.getName();
  5. if (transition.getDestination().getName().equals(name)) {
  6. name = null;
  7. } else {
  8. name = formatName(name);
  9. }
  10. graph.insertEdge(graph.getDefaultParent(), null, name, origin, destiny);
  11. }

代码示例来源:origin: org.gdl-lang.gdl-tools/gdl-graph

  1. @Override
  2. public void insertGraphEdge(GraphEdge graphEdge) throws GraphRenderingException {
  3. Object nodeA = getGraphNodeObjectMap().get(graphEdge.getGraphNodeA());
  4. if (nodeA == null) {
  5. throw new GraphRenderingException("First node from edge has not been inserted yet.");
  6. }
  7. Object nodeB = getGraphNodeObjectMap().get(graphEdge.getGraphNodeB());
  8. if (nodeB == null) {
  9. throw new GraphRenderingException("Second node from edge has not been inserted yet.");
  10. }
  11. StringBuilder styleSB = new StringBuilder();
  12. if (graphEdge.getColor() != null) {
  13. styleSB.append(mxConstants.STYLE_STROKECOLOR).append("=").append(graphEdge.getColor()).append(";");
  14. }
  15. if (GraphEdge.Style.DASHED.equals(graphEdge.getStyle())) {
  16. styleSB.append(mxConstants.STYLE_DASHED).append("=true;");
  17. }
  18. styleSB.append(mxConstants.STYLE_ROUNDED).append("=true;");
  19. styleSB.append(mxConstants.STYLE_EDGE).append("=").append(mxConstants.EDGESTYLE_ENTITY_RELATION);
  20. String label = graphEdge.getLabel();
  21. Object edge = getGraph().insertEdge(getGraph().getDefaultParent(), null, label, nodeA, nodeB);
  22. getGraph().getModel().setStyle(edge, styleSB.toString());
  23. }

代码示例来源:origin: org.opensingular/singular-requirement-commons

  1. private static void createTransition(mxGraph graph, STransition transition, Map<String, Object> mapNodes) {
  2. final Object origin = mapNodes.get(transition.getOrigin().getAbbreviation());
  3. final Object destiny = mapNodes.get(transition.getDestination().getAbbreviation());
  4. String name = transition.getName();
  5. if (transition.getDestination().getName().equals(name)) {
  6. name = null;
  7. } else {
  8. name = formatName(name);
  9. }
  10. graph.insertEdge(graph.getDefaultParent(), null, name, origin, destiny);
  11. }

代码示例来源:origin: stackoverflow.com

  1. public class TelaPrincipalController {
  2. @FXML
  3. private SwingNode swingComponentWrapper ;
  4. public void initialize() {
  5. SwingUtilities.invokeLater(this::createMxGraph);
  6. }
  7. private void createMxGraph() {
  8. mxGraph grafo = new mxGraph();
  9. Object parent = grafo.getDefaultParent();
  10. Object v1 = grafo.insertVertex(parent, null, "Brazil", 100, 100, 50, 40);
  11. Object v2 = grafo.insertVertex(parent, null, "Soccer", 240, 150, 50, 40);
  12. Object a1 = grafo.insertEdge(parent, null, "loves", v1, v2);
  13. mxGraphComponent graphComponent = new mxGraphComponent(grafo);
  14. swingComponentWrapper.setContent(graphComponent);
  15. }
  16. @FXML
  17. private void selecionarNo() {
  18. // ...
  19. }
  20. // etc etc...
  21. }

代码示例来源:origin: org.opensingular/server-commons

  1. private static void createTransition(mxGraph graph, MTransition transicao, Map<String, Object> mapaVertice) {
  2. final Object origem = mapaVertice.get(transicao.getOrigin().getAbbreviation());
  3. final Object destino = mapaVertice.get(transicao.getDestination().getAbbreviation());
  4. String nome = transicao.getName();
  5. if (transicao.getDestination().getName().equals(nome)) {
  6. nome = null;
  7. } else {
  8. nome = formatarNome(nome);
  9. }
  10. graph.insertEdge(graph.getDefaultParent(), null, nome, origem, destino);
  11. }

代码示例来源:origin: stackoverflow.com

  1. public static mxGraph makeHelloWorldGraph() {
  2. mxGraph graph = new mxGraph();
  3. Object parent = graph.getDefaultParent();
  4. graph.getModel().beginUpdate();
  5. try {
  6. Object v1 = graph.insertVertex(parent, null, "", 20, 20, 80,
  7. 30,"opacity=0");
  8. Object v2 = graph.insertVertex(parent, null, "World!", 240, 150,
  9. 80, 30);
  10. graph.insertEdge(parent, null, "Edge", v1, v2);
  11. } finally {
  12. graph.getModel().endUpdate();
  13. }
  14. return graph;
  15. }

代码示例来源:origin: stackoverflow.com

  1. import javax.swing.JFrame;
  2. import com.mxgraph.swing.mxGraphComponent;
  3. import com.mxgraph.view.mxGraph;
  4. public class GraphFrame extends JFrame {
  5. public static void main(String[] args) {
  6. mxGraph graph = new mxGraph();
  7. Object parent = graph.getDefaultParent();
  8. graph.getModel().beginUpdate();
  9. try {
  10. Object v1 = graph.insertVertex(parent, null, "Hello", 20, 20, 80,
  11. 30);
  12. Object v2 = graph.insertVertex(parent, null, "World!", 240, 150,
  13. 80, 30);
  14. graph.insertEdge(parent, null, "Edge", v1, v2);
  15. } finally {
  16. graph.getModel().endUpdate();
  17. }
  18. mxGraphComponent graphComponent = new mxGraphComponent(graph);
  19. GraphFrame frame = new GraphFrame();
  20. frame.add(graphComponent);
  21. frame.pack();
  22. frame.setVisible(true);
  23. }
  24. }

相关文章

mxGraph类方法