/** * Like {@link #nodePosition(Graph,String,Point3)} but use an existing node as argument. * * @param node The node to consider. * @param pos A point that will receive the node position. */ public static void nodePosition(Node node, Point3 pos) { if (node.hasAttribute("xyz") || node.hasAttribute("xy")) { Object o = node.getAttribute("xyz"); if (o == null) o = node.getAttribute("xy"); if (o != null) { positionFromObject(o, pos); } } else if (node.hasAttribute("x")) { pos.x = (double) node.getNumber("x"); if (node.hasAttribute("y")) pos.y = (double) node.getNumber("y"); if (node.hasAttribute("z")) pos.z = (double) node.getNumber("z"); } // if (node.hasAttribute("xyz") || node.hasAttribute("xy")) { // Object o = node.getAttribute("xyz"); // // if (o == null) // o = node.getAttribute("xy"); // // if (o != null && o instanceof Object[]) { // Object oo[] = (Object[]) o; // // if (oo.length > 0 && oo[0] instanceof Number) { // pos.x = ((Number) oo[0]).doubleValue(); // // if (oo.length > 1) // pos.y = ((Number) oo[1]).doubleValue(); // if (oo.length > 2) // pos.z = ((Number) oo[2]).doubleValue(); // } // } // } else if (node.hasAttribute("x")) { // pos.x = (double) node.getNumber("x"); // // if (node.hasAttribute("y")) // pos.y = (double) node.getNumber("y"); // // if (node.hasAttribute("z")) // pos.z = (double) node.getNumber("z"); // } }
/** * Like {@link #nodePosition(Graph,String,double[])} but use an existing node as argument. * * @param node The node to consider. * @param xyz An array of at least three cells. */ public static void nodePosition(Node node, double xyz[]) { if (xyz.length < 3) return; if (node.hasAttribute("xyz") || node.hasAttribute("xy")) { Object o = node.getAttribute("xyz"); if (o == null) o = node.getAttribute("xy"); if (o != null) { positionFromObject(o, xyz); } } else if (node.hasAttribute("x")) { xyz[0] = (double) node.getNumber("x"); if (node.hasAttribute("y")) xyz[1] = (double) node.getNumber("y"); if (node.hasAttribute("z")) xyz[2] = (double) node.getNumber("z"); } }