Arturo Yañez Sosa
miércoles, 21 de septiembre de 2011
miércoles, 13 de enero de 2010
PRACTICA-Rotacion
Al igual que los metodos anteriores (de Escalacion y Traslacion), usamos los mismos puntos para observar como actua cada uno, solo que en este ejercicio se anexo un punto extra, para observar mejor la rotacion de los puntos; el metodo que se explica a continuacion es el de ROTACION.
En la siguiente imagen podemos observar la graficacion de los puntos ingresados por el usuario, he colocado de color rojo la imagen original y con un color verde los puntos ROTADOS:
En las imagenes siguientes podemos observar la matriz identidad, junto con la matriz actualizada, es decir con el angulo ingresado por el usuario(que en este caso es de: 25°), asi como tambien la multiplicacion de la matriz.
Para esta primer imagen los puntos correspondientes son: (3,5).
Para esta segunda imagen los puntos correspondientes son: (10,3).
Para esta tercer imagen los puntos correspondientes son: (6,8).
PODEMOS DECIR ENTONCES, QUE LA ROTACION ES EL MOVIMIENTO DE CAMBIO DE ORIENTACION, DADO UN PUNTO CUALQUIERA DEL MISMO, LOS CUALES SE ENCUENTRAN RESPECTO A UN ANGULO PARA REALIZAR LA INCLINACION DE LOS MISMOS.
En la siguiente imagen podemos observar la graficacion de los puntos ingresados por el usuario, he colocado de color rojo la imagen original y con un color verde los puntos ROTADOS:
En las imagenes siguientes podemos observar la matriz identidad, junto con la matriz actualizada, es decir con el angulo ingresado por el usuario(que en este caso es de: 25°), asi como tambien la multiplicacion de la matriz.
Para esta primer imagen los puntos correspondientes son: (3,5).
Para esta segunda imagen los puntos correspondientes son: (10,3).
Para esta tercer imagen los puntos correspondientes son: (6,8).
PODEMOS DECIR ENTONCES, QUE LA ROTACION ES EL MOVIMIENTO DE CAMBIO DE ORIENTACION, DADO UN PUNTO CUALQUIERA DEL MISMO, LOS CUALES SE ENCUENTRAN RESPECTO A UN ANGULO PARA REALIZAR LA INCLINACION DE LOS MISMOS.
martes, 29 de diciembre de 2009
PRACTICA-Escalacion
Al igual que el metodo anterior (de Traslacion), usamos los mismos puntos para observar como actua cada uno, el metodo que se explica a continuacion es el de ESCALCION.
En la siguiente imagen podemos observar la graficacion de los puntos ingresados por el usuario, he colocado de color rojo la imagen original y con un color verde la imagen ESCALADA:
En las imagenes siguientes podemos observar la matriz identidad, junto con la matriz actualizada, es decir los puntos Sx y Sy (que en este caso son los puntos: 2,3), asi como tambien la multiplicacion de la matriz por los puntos que ingresa el usuario.
Para esta primer imagen los puntos correspondientes son: (3,5).
Para esta segunda imagen los puntos correspondientes son: (10,3).
Para esta tercer imagen los puntos correspondientes son: (6,8).
PODEMOS DECIR ENTONCES, QUE LA ESCALACION ES UNA ALTERACION DEL TAMAÑO DE UN OBJETO (O PUNTOS), DADO UN VECTOR (Sx, Sy) QUE DEFINE LA ESCALACION DE DICHO OBJETO.
En la siguiente imagen podemos observar la graficacion de los puntos ingresados por el usuario, he colocado de color rojo la imagen original y con un color verde la imagen ESCALADA:
En las imagenes siguientes podemos observar la matriz identidad, junto con la matriz actualizada, es decir los puntos Sx y Sy (que en este caso son los puntos: 2,3), asi como tambien la multiplicacion de la matriz por los puntos que ingresa el usuario.
Para esta primer imagen los puntos correspondientes son: (3,5).
Para esta segunda imagen los puntos correspondientes son: (10,3).
Para esta tercer imagen los puntos correspondientes son: (6,8).
PODEMOS DECIR ENTONCES, QUE LA ESCALACION ES UNA ALTERACION DEL TAMAÑO DE UN OBJETO (O PUNTOS), DADO UN VECTOR (Sx, Sy) QUE DEFINE LA ESCALACION DE DICHO OBJETO.
PRACTICA-Traslacion
En la siguiente imagen podemos observar la graficacion de los puntos ingresados por el usuario, he colocado de color rojo la imagen original y con un color verde la imagen trasladada:
En las imagenes siguientes podemos observar la matriz identidad, junto con la matriz actualizada, es decir los puntos Tx y Ty (que en este caso son los puntos: 2,3), asi como tambien la multiplicacion de la matriz por los puntos que ingresa el usuario.
Para esta primer imagen los puntos correspondientes son: (3,5).
Para esta segunda imagen los puntos correspondientes son: (10,3).
Para esta tercer imagen los puntos correspondientes son: (6,8).
PODEMOS DECIR ENTONCES, QUE LA TRASLACION ES UNA TRANSFORMACION PUNTUAL POR LA CUAL A TODO PUNTO DEL PLANO LE CORRESPONDE OTRO PUNTO TAMBIEN DEL PLANO(ES DECIR, UN MOVIMIENTO DE PUNTOS O DE UN OBJETO), DADO UN VECTOR (Tx, Ty) QUE DEFINE LA TRASLACION DE DICHOS PUNTOS.
En las imagenes siguientes podemos observar la matriz identidad, junto con la matriz actualizada, es decir los puntos Tx y Ty (que en este caso son los puntos: 2,3), asi como tambien la multiplicacion de la matriz por los puntos que ingresa el usuario.
Para esta primer imagen los puntos correspondientes son: (3,5).
Para esta segunda imagen los puntos correspondientes son: (10,3).
Para esta tercer imagen los puntos correspondientes son: (6,8).
PODEMOS DECIR ENTONCES, QUE LA TRASLACION ES UNA TRANSFORMACION PUNTUAL POR LA CUAL A TODO PUNTO DEL PLANO LE CORRESPONDE OTRO PUNTO TAMBIEN DEL PLANO(ES DECIR, UN MOVIMIENTO DE PUNTOS O DE UN OBJETO), DADO UN VECTOR (Tx, Ty) QUE DEFINE LA TRASLACION DE DICHOS PUNTOS.
lunes, 14 de diciembre de 2009
Avance 3: Lunes 14- Diciembre 2009
En la siguiente imagen podemos observar como obtenemos el histograma de la imagen seleccionada, se analiza la imagen nuevamente, y posteriormente podemos observar la cantidad de colores q tiene la imagen en el histograma. que va de [0-256].
IMPLEMENTACION DE CODIGO:
public void paint(Graphics g) {
int w = getSize().width;
int h = getSize().height;
int x=2;
for(int a=0;a<=255;a++){
Graphics2D g2 = (Graphics2D)g;
miR2D = new Rectangle2D.Double((double)x,255.0-(double)p.h.escala[a],1,(double)p.h.escala[a]) ;
g2.draw(miR2D);
x+=1;
}
}
Este codigo, nos sirvio para crear las barras mostradas en el histograma, esto a apartir de la creacion de un canvas para poder dibujar bien las lineas indicadoras de color.
IMPLEMENTACION DE CODIGO:
public void paint(Graphics g) {
int w = getSize().width;
int h = getSize().height;
int x=2;
for(int a=0;a<=255;a++){
Graphics2D g2 = (Graphics2D)g;
miR2D = new Rectangle2D.Double((double)x,255.0-(double)p.h.escala[a],1,(double)p.h.escala[a]) ;
g2.draw(miR2D);
x+=1;
}
}
Este codigo, nos sirvio para crear las barras mostradas en el histograma, esto a apartir de la creacion de un canvas para poder dibujar bien las lineas indicadoras de color.
APLICACIONES (Exposiciones)
lunes, 30 de noviembre de 2009
USO DEL METODO UNCARDLAYOUT:
EN ESTA SIGUIENTE IMAGEN PODEMOS OBSERVAR COMO PODEMOS DESGLOZAR LAS OPCIONES DISPONIBLES EN NUESTRO CARDLAYOUT:
DESCRIPCION:
->PODEMOS OBSERVAR COMO PODEMOS JUNTAR, NUESTRAS APLICACIONES DESDE EL METODO UN CARD LAYOUT.
OBSERVAMOS EL CODIGO QUE PODEMOS IMPLEMENTAR ACONTINUACION:
public class UnCardLayout extends Applet {
Panel card;
final static String PanelBoton="Panel con botones";
public void init() {
setLayout(new BorderLayout());
Panel ac=new Panel();
Choice c=new Choice();
c.addItem(PanelBoton);
ac.add(c);
ac.setBackground(Color.yellow);
add("North",ac);
card=new Panel();
card.setLayout(new CardLayout());
Panel p1=new Panel();
p1.setBackground(Color.BLUE);
p1.add(new Button("Boton 1"));
p1.add(new Button("Boton 2"));
p1.add(new Button("Boton 3"));
card.add(PanelBoton,p1);
add("Center",card);
}
public boolean action(Event evt,Object arg){
if(evt.target instanceof Choice){
((CardLayout)card.getLayout()).show(card,(String)arg);
return true;
}
return false;
}
}
EN ESTA SIGUIENTE IMAGEN PODEMOS OBSERVAR COMO PODEMOS DESGLOZAR LAS OPCIONES DISPONIBLES EN NUESTRO CARDLAYOUT:
DESCRIPCION:
->PODEMOS OBSERVAR COMO PODEMOS JUNTAR, NUESTRAS APLICACIONES DESDE EL METODO UN CARD LAYOUT.
OBSERVAMOS EL CODIGO QUE PODEMOS IMPLEMENTAR ACONTINUACION:
public class UnCardLayout extends Applet {
Panel card;
final static String PanelBoton="Panel con botones";
public void init() {
setLayout(new BorderLayout());
Panel ac=new Panel();
Choice c=new Choice();
c.addItem(PanelBoton);
ac.add(c);
ac.setBackground(Color.yellow);
add("North",ac);
card=new Panel();
card.setLayout(new CardLayout());
Panel p1=new Panel();
p1.setBackground(Color.BLUE);
p1.add(new Button("Boton 1"));
p1.add(new Button("Boton 2"));
p1.add(new Button("Boton 3"));
card.add(PanelBoton,p1);
add("Center",card);
}
public boolean action(Event evt,Object arg){
if(evt.target instanceof Choice){
((CardLayout)card.getLayout()).show(card,(String)arg);
return true;
}
return false;
}
}
USO DEL METODO UNGRIDBAGLAYOUT:
DESCRIPCION:
->USO DE BOTONES, AGREGADOS A UN PANEL MEDIANTE EL METODO UNGRIDBAGLAYOUT Y USO DEL METODO GRIDBAGCONSTRAINTS.
OBSERVAMOS EL CODIGO QUE PODEMOS IMPLEMENTAR ACONTINUACION:
public void init() {
GridBagLayout gridbag=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
setLayout(gridbag);
gbc.fill=GridBagConstraints.BOTH;
gbc.weightx=1.0;
Button boton0=new Button("Boton 0");
gridbag.setConstraints(boton0,gbc);
add(boton0);
Button boton1=new Button("Boton 1");
gridbag.setConstraints(boton1,gbc);
add(boton1);
.
.
.
}
DESCRIPCION:
->USO DE BOTONES, AGREGADOS A UN PANEL MEDIANTE EL METODO UNGRIDBAGLAYOUT Y USO DEL METODO GRIDBAGCONSTRAINTS.
OBSERVAMOS EL CODIGO QUE PODEMOS IMPLEMENTAR ACONTINUACION:
public void init() {
GridBagLayout gridbag=new GridBagLayout();
GridBagConstraints gbc=new GridBagConstraints();
setLayout(gridbag);
gbc.fill=GridBagConstraints.BOTH;
gbc.weightx=1.0;
Button boton0=new Button("Boton 0");
gridbag.setConstraints(boton0,gbc);
add(boton0);
Button boton1=new Button("Boton 1");
gridbag.setConstraints(boton1,gbc);
add(boton1);
.
.
.
}
Avance 2: Lunes 30-Noviembre-2009
AGREGAR LA IMAGEN SELECCIONADA DESDE EL EXPLORADOR, A UN JINTERNALFRAME:
EN LA PARTE DE ABAJO OBSERVAMOS EL CODIGO IMPLEMENTADO PARA DICHA ACCION:
DESCRIPCION:
->CARGA DE IMAGENES A UN JINTERNALFRAME DESDE LA VENTANA DEL EXPLORADOR.
SOLUCION:
->AQUI OBSERVAMOS EL CODIGO, LA SOLUCION QUE SE IMPLEMENTO PARA PODER COLOCAR LA IMAGEN EN UN JINTERNALFRAME DESDE LA VENTANA DEL EXPLORADOR:
public void AbreArchivo()
{
if(fc == null)
{
fc = new JFileChooser();
fc.setAcceptAllFileFilterUsed(false);
}
int returnVal = fc.showDialog(panel1, "Seleccione archivo");
if(returnVal == 0)
{
File file = fc.getSelectedFile();
archivo = file.getAbsolutePath();
Image img = Toolkit.getDefaultToolkit().getImage(archivo);
try
{
MediaTracker tracker = new MediaTracker(panel1);
tracker.addImage(img, 0);
tracker.waitForID(0);
}
catch(Exception ex) { }
int iw = img.getWidth(panel1);
int ih = img.getHeight(panel1);
if(iw > 0 && ih > 0)
{
bi = new BufferedImage(iw, ih, 10);
bires = new BufferedImage(iw, ih, 10);
Graphics2D big = bi.createGraphics();
Graphics2D big2 = bires.createGraphics();
big.drawImage(img, 0, 0, p);
big2.drawImage(img, 0, 0, resultado);
p.img = bi;
resultado.img = bires;
h.setImg(bi);
p.ajusta = resultado.ajusta = mnuAjusta.getState();
repaint();
} else
{
JOptionPane.showConfirmDialog(this, "Error al cargar la imagen (no existe o no es v\341lida)");
}
}
}
OBSERVAMOS Q SE CARGA LA DIREECION DE LA IMAGEN PARA POSTERIORMENTE PODER DIBUJARLA, EST0 MEDIANTE LA OBTENCION DE LA RUTA DE LA IMAGEN(OBSERVA PATH), Y USO DE UN JINTERNALFRAME.
EN LA PARTE DE ABAJO OBSERVAMOS EL CODIGO IMPLEMENTADO PARA DICHA ACCION:
DESCRIPCION:
->CARGA DE IMAGENES A UN JINTERNALFRAME DESDE LA VENTANA DEL EXPLORADOR.
SOLUCION:
->AQUI OBSERVAMOS EL CODIGO, LA SOLUCION QUE SE IMPLEMENTO PARA PODER COLOCAR LA IMAGEN EN UN JINTERNALFRAME DESDE LA VENTANA DEL EXPLORADOR:
public void AbreArchivo()
{
if(fc == null)
{
fc = new JFileChooser();
fc.setAcceptAllFileFilterUsed(false);
}
int returnVal = fc.showDialog(panel1, "Seleccione archivo");
if(returnVal == 0)
{
File file = fc.getSelectedFile();
archivo = file.getAbsolutePath();
Image img = Toolkit.getDefaultToolkit().getImage(archivo);
try
{
MediaTracker tracker = new MediaTracker(panel1);
tracker.addImage(img, 0);
tracker.waitForID(0);
}
catch(Exception ex) { }
int iw = img.getWidth(panel1);
int ih = img.getHeight(panel1);
if(iw > 0 && ih > 0)
{
bi = new BufferedImage(iw, ih, 10);
bires = new BufferedImage(iw, ih, 10);
Graphics2D big = bi.createGraphics();
Graphics2D big2 = bires.createGraphics();
big.drawImage(img, 0, 0, p);
big2.drawImage(img, 0, 0, resultado);
p.img = bi;
resultado.img = bires;
h.setImg(bi);
p.ajusta = resultado.ajusta = mnuAjusta.getState();
repaint();
} else
{
JOptionPane.showConfirmDialog(this, "Error al cargar la imagen (no existe o no es v\341lida)");
}
}
}
OBSERVAMOS Q SE CARGA LA DIREECION DE LA IMAGEN PARA POSTERIORMENTE PODER DIBUJARLA, EST0 MEDIANTE LA OBTENCION DE LA RUTA DE LA IMAGEN(OBSERVA PATH), Y USO DE UN JINTERNALFRAME.
Suscribirse a:
Entradas (Atom)