public void renderSVG(SVGTarget target, Edge edge, String label, float x, float y, Color color, float outlineSize, Color outlineColor) { Text labelText = target.createTextNode(label); Text labelTextOutline = target.createTextNode(label); Element outlineElem = target.createElement("text"); outlineElem.setAttribute("class", SVGUtils.idAsClassAttribute(edge.getId())); outlineElem.setAttribute("x", String.valueOf(x)); outlineElem.setAttribute("y", String.valueOf(y)); outlineElem.setAttribute("style", "text-anchor: middle; dominant-baseline: central;"); outlineElem.setAttribute("fill", target.toHexString(color)); outlineElem.setAttribute("font-family", font.getFamily()); outlineElem.setAttribute("font-size", font.getSize() + ""); outlineElem.setAttribute("stroke", target.toHexString(outlineColor)); outlineElem.setAttribute("stroke-width", (outlineSize * target.getScaleRatio()) + "px"); outlineElem.setAttribute("stroke-linecap", "round"); outlineElem.setAttribute("stroke-linejoin", "round"); outlineElem.setAttribute("stroke-opacity", String.valueOf(outlineColor.getAlpha() / 255f)); outlineElem.appendChild(labelTextOutline); target.getTopElement(SVGTarget.TOP_NODE_LABELS_OUTLINE).appendChild(outlineElem); Element labelElem = target.createElement("text"); labelElem.setAttribute("class", SVGUtils.idAsClassAttribute(edge.getId())); labelElem.setAttribute("x", x + ""); labelElem.setAttribute("y", 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", font.getSize() + ""); labelElem.appendChild(labelText); target.getTopElement(SVGTarget.TOP_EDGE_LABELS).appendChild(labelElem);
} else if (target instanceof SVGTarget) { final SVGTarget svgTarget = (SVGTarget) target; final Element arrowElem = svgTarget.createElement("polyline"); arrowElem.setAttribute("points", String.format( Locale.ENGLISH, SVGUtils.idAsClassAttribute(((Node) h.targetItem.getSource()).getId()) )); arrowElem.setAttribute("fill", svgTarget.toHexString(color)); arrowElem.setAttribute("fill-opacity", (color.getAlpha() / 255f) + ""); arrowElem.setAttribute("stroke", "none"); svgTarget.getTopElement(SVGTarget.TOP_ARROWS).appendChild(arrowElem); } else if (target instanceof PDFTarget) { final PDFTarget pdfTarget = (PDFTarget) target;
TranscoderInput input = new TranscoderInput(target.getDocument());
public void renderSVG(SVGTarget target, Node node, String label, float x, float y, int fontSize, Color color, float outlineSize, Color outlineColor, boolean showBox, Color boxColor) { Text labelText = target.createTextNode(label); Font font = fontCache.get(fontSize); Text labelTextOutline = target.createTextNode(label); Element outlineElem = target.createElement("text"); outlineElem.setAttribute("class", SVGUtils.idAsClassAttribute(node.getId())); outlineElem.setAttribute("x", String.valueOf(x)); outlineElem.setAttribute("y", String.valueOf(y)); outlineElem.setAttribute("style", "text-anchor: middle; dominant-baseline: central;"); outlineElem.setAttribute("fill", target.toHexString(color)); outlineElem.setAttribute("font-family", font.getFamily()); outlineElem.setAttribute("font-size", String.valueOf(fontSize)); outlineElem.setAttribute("stroke", target.toHexString(outlineColor)); outlineElem.setAttribute("stroke-width", (outlineSize * target.getScaleRatio()) + "px"); outlineElem.setAttribute("stroke-linecap", "round"); outlineElem.setAttribute("stroke-linejoin", "round"); outlineElem.setAttribute("stroke-opacity", String.valueOf(outlineColor.getAlpha() / 255f)); outlineElem.appendChild(labelTextOutline); target.getTopElement(SVGTarget.TOP_NODE_LABELS_OUTLINE).appendChild(outlineElem); Element labelElem = target.createElement("text"); labelElem.setAttribute("class", SVGUtils.idAsClassAttribute(node.getId())); 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);
Element nodeElem = target.createElement("circle"); nodeElem.setAttribute("class", SVGUtils.idAsClassAttribute(node.getId())); nodeElem.setAttribute("cx", x.toString()); nodeElem.setAttribute("cy", y.toString()); nodeElem.setAttribute("r", size.toString()); nodeElem.setAttribute("fill", target.toHexString(color)); nodeElem.setAttribute("fill-opacity", "" + alpha); if (borderSize > 0) { nodeElem.setAttribute("stroke", target.toHexString(borderColor)); nodeElem.setAttribute( "stroke-width", Float.toString(borderSize * target.getScaleRatio())); nodeElem.setAttribute("stroke-opacity", "" + alpha); target.getTopElement(SVGTarget.TOP_NODES).appendChild(nodeElem);
final SVGTarget svgTarget = (SVGTarget) target; final Element selfLoopElem = svgTarget.createElement("path"); selfLoopElem.setAttribute("d", String.format( Locale.ENGLISH, selfLoopElem.setAttribute( "stroke", svgTarget.toHexString(color)); selfLoopElem.setAttribute( "stroke-opacity", (color.getAlpha() / 255f) + ""); selfLoopElem.setAttribute("stroke-width", Float.toString( getThickness(item) * svgTarget.getScaleRatio())); selfLoopElem.setAttribute("fill", "none"); svgTarget.getTopElement(SVGTarget.TOP_EDGES) .appendChild(selfLoopElem); } else if (target instanceof PDFTarget) {
} else if (target instanceof SVGTarget) { final SVGTarget svgTarget = (SVGTarget) target; final Element edgeElem = svgTarget.createElement("path"); edgeElem.setAttribute("class", String.format( "%s %s", "M %f,%f L %f,%f", h.x1, h.y1, h.x2, h.y2)); edgeElem.setAttribute("stroke", svgTarget.toHexString(color)); edgeElem.setAttribute( "stroke-width", Float.toString(getThickness(item) * svgTarget.getScaleRatio())); edgeElem.setAttribute( "stroke-opacity", (color.getAlpha() / 255f) + ""); edgeElem.setAttribute("fill", "none"); svgTarget.getTopElement(SVGTarget.TOP_EDGES) .appendChild(edgeElem); } else if (target instanceof PDFTarget) {
} else if (target instanceof SVGTarget) { final SVGTarget svgTarget = (SVGTarget) target; final Element edgeElem = svgTarget.createElement("path"); edgeElem.setAttribute("class", String.format( "%s %s", h.x1, h.y1, h.v1.x, h.v1.y, h.v2.x, h.v2.y, h.x2, h.y2)); edgeElem.setAttribute("stroke", svgTarget.toHexString(color)); edgeElem.setAttribute( "stroke-width", Float.toString(getThickness(item) * svgTarget.getScaleRatio())); edgeElem.setAttribute( "stroke-opacity", (color.getAlpha() / 255f) + ""); edgeElem.setAttribute("fill", "none"); svgTarget.getTopElement(SVGTarget.TOP_EDGES) .appendChild(edgeElem); } else if (target instanceof PDFTarget) {