Package com.jgraph.layout.tree.JGraphTreeLayout

Examples of com.jgraph.layout.tree.JGraphTreeLayout.StandardTreeNode


      int widestIndex = -1;
      int index = -1;
      double widestAmount = 0;
      for (Iterator it = node.children.iterator(); it.hasNext();) {
        index++;
        StandardTreeNode n = (StandardTreeNode) it.next();
        n.setDepth(node.getDepth() + 1);
        double childWidth = n.width;
        if (childWidth > widestAmount) {
          widestAmount = childWidth;
          widestIndex = index;
        }
      }
      if (widestIndex >= 0) {
        StandardTreeNode sub = (StandardTreeNode) node.children.get(widestIndex);
        sub.leftContour.dx = 0;
        sub.rightContour.dx = (sub.width - node.width) / 2 + verticalEdgeLeftInset + verticalEdgeRightInset;

        node.leftContour.next = sub.leftContour;
        node.rightContour.next = sub.rightContour;
      } else {
        StandardTreeNode sub = (StandardTreeNode) node.children.get(0);

        sub.leftContour.dx = (sub.width - node.width) / 2;
        sub.rightContour.dx = (sub.width - node.width) / 2;

        node.leftContour.next = sub.leftContour;
        node.rightContour.next = sub.rightContour;
      }
     
    } else if (node.children.size() == 1) {
      StandardTreeNode sub = (StandardTreeNode) node.children.get(0);
      sub.setDepth(node.getDepth() + 1);
      layout(sub);

      sub.leftContour.dx = (sub.width - node.width) / 2;
      sub.rightContour.dx = (sub.width - node.width) / 2;

      node.leftContour.next = sub.leftContour;
      node.rightContour.next = sub.rightContour;
    } else {
      for (Iterator it = node.children.iterator(); it.hasNext();) {
        StandardTreeNode n = (StandardTreeNode) it.next();
        n.setDepth(node.getDepth() + 1);
        layout(n);
      }

      join(node);
    }
View Full Code Here

TOP

Related Classes of com.jgraph.layout.tree.JGraphTreeLayout.StandardTreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.