private void dibujarEntidades(Graphics grafico, IRegion region, IPunto origen) { Collection<Dibujable> todas = this.controlador.getEntidadesDibujables(); if (todas == null) { System.err.println("Error gráfico: la colección de objetos dibujables 2D es nula."); } else { for (Dibujable item : todas) { Image imagen = this.localizador.localiza(item.getImagen()); if (imagen == null) { System.err.println("Error gráfico: no se encuentra la imagen --> " + item.getImagen()); System.out.println("Se muestra la imagen por defecto"); imagen = this.noImagen; } int menorX = item.getPosicionX(); int menorY = item.getPosicionY(); int ladoX = 1; int ladoY = 1; int posX = menorX - origen.getCoordenadaX(); int posY = menorY - origen.getCoordenadaY(); if ((posX >= 0) && (posY >= 0)) { grafico.drawImage( imagen, posX * this.pixelesUnidad + 1, this.altoEscenario - (posY + ladoY) * this.pixelesUnidad + 1, ladoX * this.pixelesUnidad - 1, ladoY * this.pixelesUnidad - 1, null); } } } }
@Override public void paint(Graphics g) { super.paint(g); for (Dibujable dibujo : dibujos) { dibujo.dibujar(g); } if (dibujandoTmp && dibujableTmp != null) { dibujableTmp.dibujar(g); } }