public void writeInfo(String value) { WrapperStruct w = pilha.pop(); if (w == null) return; if (w.getType() == IGEDConst.VETOR) { ((Vetor) w.getStruct()).escrever(this.regVet, value); return; } w.getStruct().writeInfo(value); // apenas escreve um lavor }
public void readInfo() { WrapperStruct ws = pilha.pop(); if (ws == null) { return; } if (ws.getType() != IGEDConst.VETOR) { ws.getStruct().readInfo(); } else { ((Vetor) ws.getStruct()).ler(this.regVet); } // apenas ler o info }
public void lixeiro() { quadro.limpar(); for (WrapperStruct w : this.structs.values()) { System.out.println(w.getReferencia()); w.startRepaint(); } // Pintas as Estruturas diferentes de Nodes. List<WrapperStruct> nodes = new ArrayList<WrapperStruct>(); for (WrapperStruct w : this.structs.values()) { if (w.isDataStruct()) { System.out.println("Repintar: " + w.getReferencia()); /** * Devido a particularidade da binarytree em crescer para baixo o código deste if calcula o * limite inferior da árvore */ if (w.getType() == IGEDConst.BINARY_TREE && w.getStruct() != null) { BinaryTree bt = ((BinaryTree) w.getStruct()); bt.adjust(); this.calculaBound(bt.readField(IGEDConst.NODE_TREE_ROOT), IGEDConst.BINARY_TREE); System.out.println("o/"); } w.repintar(); } else { System.out.println("Nodes add: " + w.getReferencia()); nodes.add(w); } } this.nodesSoltos = 0; Collections.sort(nodes); for (WrapperStruct no : nodes) { if (no.getStruct() != null && !no.getStruct().isRepintado()) { no.repintar(); System.out.println("HHHHHHH"); if (no.getType() == IGEDConst.NODE) { LinkedListNode n = ((LinkedListNode) no.getStruct()); // Cria um semaphoro que bloquea a Thread equanto os nodes n forem desenhados. LinkedListNode aux = n.getProx(); // Conta com o no atual n. int count = 1; while ((aux != null) && (!aux.isAjustado()) && (aux != n)) { ++count; aux = aux.getProx(); } System.out.println("Noooode: " + count); if (count > 0) { Semaphore sem = new Semaphore(0, true); n.adjust(new Point2D.Double(getXNodeSoltos(), Quadro.YBASE_TRABALHO), sem); try { sem.acquire(count); } catch (InterruptedException ie) { } } nodesSoltos++; } else { NodeTree nt = ((NodeTree) no.getStruct()); nt.mover( new Point2D.Double(getXNodeSoltos(), this.boundsBinaryTree + this.ESPACO_ESTRUTURAS)); nt.repintar(); nodesSoltos++; } // // LinkedListNode n = ((LinkedListNode) no.getStruct()); // // ((LinkedListNode) no.getStruct()).adjust(new // Point2D.Double(getXNodeSoltos(), yBaseTrabalho)); // nodesSoltos++; } else { no.repintar(); } } quadro.atualizar(); clearStack(); this.vi.repintar(); }