Professional Documents
Culture Documents
==============================================
JAVA 2D
Obtenga la siguiente imagen y texto mostrada en la figura, usado Java 2D.
Envía tu archivo a través de este medio.
Desarrollo:
Ejemplo 1
import java.awt.*;
public TiledImages() {
BufferedImage image =
ImageUtilities.getBufferedImage(imageFile1, this);
imageRect =
new Rectangle(235, 70, image.getWidth(), image.getHeight());
imagePaint1 =
new TexturePaint(image, imageRect);
image = ImageUtilities.getBufferedImage(imageFile2, this);
imagePaint2 =
new TexturePaint(image, new Rectangle(0, 0, 32, 32));
}
ImageUtilities.java
import java.awt.*;
import java.awt.image.*;
/** Create Image from a file, then turn that into a BufferedImage.
*/
/** Take some Images associated with files, and wait until they
* are done loading. Just a simple application of MediaTracker.
*/
public static boolean waitForImages(Image[] images, Component c) {
MediaTracker tracker = new MediaTracker(c);
for(int i=0; i<images.length; i++)
tracker.addImage(images[i], 0);
try {
tracker.waitForAll();
} catch(InterruptedException ie) {}
return(!tracker.isErrorAny());
}
}