Cita de: tincopasan en 7 Octubre 2009, 04:20 AM
probaste con un editor de recursos?
Te voy a seguir por todos lados.... mandalo!!!!!!!!








Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúCita de: tincopasan en 7 Octubre 2009, 04:20 AM
probaste con un editor de recursos?
private void animar() {
try{
h = new hilo(100, this);
h.start();
}catch(Exception e){
h.stop();
}
}
class hilo extends Thread {
private int dist=0;
private int mseg;
private animacionTexto aT;
public hilo(int mseg, animacionTexto aT)
{
dist = 0;
mseg = mseg;
this.aT=aT;
}
public void run()
{
try{
for(int y=0; y<17; y++){
sleep(mseg);
aT.moverX(dist+=25);
}
}catch(InterruptedException e){
}
}
}
public BufferedImage dibujarArbol(nodo raiz,int x,int y)
{
if (raiz.esHoja()) return dibujarNodo(raiz);
ArrayList<BufferedImage> imagenes=new ArrayList<BufferedImage>();
BufferedImage imagenFinal;
int ancho=0,alto=0;
for (Object hijo : raiz.getHijos())
{
nodo son=(nodo)hijo;
BufferedImage im=dibujarArbol(son,0,0);
imagenes.add(im);
ancho+=im.getWidth()+GAP_X;
if(im.getHeight()>alto) alto=im.getHeight();
}
alto+=ALTO_NODO+2*GAP_Y;
BufferedImage imagenRaiz=dibujarNodo(raiz);
if(ancho<imagenRaiz.getHeight())ancho=imagenRaiz.getHeight();
imagenFinal=new BufferedImage(ancho, alto, BufferedImage.TYPE_INT_RGB);
imagenFinal.getGraphics().setColor(Color.white);
imagenFinal.getGraphics().fillRect(0, 0, getWidth(), getHeight());
Graphics2D g2d=imagenFinal.createGraphics();
g2d.drawImage(imagenRaiz, ancho/2-ANCHO_NODO/2, 0, null);
int posx=GAP_X;
for (BufferedImage bNodo : imagenes) {
g2d.setColor(Color.RED);
g2d.setStroke(new BasicStroke(2));
g2d.drawLine(ancho/2, ALTO_NODO+0, posx+bNodo.getWidth()/2, ALTO_NODO+GAP_Y*2);
g2d.drawImage(bNodo, posx, ALTO_NODO+2*GAP_Y, this);
posx+=bNodo.getWidth()+GAP_X;
}
imagenFinal.getGraphics().setColor(Color.black);
imagenFinal.getGraphics().drawRect(0, 0, getWidth(), getHeight());
return imagenFinal;
}
/**
* netodo para dibujar un solo nodo
* @param n el nodo a dibujar
* @return una imagen con le nodo dibujado
*/
private BufferedImage dibujarNodo(nodo n)
{
BufferedImage imagenNodo=new BufferedImage(ANCHO_NODO, ALTO_NODO, BufferedImage.TYPE_INT_RGB);
Graphics2D g=imagenNodo.createGraphics();
g.setColor(Color.CYAN);
g.fillRect(0, 0, ANCHO_NODO, ALTO_NODO);
BasicStroke bs=new BasicStroke(3);
g.setStroke(bs);
g.setColor(Color.BLACK);
g.drawRect(0, 0, ANCHO_NODO-1, ALTO_NODO-1);
g.setColor(Color.BLUE);
g.setFont(new Font("Arial", Font.BOLD,20));
g.drawString(n.toString(), 10, ALTO_NODO/2);
return imagenNodo;
}
File archivo = new File("imagen.png");
BufferedImage img =ImageIO.read(archivo);
int alto=im.getHeight();
int ancho=im.getWidth();
int rojo=new int[alto][ancho];
int azul=new int[alto][ancho];
int verde=new int[alto][ancho];
for (int i = 0; i < rojo.length; i++)
{
for (int j = 0; j < rojo[0].length; j++)
{
int valor=im.getRGB(j, i);
rojo[i][j]= (valor & 0x00ff0000)>> 16;
verde[i][j]= (valor & 0x0000ff00)>> 8;
azul[i][j]= (valor & 0x000000ff);
}
}