@Override public void storeState(Hashtable<Object, Object> state) { super.storeState(state); HashtableStoreSupport.store(state, hash + "rank", rank); HashtableStoreSupport.store(state, hash + "doubleArrow", doubleArrow); HashtableStoreSupport.store(state, hash + "dashedRightLine", dashedRightLine); HashtableStoreSupport.store(state, hash + "dashedLeftLine", dashedLeftLine); }
@Override public void draw(View v) { super.draw(v); drawDoubleArrow(v); final String str = "" + rank; if (rank != -1) { if (this.getParent() != null && this.getParent().getLeft() == this) { v.drawString(str, x - Node.RADIUS, y - Node.RADIUS, Fonts.SMALL); } else { v.drawString(str, x + Node.RADIUS, y - Node.RADIUS, Fonts.SMALL); } } }
@Override protected void draw(View V) { BSTNode z; if (u != null) { z = u.getParent(); if (z == v || z == w) { V.drawWideLine(u.x, u.y, z.x, z.y); } } if (v != null) { z = v.getParent(); if (z == u || z == w) { V.drawWideLine(v.x, v.y, z.x, z.y); } } if (w != null) { z = w.getParent(); if (z == u || z == v) { V.drawWideLine(w.x, w.y, z.x, z.y); } } }
@Override public void restoreState(Hashtable<?, ?> state) { super.restoreState(state); final Object rank = state.get(hash + "rank"); if (rank != null) { this.rank = (Integer) HashtableStoreSupport.restore(rank); } final Object doubleArrow = state.get(hash + "doubleArrow"); if (doubleArrow != null) { this.doubleArrow = (Boolean) HashtableStoreSupport.restore(doubleArrow); } final Object dashedRightLine = state.get(hash + "dashedRightLine"); if (dashedRightLine != null) { this.dashedRightLine = (Boolean) HashtableStoreSupport.restore(dashedRightLine); } final Object dashedLeftLine = state.get(hash + "dashedLeftLine"); if (dashedLeftLine != null) { this.dashedLeftLine = (Boolean) HashtableStoreSupport.restore(dashedLeftLine); } }
private void recompute() { x = u.x; y = u.y; p = new Polygon(); p.addPoint(u.x - 1, u.y - 1); if (u.D.getLayout() == Layout.SIMPLE) { if (u.height == 1) { p.addPoint(u.x - 7, u.y + 10); p.addPoint(u.x + 7, u.y + 10); } else { final int x1 = u.x - u.leftw + DataStructure.minsepx / 2, x2 = u.x + u.rightw - DataStructure.minsepx / 2, y1 = u.y + DataStructure.minsepy, y2 = u.y + (u.height - 1) * DataStructure.minsepy; p.addPoint(x1, y1); p.addPoint(x1, y2); p.addPoint(x2, y2); p.addPoint(x2, y1); } } else { // TODO: BST needs to expose threads BSTNode w = u; final Stack<BSTNode> tmp = new Stack<BSTNode>(); while (u != null && w != null) { p.addPoint(u.x - 1, u.y); tmp.add(w); u = (u.getLeft() != null) ? u.getLeft() : u.getRight(); // TODO w = (w.getRight() != null) ? w.getRight() : w.getLeft(); } while (!tmp.isEmpty()) { w = tmp.pop(); p.addPoint(w.x + 1, w.y); } } p.addPoint(u.x + 1, u.y - 1); }
public void setParent(LeftHeapNode v) { super.setParent(v); }
void setLeft(LeftHeapNode v) { super.setLeft(v); }
public void setRight(LeftHeapNode v) { super.setRight(v); }