private void display(Graphics2D g, VisualConnection node, float alpha) {

    node.paint(g, alpha);

    for (VisualConnection child : node.getChildren())
      if (child.getNode().isVisible()) display(g, child, alpha);
  }
  private void moveCategory(
      DimensionHandle dimension, CategoryHandle category, int index, VisualConnection node) {

    if (node.getChildren() == null) return;

    ArrayList<VisualConnection> children = node.getChildren();

    if (!children.isEmpty()
        && children.get(0).getNode().getToCategory().getDimension().equals(dimension)) {

      VisualConnection moveCat = null;

      for (VisualConnection child : children)
        if (child.getNode().getToCategory().equals(category)) moveCat = child;

      if (moveCat != null) {
        children.remove(moveCat);
        if (index < children.size()) children.add(index, moveCat);
        else children.add(moveCat);
      }
    } else {
      for (VisualConnection child : children) {
        moveCategory(dimension, category, index, child);
      }
    }
  }
 public void updateChildren(VisualConnection connectionNode, BarState currentState) {
   for (VisualConnection child : connectionNode.getChildren())
     if (child.getNode().isVisible()) {
       child.setState(currentState);
       updateChildren(child, currentState);
     }
 }
 public void layoutChildren(VisualConnection connectionNode, BarState currentState) {
   for (VisualConnection child : connectionNode.getChildren())
     if (child.getNode().isVisible()) {
       child.setState(currentState);
       child.layout(connectionNode.getFutureWidth());
       layoutChildren(child, currentState);
     }
 }
  private void orderChildren(VisualConnection parentNode, List<CategoryHandle> categoryOrder) {

    ArrayList<VisualConnection> newList = new ArrayList<VisualConnection>();

    newList.addAll(parentNode.getChildren());

    parentNode.getChildren().clear();

    for (CategoryHandle cat : categoryOrder) {
      for (VisualConnection ribbon : newList) {
        if (ribbon.getNode().getToCategory().equals(cat)) {
          parentNode.getChildren().add(ribbon);
        }
      }
    }
  }
  public void setColors(VisualConnection connectionNode) {

    // The top level categorical axis determines the color scheme.
    if (connectionNode.getChildren().isEmpty()) return;

    if (connectionNode == root) {
      for (VisualConnection childNode : connectionNode.getChildren()) {
        childNode.setColorBrewerIndex(childNode.getNode().getToCategory().getCategoryNum() - 1);
        setColors(childNode);
      }
    } else {
      for (VisualConnection childNode : connectionNode.getChildren()) {
        childNode.setColorBrewerIndex(connectionNode.getColorBrewerIndex());
        setColors(childNode);
      }
    }
  }
 public void findCategoryBarNode(CategoryHandle category, VisualConnection node) {
   if (!node.equals(root) && node.getNode().getToCategory().equals(category)) {
     test = node;
   } else for (VisualConnection child : node.getChildren()) findCategoryBarNode(category, child);
 }
  private void selectCategory(CategoryHandle category, VisualConnection node) {

    if (!node.equals(root) && node.getNode().getToCategory().equals(category))
      for (VisualConnection child : node.getChildren()) selectDown(child);
    else for (VisualConnection child : node.getChildren()) selectCategory(category, child);
  }
  private void displaySelected(Graphics2D g, VisualConnection node) {
    if (node.isSelected()) node.paintSelected(g);

    for (VisualConnection child : node.getChildren())
      if (child.getNode().isVisible()) displaySelected(g, child);
  }