outlineElem.setAttribute("stroke-opacity", String.valueOf(outlineColor.getAlpha() / 255f));
outlineElem.appendChild(labelTextOutline);
target.getTopElement(SVGTarget.TOP_NODE_LABELS_OUTLINE).appendChild(outlineElem);
//Trick to center text vertically on node:
SVGRect rect = ((SVGLocatable) outlineElem).getBBox();
outlineElem.setAttribute("y", String.valueOf(y + rect.getHeight() / 4f));
}
Element labelElem = target.createElement("text");
labelElem.setAttribute("class", node.getId().toString());
labelElem.setAttribute("x", String.valueOf(x));
labelElem.setAttribute("y", String.valueOf(y));
labelElem.setAttribute("style", "text-anchor: middle; dominant-baseline: central;");
labelElem.setAttribute("fill", target.toHexString(color));
labelElem.setAttribute("font-family", font.getFamily());
labelElem.setAttribute("font-size", String.valueOf(fontSize));
labelElem.appendChild(labelText);
target.getTopElement(SVGTarget.TOP_NODE_LABELS).appendChild(labelElem);
//Trick to center text vertically on node:
SVGRect rect = ((SVGLocatable) labelElem).getBBox();
labelElem.setAttribute("y", String.valueOf(y + rect.getHeight() / 4f));
//Box
if (showBox) {
rect = ((SVGLocatable) labelElem).getBBox();
Element boxElem = target.createElement("rect");
boxElem.setAttribute("x", Float.toString(rect.getX() - outlineSize / 2f));
boxElem.setAttribute("y", Float.toString(rect.getY() - outlineSize / 2f));
boxElem.setAttribute("width", Float.toString(rect.getWidth() + outlineSize));
boxElem.setAttribute("height", Float.toString(rect.getHeight() + outlineSize));
boxElem.setAttribute("fill", target.toHexString(boxColor));
boxElem.setAttribute("opacity", String.valueOf(boxColor.getAlpha() / 255f));
target.getTopElement(SVGTarget.TOP_NODE_LABELS).insertBefore(boxElem, labelElem);
}
}