Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //funkce na vypocet pozic
- public static Point getNodeChildernPosition(DrawNode node, NodeType childType, Integer width, Integer displaceY, Integer level, Boolean boostRoot) {
- switch (childType) {
- case ntRoot:
- return new Point(node.getFinalDrawLocation().getX(), node.getFinalDrawLocation().getY() + displaceY);
- case ntLeftSon:
- if (node.getNodeType() == NodeType.ntRoot && boostRoot) {
- return new Point(node.getFinalDrawLocation().getX() - (width / 4), node.getFinalDrawLocation().getY() + (displaceY + displaceY / 2));
- } else {
- return new Point(node.getFinalDrawLocation().getX() - (int) ((double) width / 5 / ((double) level * Math.max(1.0, (double) level - 2.5))), node.getFinalDrawLocation().getY() + displaceY);
- }
- case ntRightSon:
- if (node.getNodeType() == NodeType.ntRoot && boostRoot) {
- return new Point(node.getFinalDrawLocation().getX() + (width / 4), node.getFinalDrawLocation().getY() + (displaceY + displaceY / 2));
- } else {
- return new Point(node.getFinalDrawLocation().getX() + (int) ((double) width / 5 / ((double) level * Math.max(1.0, (double) level - 2.5))), node.getFinalDrawLocation().getY() + displaceY);
- }
- case ntNW: //1
- return new Point((int) ((double) node.getFinalDrawLocation().getX() - 3.0 * ((double) width / Math.pow((double) level, 2.0) / 8.0)), node.getFinalDrawLocation().getY() + displaceY);
- case ntNE: //2
- return new Point((int) ((double) node.getFinalDrawLocation().getX() - (double) width / Math.pow((double) level, 2.0) / 8.0), node.getFinalDrawLocation().getY() + displaceY);
- case ntSW: //3e
- return new Point((int) ((double) node.getFinalDrawLocation().getX() + (double) width / Math.pow((double) level, 2.0) / 8.0), node.getFinalDrawLocation().getY() + displaceY);
- case ntSE: //4
- return new Point((int) ((double) node.getFinalDrawLocation().getX() + 3.0 * ((double) width / Math.pow((double) level, 2.0) / 8.0)), node.getFinalDrawLocation().getY() + displaceY);
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement