next Cell( ) Java Help

next Cell( )

The next Cen() method modifies the work..pixels may for the next cell; It loops through each line of the image starting from the bottom line and fills part of each .column by copying pixels from the next billboard onto the work_pixels array. It does not ever need to copy pixels from the old billboard, because these were already copied to the array in the init( ) method. It’s worth repeating that the pixel arrays used to form the images are only one-dimensional, Every width pixel represents one horizontal line of the Image.

Fade Transition.java 

The Fade Transition class changes one image into another by randomly Including number of new pixels from the next billboard in each successive cell frame. This nukes the next billboard appear to fade in over the old billboard. The heart of this transition is a two-dimensional array of short integers called random. This array holds an index for every element in the next ‘board’s image pixel array. These indexes are randomly distributed in the two-dissension array. The eight elements in the first dimension of this array will be used when cells are created, one for each new cell. The last element is never actually used, because there arc only seven cells. It is included when the random array is created to ensure that the indexes are randomly distributed correctly. The.FadeTransilion uses this array to pick pixels from the next billboard to overwrite pixels of the old billboard. For the first cell, the work pixels array contains nothing but pixels from the old billboard. One-eighth of these pixels get changed to the next billboard’s pixels. For the following cell, the same work_pixels array .s used, and one-eighth more pixels arc filled in from the next billboard, For this cell the result has one-fourth of tile pixels from the next billboard, while the remainder are from the old billboard. This continues until the last cell, cell number seven, which has seven-eighths of its pixels from the new billboard. Remember, the Dynamic Billboard applet simply uses the whole image from the next billboard aft~r the last cell to complete the transition.

Because the size of this two-dimensional array is dependent on the size of the applet, it must be unique to each applet. Using a static variable to store this array is unacceptable, because applets of different sizes would share this array. Since it is fairly time-consuming to create.this array, it does not make sense to re-create it every time this transition is to be used.

This is where the super class static variable, object_table, first comes into play. Once this array is created, it can be stored in this hash table with a key that includes the size of the applet. When the array needs to be used, the applet can get the appropriate one out of the hash table. If it does not exist in the hash table, the applet can then create the array and store it in the ‘hash table for future use. New applets of the same size as the current applet will benefit from a usable array already being there. This seems like a lot of effort, but in practice, web sites tend to use this applet on a large number of pages with a standard layout size for each banner advertisement. So, it saves an enormous amount of and CPU time to cache these tables.

JavaHelpOnline.com

  • Feel free to send us an inquiry, we will reply back in hours.
 

Verification

Posted on September 18, 2014 in The Dynamic Billboard Applet

Share the Story

About the Author

Back to Top