public String getBranchLine() { int width = getMinWidth(); int space = width - (name.length() + 2); int left = space / 2; int right = space - left; StringBuilder r = new StringBuilder(); for (Node child : children) { int w = child.getMinWidth(); int t = child.getTopAnchor(); r.append(ws(t)); if (r.length() < left) r.append("/"); else if (r.length() > width - right) r.append("\\"); else r.append("|"); r.append(ws(w - (t))); } return r.toString(); }
public String getBranchLine() { int width = getMinWidth(); int space = width - (name.length() + 2); int left = space / 2; int right = space - left; StringBuilder r = new StringBuilder(); for (Node child : children) { int w = child.getMinWidth(); int t = child.getTopAnchor(); r.append(ws(t)); if (r.length() < left) r.append("/"); else if (r.length() > width - right) r.append("\\"); else r.append("|"); r.append(ws(w - (t))); } return r.toString(); }
public int getMinChildrenWidth() { int result = 0; for (Node child : children) result += child.getMinWidth(); result += children.size() - 1; return result; }
int width = 0; for (Node n : nodes) { n.draw(canvas, 0, width, n.getMinWidth()); width += n.getMinWidth();
int width = 0; for (Node n : nodes) { n.draw(canvas, 0, width, n.getMinWidth()); width += n.getMinWidth();
public void draw(Canvas canvas, int line, int column, int width) { canvas.set(line, getNamePos(column, width), name); if (alias) canvas.set(line + 1, column + ((width - 1) / 2), "*"); else if (!children.isEmpty()) { int[] childWidth = new int[children.size()]; int childrenWidth = 0; for (int i = 0; i < children.size(); i++) childrenWidth += childWidth[i] = children.get(i).getMinWidth(); while (childrenWidth < width) for (int i = children.size() - 1; i >= 0; i--) { childWidth[i]++; childrenWidth++; } int childCol = column; for (int i = 0; i < children.size(); i++) { Node child = children.get(i); drawEdge(canvas, line, getNamePos(column, width), name.length(), getNamePos(childCol, childWidth[i]), child.name.length()); child.draw(canvas, line + 2, childCol, childWidth[i]); childCol += childWidth[i]; } } }
public void draw(Canvas canvas, int line, int column, int width) { canvas.set(line, getNamePos(column, width), name); if (alias) canvas.set(line + 1, column + ((width - 1) / 2), "*"); else if (!children.isEmpty()) { int[] childWidth = new int[children.size()]; int childrenWidth = 0; for (int i = 0; i < children.size(); i++) childrenWidth += childWidth[i] = children.get(i).getMinWidth(); while (childrenWidth < width) for (int i = children.size() - 1; i >= 0; i--) { childWidth[i]++; childrenWidth++; } int childCol = column; for (int i = 0; i < children.size(); i++) { Node child = children.get(i); drawEdge(canvas, line, getNamePos(column, width), name.length(), getNamePos(childCol, childWidth[i]), child.name.length()); child.draw(canvas, line + 2, childCol, childWidth[i]); childCol += childWidth[i]; } } }
public int getTopAnchor() { return getMinWidth() / 2; }
public int getTopAnchor() { return getMinWidth() / 2; }
public int getMinChildrenWidth() { int result = 0; for (Node child : children) result += child.getMinWidth(); result += children.size() - 1; return result; }
public String getNameLine() { int space = getMinWidth() - name.length(); if (space <= 0) return name; int left = space / 2; int right = space - left; return ws(left) + name + ws(right); }
public String getNameLine() { int space = getMinWidth() - name.length(); if (space <= 0) return name; int left = space / 2; int right = space - left; return ws(left) + name + ws(right); }