public static Element createPath(final Document document, final String fill, final double strokeWidth, final String stroke, final String path, final String... attributes) { checkPositiveValues("strokeWidth", strokeWidth); final Element el = createElement(document, "path", prepend(attributes, "fill", fill, "stroke-width", strokeWidth, "stroke", stroke, "d", path)); return el; }
public static Element createLine(final Document document, final double x1, final double y1, final double x2, final double y2, final SVGColor strokeColor, final String... attributes) { return createLine(document, x1, y1, x2, y2, prepend(attributes, "stroke", strokeColor.getName())); }
public static Element createElement(final Document document, final String tag, final SVGColor fillColor, final String... attributes) { return createElement(document, tag, prepend(attributes, "fill", fillColor.getName())); }
public static Element createText(final Document document, final double x, final double y, final String text, final String... attributes) { if (text == null) { throw new IllegalArgumentException("text shouldn't be null."); } checkNonNegativeValues("x, y", x, y); if (log.isDebugEnabled() == true) { log.debug("createText: x=" + x + ", y=" + y + ", text=" + text); } final Element el = createElement(document, "text", prepend(attributes, "x", round(x), "y", round(y))); el.appendChild(document.createTextNode(text)); return el; }
public static Element createRect(final Document document, final double x, final double y, final double width, final double height, final SVGColor fillColor, final SVGColor strokeColor, final String... attributes) { return createRect(document, x, y, width, height, fillColor.getName(), prepend(attributes, "stroke", strokeColor.getName())); }
@Test public void prepend() { assertArrayEquals(new String[] {}, SVGHelper.prepend(new String[] {}, (Object[]) null)); assertArrayEquals(new String[] { "1" }, SVGHelper.prepend(new String[] {}, new Object[] { 1 })); assertArrayEquals(new String[] { "1", "zwei" }, SVGHelper.prepend(new String[] {}, new Object[] { 1, "zwei" })); assertArrayEquals(new String[] { "3" }, SVGHelper.prepend(new String[] { "3" }, new Object[] {})); assertArrayEquals(new String[] { "1", "3" }, SVGHelper.prepend(new String[] { "3" }, new Object[] { 1 })); assertArrayEquals(new String[] { "1", "zwei", "3" }, SVGHelper.prepend(new String[] { "3" }, new Object[] { 1, "zwei" })); assertArrayEquals(new String[] { "1", "zwei", "3", "vier" }, SVGHelper.prepend(new String[] { "3", "vier" }, new Object[] { 1, "zwei" })); }
public static Element createUse(final Document document, final String id, final double x, final double y, final String... attributes) { checkNonNegativeValues("x, y", x, y); final Element el = createElement(document, "use", prepend(attributes, "xlink:href", id, "x", round(x), "y", round(y))); return el; }
public static Element createLine(final Document document, final double x1, final double y1, final double x2, final double y2, final String... attributes) { checkNonNegativeValues("x1, y1, x2, y2", x1, y1, x2, y2); if (log.isDebugEnabled() == true) { log.debug("createLine: x1=" + x1 + ", y1=" + y1 + ", x2=" + x2 + ", y2=" + y2 + ", attributes=" + StringHelper.listToString(",", attributes)); } final Element el = createElement(document, "line", prepend(attributes, "x1", round(x1), "y1", round(y1), "x2", round(x2), "y2", round(y2))); return el; }
public static Element createRect(final Document document, final double x, final double y, final double width, final double height, final String fill, final String... attributes) { checkPositiveValues("width, height", width, height); checkNonNegativeValues("x, y", x, y); if (log.isDebugEnabled() == true) { log.debug("createRect: x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + ", fill=" + fill + ", attributes=" + StringHelper.listToString(",", StringHelper.listToString(",", attributes))); } final Element el = createElement(document, "rect", prepend(attributes, "x", round(x), "y", round(y), "width", round(width), "height", round(height), "fill", fill)); return el; }