|
midterm
3.21.05
canyon void

I decided to take advantage of the time element and have evolved the idea of user participation to change the concept of networked image manipulation.
For the midterm, I brought in live webcam feed from the grand canyon, created an array, and devised a method
for detecting presence which will erase the layers of the web cam image as the user looks at the image.
For the final, I continue to develop the "worm hole effect".
code:
package grancanHole;
import java.awt.*;
import java.util.ArrayList;
public class GetCan extends java.applet.Applet implements Runnable {
Image img;
MediaTracker tracker;
boolean show = false;
Thread runme;
String message="Loading...";
int imageNum=0;
int startTime = (int) System.currentTimeMillis();
int elapsedTime = 0;
ArrayList imglist = new ArrayList();
public void init() {
img = getImage( getCodeBase(), "http://www2.nature.nps.gov/air/webcams/parks/grcacam/grca.jpg" );
tracker = new MediaTracker(this);
tracker.addImage( img, imageNum );
resize (640, 480);
imglist.add(img);
// System.out.println( "the image number is:" imageNum );
}
public void GetNewImage(){
img = getImage( getCodeBase(), "http://www2.nature.nps.gov/air/webcams/parks/grcacam/grca.jpg" );
tracker = new MediaTracker(this);
tracker.addImage( img, imageNum );
imglist.add(img);
}
public void start() {
if ( !tracker.checkID( imageNum ) ) {
runme = new Thread( this );
runme.start();
}
}
public void stop() {
runme = null;
}
public void run() {
// Paint the loading message
repaint();
// The wait for the image to finish loading
try {
tracker.waitForID( imageNum );
} catch( InterruptedException e) { }
//imglist. //trimtosize is an arraylist method
// Check if there was a loading error
if ( tracker.isErrorID( imageNum ) )
message= "Error";
else
show = true;
elapsedTime = (int) System.currentTimeMillis()-startTime;
System.out.println(elapsedTime);
if (elapsedTime > 900000){
GetNewImage();
startTime = (int) System.currentTimeMillis();
elapsedTime = 0;
System.out.println("got new image");
}
repaint();
}
// Repaint with the image now if it loaded OK
public void array(){
for (int i = 0; i < imglist.size(); i++) {
imglist.get(i);
System.out.println("the number in the array is:");
System.out.println(i);
}
}
public void paint( Graphics g ) {
if ( show )
g.drawImage( img, 0, 0, this );
else {
g.drawRect( 0, 0, getSize().width-1, getSize().height-1);
g.drawString( message, 20, 20 );
}
}
}
back
|