Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
The DynamicBillboard applet displays a sequence of images by repeatedly changing the image on the screen to another after a period of time. This applet was designed by Robert Temple when he was working at at Embry-Riddle Aeronautical University in Florida.The transition between one image and the next is done with one of a variety of special effects. The DynamicBillboard applet provides web sites with an elegant way to rotate ads, banners, or billboards on a single static page. The applet links to other pages through a URL associated with each image. When the user presses the mouse button with the cursor over the applet, the browser will go to the new page associated with the current image. The applet consists of three main classes and any number of transition classes.The three main classes are DynamicBillboard, BillData, and BillTransition. 1. DynamicBillboard.java This is the main applet class. It implements Runnable to include a thread that controls the continuous process of creation and animation of the transitions. The transition classes array stores the names of the transition classes as strings. It uses strings because it loads these classes dynamically using the method java.lang.Class.forName(String). This allows the applet to put off the loading of these classes until they are first instantiated. 2. BillData.java The BillData class is mostly just a data structure for encapsulating attributes associated with individual billboards. It contains three variables. The first variable stores the URL to which the billboard is a link. The second variable has an Image that the applet uses to draw on the screen. The third variable includes a pixel array of the image in RGB format. The pixel array is used by transitions in combination with another BillData pixel array to create the cells for transition animation. The array is only one-dimensional. The pixels in it are arranged in such a way that the first element in this array is the top-left corner of the image. The second element is the pixel just to the right of this corner. Elements that follow are the pixels to the right of this one, and so on, until the rightmost pixel is reached. Then the leftmost pixel on the next line of the image is used. This continues until the last index in the array, which corresponds to the pixel on the bottom-right corner of the image 3. BillTransition.java The BillTransition class is used as a base class for other transition classes. These other classes create transition cells between two individual billboard images. This abstract class contains variables and methods that are common to all transitions. This applet consist of following transition classes: 1. ColumnTransition.java The ColumnTransition class changes one image into another by drawing increasingly large columns of the new image onto the old image. The column sizes increase to the left, and the same pixels are always drawn on the left side of each column. This makes the billboard appear to be sliding in from behind the old billboard through vertical slots in the current billboard. 2. FadeTransition.java The FadeTransition class changes one image into another by randomly including a number of new pixels from the next billboard in each successive cell frame. This makes the next billboard appear to fade in over the old billboard.
3. SmashTransition.java The SmashTransition class changes one image into another by dropping the new image onto the old one. The old image appears to crumble under the weight of the new image. 4. TearTransition.java The TearTransition creates the illusion of the current billboard getting torn off the applet like a piece of paper. It gets ripped upwards and toward the left to reveal the next billboard image underneath. 5. UnrollTransition.java UnrollTransition makes it appear as if a rolled-up poster is placed on the bottom of the applet and then unrolled upward, gradually revealing the next image and covering the old image. To enhance the unroll illusion, the roll gradually decreases in size as it makes its way upward on the billboard.
about to be added on the right edge. Then the pixel values for the next column are read and used as the color to fill a column of 88 rectangles at the right edge of the applet. The transparent column of bulbs is painted, and then the whole backing image is drawn to the screen. Since this applet doesnt have to do much except scroll the image, it avoids the normal repaint( ) loop by forking a thread that repeatedly calls paint( ), pausing only to call yield( ) to allow other threads to run.