public Matriz(int x, int y) { this.size_x = x; this.size_y = y; this.suma = 0; NodoMatriz nodo = new NodoMatriz(0, 0); NodoMatriz auxN = null; NodoMatriz auxF = null; NodoMatriz auxFA = null; for (int posy = 0; posy < size_y; posy++) { for (int posx = 0; posx < size_x; posx++) { if (posx == 0 && posy == 0) { auxF = nodo; } else if (posx == 0 && posy > 0) { auxFA = nodo; auxN = new NodoMatriz(posx, posy); nodo.setAbajo(auxN); auxN.setArriba(nodo); nodo = auxN; auxF = nodo; } else if (posx > 0 && posy == 0) { auxN = new NodoMatriz(posx, posy); auxF.setDerecha(auxN); auxN.setIzquierda(auxF); auxF = auxN; } else if (posx > 0 && posy > 0) { auxFA = auxFA.getDerecha(); auxN = new NodoMatriz(posx, posy); auxN.setArriba(auxFA); auxFA.setAbajo(auxN); auxN.setIzquierda(auxF); auxF.setDerecha(auxN); auxF = auxN; } } } while (nodo.getArriba() != null) { nodo = nodo.getArriba(); } this.raiz = nodo; }