Changeset 11565


Ignore:
Timestamp:
2006-04-03T10:01:06+12:00 (18 years ago)
Author:
shaoqun
Message:

new wersion that does not use Dislay class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/java/org/nzdl/gsdl/GsdlCollageApplet/GsdlCollageApplet.java

    r11471 r11565  
    11package org.nzdl.gsdl.GsdlCollageApplet;
    22
    3 import java.applet.*;
     3import java.applet.Applet;
    44import java.awt.*;
    55import java.net.*;
     
    6767    protected DisplayImages display_thread_   = null;
    6868
    69     protected Display display_ = null;
     69   
    7070
    7171    /** Gets verbosity */
     
    9292     *     the gwcgi, collection and classifier parameters as provided.
    9393     * Then starts downloading and displaying images */
     94
     95    Thread paint ;
     96
    9497    public void init()
    9598    {       
     
    123126        System.err.println("Got parameters.");
    124127    }
    125 
     128    verbosity_=0;
    126129    if (caption_param != null && !caption_param.startsWith("_")) {
    127130        caption_ = caption_param;
     
    176179    if ((max_downloads_param!=null) && (!max_downloads_param.startsWith("_"))) {
    177180        maxDownloads_ = Integer.parseInt(max_downloads_param);
     181            System.out.println(" maxDownloads " + maxDownloads_ );
     182        maxDownloads_=50;
    178183    }
    179184
    180185    if ((max_display_param!=null) && (!max_display_param.startsWith("_"))) {
    181186        maxDisplay_ = Integer.parseInt(max_display_param);
     187             
    182188    }
    183189
     
    217223    }
    218224
     225    MediaTracker trk = new  MediaTracker(this);
    219226
    220227    // creates a class to store the image and it's associated url
    221     download_images_ = new DownloadImages(verbosity_);
     228    download_images_ = new DownloadImages( this, verbosity_,isJava2_ );
    222229    // starts the download image thread with the starting url
    223230
    224231        download_thread_ = new DownloadUrls(this, download_images_,
    225232                        image_url, href_musthave, image_mustnothave,
    226                         image_ignore, imageType_,document_root,verbosity_);
     233                        image_ignore, imageType_,document_root,verbosity_,trk);
    227234    // starts the display image thread with the currently downloaded images
    228     display_thread_ = new DisplayImages(this,download_images_, isJava2_, bgcolor_);
    229     display_ = new Display(this);
    230     }
     235    display_thread_ = new DisplayImages(this, download_images_,isJava2_, bgcolor_);
     236   
     237    }
     238
     239 
    231240
    232241    /** Goes to the url associated with the image that is clicked on screen<br>
     
    256265    public void start()
    257266    {
    258     download_thread_.start();
     267   
     268         paint =  new Thread(new Runnable(){
     269                public void run() {
     270            try {
     271
     272            Thread curr_thread = Thread.currentThread();
     273       
     274            while (curr_thread == paint) {
     275         
     276               repaint();
     277               
     278                Thread.sleep(1000);
     279                curr_thread = Thread.currentThread();
     280            }
     281
     282       
     283            } catch (Exception e) {
     284            e.printStackTrace();
     285            }
     286        }
     287
     288
     289        });
     290
     291        paint.start();
     292
     293
     294        download_thread_.start();   
     295
    259296    display_thread_.start();
    260     display_.start();
     297
    261298    }
    262299
     
    266303    download_thread_.stop();
    267304    display_thread_.stop();
    268     display_.stop();
    269 
     305   
    270306    download_thread_ = null;
    271307    display_thread_ = null;
    272     display_ = null;
     308   
    273309    }
    274310
     
    277313    {
    278314    download_thread_ = null;
     315   
    279316    display_thread_ = null;
    280     display_ = null;
    281     }
     317   
     318    }
     319
    282320
    283321    /** Repaints the applet */
     
    287325    paint(g);
    288326    }
    289        
     327   
    290328    /** Repaints the applet using the paint method of the thread that is
    291329     * currently displaying images */
    292330    public void paint(Graphics g) {
    293331    if (display_thread_!=null)
    294     {
    295         //display_thread_.display_collage();
    296         display_thread_.paint(g);
    297     }
     332        {   
     333         
     334            //display_thread_.display_collage();
     335              display_thread_.paint(g);
     336        }
    298337    else
    299     {
    300         System.err.println("Applet still trying to paint!!");
    301     }
    302     }
    303 
    304 
     338        {
     339        System.err.println("Applet still trying to paint!!");
     340        }
     341
     342   
     343   
     344    }
     345
     346 
    305347   
    306348    /** Ensures a URL address (as string) has a protocol, host, and file.
Note: See TracChangeset for help on using the changeset viewer.