// convert coordinates to relative coordinates with the top-left one as (0,0) public void convertToRelativePositions() { LayoutBox box = getExactLayoutBox(); // System.out.println("Box // ("+box.topleft.x+","+box.topleft.y+");("+(box.topleft.x+box.width)+","+(box.topleft.y+box.height)); Iterator<NodeLayout> e = nodes.iterator(); NodeLayout nl; while (e.hasNext()) { nl = e.next(); /* Debug code if(nl.x<box.topleft.x || nl.y<box.topleft.y || nl.x>(box.topleft.x+box.width) || nl.y>(box.topleft.y+box.height)){ System.out.println("Invalid node "+nl.x+","+nl.y); } //*/ nl.x = nl.x - box.topleft.x; nl.y = nl.y - box.topleft.y; } Iterator<EdgeLayout> e2 = edges.iterator(); EdgeLayout el; while (e2.hasNext()) { el = e2.next(); for (LayoutPoint lp : el.bends) { lp.x = lp.x - box.topleft.x; lp.y = lp.y - box.topleft.y; } } }
public void flipLayoutUpDown() { LayoutBox box = getExactLayoutBox(); Iterator<NodeLayout> ne = nodes.iterator(); while (ne.hasNext()) { NodeLayout nl = ne.next(); if (isSecondary(nl)) { nl.y = box.topleft.y + (box.height - (nl.y - box.topleft.y)) - 12; } else { nl.y = box.topleft.y + (box.height - (nl.y - box.topleft.y)) - 20; } } Iterator<EdgeLayout> e2 = edges.iterator(); EdgeLayout el; while (e2.hasNext()) { el = e2.next(); for (LayoutPoint lp : el.bends) { lp.y = box.topleft.y + (box.height - (lp.y - box.topleft.y)); } } }
public void filpLayoutUpDown() { LayoutBox box = getExactLayoutBox(); Iterator<NodeLayout> ne = nodes.iterator(); while (ne.hasNext()) { NodeLayout nl = ne.next(); if (nl.cofactor.equalsIgnoreCase("true")) { nl.y = box.topleft.y + (box.height - (nl.y - box.topleft.y)) - 12; } else { nl.y = box.topleft.y + (box.height - (nl.y - box.topleft.y)) - 20; } } Iterator<EdgeLayout> e2 = edges.iterator(); EdgeLayout el; while (e2.hasNext()) { el = e2.next(); for (LayoutPoint lp : el.bends) { lp.y = box.topleft.y + (box.height - (lp.y - box.topleft.y)); } } }
// convert coordinates to shifted coordinates with the top-left one as (xs,ys) public void convertToShiftedPositions(double xs, double ys) { convertToRelativePositions(); Iterator<NodeLayout> e = nodes.iterator(); NodeLayout nl; while (e.hasNext()) { nl = e.next(); nl.x += xs; nl.y += ys; } Iterator<EdgeLayout> e2 = edges.iterator(); EdgeLayout el; while (e2.hasNext()) { el = e2.next(); for (LayoutPoint lp : el.bends) { lp.x += xs; lp.y += ys; } } }