GraphmlFactory factory = GraphmlFactory.getInstance(); GraphmlDiagram diagram = factory.newDiagram(); GraphMLNode node1 = diagram.addNode(); node1.setX(10); node1.setY(10); GraphMLNode node2 = diagram.addNode(); node2.setX(100); node2.setY(100); GraphMLEdge edge = diagram.addEdge(node1, node2);
GraphmlFactory factory = GraphmlFactory.getInstance(); GraphmlDiagram diagram = factory.newDiagram(); GraphMLNode node1 = diagram.addNode(); node1.setX(10); node1.setY(10); GraphMLNode node2 = diagram.addNode(); node2.setX(100); node2.setY(100); GraphMLEdge edge = node1.addEdgeTo(node2);
edge.getLineStyle().setColor("red");To set the line style of an edge:
edge.getLineStyle().setLineStyle(LineStyle.DASHED);
arrowSource
and arrowTarget
properties of the diagram defaults.Arrows arrows = edge.getArrows(); arrows.setTarget(ArrowType.STANDARD);
edge.setLabel("The Label");By default the text color is black, and the label has no background and no border. However it is possible to set the text color, the background color, the border color and the insets of the label. For example:
EdgeLabel label = edge.setLabel("The Label"); label.setTextColor(Color.RED); label.setBackgroundColor(Color.YELLOW); label.setBorderColor(Color.BACK); label.setInsets(new Insets(1, 1, 1, 1));
EdgeLabel label = edge.getLabel(); EdgeLabel.ParamModel model = label.getParameterModel(); model.setAutoFlip(true); model.setAutoRotate(true);If you don't want to do it for all edges, you can access the default values of these parameters through the DiagramDefaults.
Path path = edge.getPath(); path.setSource(10, 10); path.setTarget(100, 100);It is also possible to set a complex path by adding points:
Path path = edge.getPath(); path.setSource(10, 10); path.setTarget(100, 100); path.addPoint(50, 50);
node1
to node2
specifying that the side of the port on the source node is South and the side of the port on the target port is North:Copyright 2021 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence