public static String drawArrow(final ArrowDirection direction, final double x, final double y, final double size) { checkNonNegativeValues("x, y", x, y); checkPositiveValues("size", size); final StringBuffer buf = new StringBuffer(); if (direction == ArrowDirection.LEFT) { buf.append("M ").append(round(x)).append(" ").append(round(y)); // (x, y) buf.append(" L ").append(round(x + size)).append(" ").append(round(y + size)); // (x + size, y + size) buf.append(" L ").append(round(x + size)).append(" ").append(round(y - size)); // (x + size, y - size) } else if (direction == ArrowDirection.RIGHT) { buf.append("M ").append(round(x)).append(" ").append(round(y)); // (x, y) buf.append(" L ").append(round(x - size)).append(" ").append(round(y - size)); // (x - size, y - size) buf.append(" L ").append(round(x - size)).append(" ").append(round(y + size)); // (x - size, y + size) } else { log.error("Unsupported arrow direction: " + direction); } buf.append(" z"); return buf.toString(); }
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; }
final double yHalf = (y2 - y1) / 2; final StringBuffer buf = new StringBuffer(); buf.append("M ").append(round(x1)).append(" ").append(round(y1)); // (x1, y1) if (type == GanttRelationType.FINISH_START || type == null) { if (xHalf > minXDist) { buf.append(" L ").append(round(x1 + xHalf)).append(" ").append(round(y1)); // (x1 + x_half, y1), xHalf may be negative. buf.append(" L ").append(round(x1 + xHalf)).append(" ").append(round(y2)); // (x1 + x_half, y2), xHalf may be negative. } else { buf.append(" L ").append(round(x1 + minXDist)).append(" ").append(round(y1)); // (x1 + dist, y1) buf.append(" L ").append(round(x1 + minXDist)).append(" ").append(round(y1 + yHalf)); // (x1 + dist, y1 + yHalf), yHalf may be buf.append(" L ").append(round(x2 - minXDist)).append(" ").append(round(y1 + yHalf)); // (x1 - dist, y1 + yHalf), yHalf may be buf.append(" L ").append(round(x2 - minXDist)).append(" ").append(round(y2)); // (x1 - dist, y2), yHalf may be negative. buf.append(" L ").append(round(x1 + xHalf)).append(" ").append(round(y1)); // (x1 + x_half, y1) buf.append(" L ").append(round(x1 + xHalf)).append(" ").append(round(y2)); // (x1 + x_half, y2) } else { buf.append(" L ").append(round(x1 - minXDist)).append(" ").append(round(y1)); // (x1 - dist, y1) buf.append(" L ").append(round(x1 - minXDist)).append(" ").append(round(y1 + yHalf)); // (x1 - dist, y1 + yHalf), yHalf may be buf.append(" L ").append(round(x2 + minXDist)).append(" ").append(round(y1 + yHalf)); // (x1 + dist, y1 + yHalf), yHalf may be buf.append(" L ").append(round(x2 + minXDist)).append(" ").append(round(y2)); // (x1 + dist, y2), yHalf may be negative. buf.append(" L ").append(round(x)).append(" ").append(round(y1)); // (x1 + x_half, y1), xHalf may be negative. buf.append(" L ").append(round(x)).append(" ").append(round(y2)); // (x1 + x_half, y2), xHalf may be negative. buf.append(" L ").append(round(x2)).append(" ").append(round(y2)); // (x2, y2).
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; }