Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

Travel through time with Java

Explore a simple Java-based technique for visiting the past and the future

Many people are fascinated with the possibility of traveling through time. Over the years, a considerable number of television shows and movies have been created to exploit this fascination. Two of these movies, along with a third movie that appears to be under development, focus on two alleged time-travel events occurring in 1943 and 2000:

  • The Philadelphia Experiment: In 1943, the United States Navy supposedly tested technology for making a warship invisible to radar and floating mines. The ship used in the test was the U.S.S. Eldridge. During the test, the U.S.S. Eldridge disappeared and reappeared about four hours later. Some of the sailors were found fused to the ship, some sailors were on fire, some had heart attacks, others appeared to be insane, and a few sailors seemed to disappear without ever being seen again. Legend has it that this ship traveled forty years into the future and ended up in Montauk, New York, prior to its return. Learn more about the Philadelphia Experiment by visiting Resources. Also, you might want to watch the 1984 The Philadelphia Experiment and 1993 Philadelphia Experiment II movies.
  • John Titor's arrival: On November 2, 2000, someone calling himself Timetravel_0, and later on John Titor, began posting on a public forum that he was a time traveler from the year 2036. He posted pictures of his time-travel device and its operations manual, answered various questions about life in his time, and made various predictions of future events, including a woman president in 2008—some of these predictions have already manifested themselves. John mentioned visiting his parents and his younger self, and, on March 21, 2001, announced his upcoming departure back to the future. John has not been heard from since. If you Google the Internet, you will discover many Websites, including the official John Titor Website (see Resources for a link), that are devoted to this unusual character. The John Titor Website mentions that a movie about John Titor is in the works.


Scientists believe you need a wormhole (or some other exotic device) to travel through time. But in 2002, I discovered another way to visit the past and any one of the many possible futures. All this computer-based technique requires is an appropriate programming language, such as Java. I prefer to use Java because Java's support for big integers and buffered images greatly facilitates the implementation of this technique.

It's all about pictures

You have probably heard someone refer to a picture as being worth a thousand words. Pictures save people time by sparing them from having to accurately describe, via many spoken words, what those pictures express. Perhaps even more importantly, pictures are windows into the past. Whenever you look at a picture, you are looking back in time to the moment when that picture was taken. From that perspective, you are traveling back in time. Confused? Sit back, close your eyes, and think about this concept before continuing to read this article.

Note
While you are thinking about pictures and the past, you might want to think about this: if you create a picture of some item from some possible future, are you also looking back in time to the moment when this picture was created, whenever you look at the picture?


A picture appears on a computer screen as a rectangular grid of colored pixels, an image. I believe that generating all possible images from a solid black image to a solid white image will reveal the past and all possible futures. All it takes to accomplish this task is a simple algorithm. The following algorithm, which I have expressed in pseudocode, uses constants NROWS and NCOLS to describe each image's pixel resolution, and assumes the maximum number of colors per pixel to be 224 or 16,777,216 colors:

 LET NROWS = 100 ' 100 rows in image
LET NCOLS = 100 ' 100 columns in image
 
DIM image [NROWS][NCOLS] ' Create 100x100 array of 32-bit integers. Each entry 
                         ' represents a color, ranging from 0 (black) through
                         ' 16777215 (white). Each entry defaults to 0 (black).
 
' Generate and display all possible images for the 100x100 resolution and the
' 2^24 possible colors per pixel.
 
' The stopping condition is the lower-right pixel -- image[NROWS-1][NCOLS-1] 
' -- exceeding the white color. This is analogous to setting up a counter that 
' counts all possible values from 0 through 99. When the counter reaches 100, 
' you know that it has gone through all 100 values (0 through 99).
 
' For each iteration of the while loop, we increment the color in image[0][0],
' the upper-left pixel. When this color reaches one past white (16777216, in
' other words), we have the equivalent of a mathematical carry. We propagate
' this carry to the pixel to the right of image[0][0], by incrementing
' image[0][1]. If we go past white, we propagate to image[0][2], and continue
' until we reach the pixel in the lower-right corner. Eventually, the while
' loop will come to an end, having generated every possible color combination.
 
' Think of this algorithm as performing roughly the same task as adding two or
' more numbers (with a carry each time a digit column sum exceeds 9).
 
WHILE image [NROWS-1][NCOLS-1] != 16777216
  DISPLAY image
  INCREMENT image [0][0]
  IF image [0][0] == 16777216 THEN
     LET image [0][0] = 0;
     FOR index = 1 TO NROWS*NCOLS-1
         INCREMENT image [index/NROWS][index%NCOLS]
         IF image [index/NROWS][index%NCOLS] != 16777216 THEN
            BREAK
         ELSE
            IF index != NROWS*NCOLS-1 THEN
               LET image [index/NROWS][index%NCOLS] = 0
            ENDIF 
         ENDIF
     ENDFOR
  ENDIF
ENDWHILE


The algorithm reveals many meaningless images between the solid black and solid white extremes; they exhibit a randomness much like "snow" that often appears on a television screen when a channel's signal is lost. Other images are meaningful, and reveal people's faces, city skylines, animals, and so forth. Many of those images are part of the real past (the Titanic sinking in the early part of the twentieth century), an imagined past (President Al Gore), or a possible future (human beings living on the moon).

1 | 2 | 3 |  Next >

Discuss

Start a new discussion or jump into one of the threads below:

Subject Replies Last post
. Pretty Interesting! Reducing the search space...
By h3nryx
0 09/26/07 12:02 PM
by h3nryx
. Grid computing application!
By Anonymous
9 12/01/06 01:13 PM
by Gary_J_Korman
. What is 2^6558720 images in powers of 10 terms?
By Anonymous
1 10/04/06 07:22 AM
by Anonymous
. not helpful
By Anonymous
2 10/04/06 07:20 AM
by Anonymous
. The problem with such ideas
By Matthias
1 10/03/06 02:23 PM
by Anonymous


Resources