public static TextureGraphNode load(Scanner s) { int x = s.nextInt(); int y = s.nextInt(); boolean isFolded = false; if (s.hasNextInt()) { // this check is needed to be compatible to files savec in version 0.6.3 // and earlier (where no folding existed) isFolded = (s.nextInt() == 1); } TextureGraphNode ret = new TextureGraphNode(Channel.loadChannel(s)); ret.setLocation(x, y); ret.setFolded(isFolded); return ret; }
// saves only the node; not the Connection!! public void save(Writer w, TextureGraphNode n) throws IOException { w.write(String.format("%d %d %d\n", n.getX(), n.getY(), folded ? 1 : 0)); Channel.saveChannel(w, texChannel); }
// Utility method to check if the mouse position is inside the // connection point public boolean inside(int px, int py) { return ((px >= getX() + parent.getX()) && (px <= (getX() + parent.getX() + width)) && (py >= getY() + parent.getY()) && (py <= (getY() + parent.getY() + height))); }
public int getWorldSpaceY() { return parent.getY() + getY() + 4; }
public int getY() { if (y > 16 && parent.isFolded()) return y - 64; // !!HACK return y; }
/** @return a true copy of the current node */ public TextureGraphNode cloneThisNode() { TextureGraphNode ret = new TextureGraphNode(Channel.cloneChannel(texChannel)); ret.setLocation(getX(), getY()); return ret; }