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));
edge.createAdditionalLabel("The Label", 0.98f);
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.
GraphMLFactory factory = GraphMLFactory.getInstance(); GraphMLDiagram diagram = factory.newDiagram(); GraphMLNode node1 = diagram.addNode(); GraphMLNode node2 = diagram.addNode(); GraphMLEdge edge = node1.addEdgeTo(node2); Arrows arrows = edge.getArrows(); arrows.setTarget(ArrowType.STANDARD); EdgeLabel label1 = edge.createAdditionalLabel("Origin", 0.02f); EdgeLabel label2 = edge.createAdditionalLabel("Destination", 0.98f);Produce the following diagram:
Copyright 2021 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence