Pages

Subscribe:

Labels

Friday, July 20, 2012

Development: Mosaic progress bar


Problemsfaced while doing the mosaic progress bar:

1) The bardoes not update concurrently.


It onlyupdates after the loop for the mosaic is done


The mainchoke point for all this is from this line

window= new PhotosaicWindow( im, sizePercent, tileSize, limit, keywords,google, flickr, files);

PhotosaicWindow calls on Photosaic constructor, and its memberfunction is used in PhotosaicWindowclass. Photosaic member functionincludes the very long process of getting images from google/flickr.

Methodstried so far:

1) Usingthread
Runnable mosaicRun = new Runnable() {
publicvoid run() {
window= new PhotosaicWindow( im, sizePercent, tileSize,
limit,keyword2, google, flickr, file2);
}
};
Runnable barRun = new Runnable() {
publicvoid run() {
intbarval = 0;
while(true) {
barval+=1;
progressBar.setValue(barval);
}
}
};
Thread thr1 = new Thread(barRun);
Thread thr2 = new Thread(mosaicRun);
thr1.start();
thr2.start();

This doesn’t work as it seems thatthread 1 is taking all the required resources, and thread 2 will only startafter thread 1 end. Also, thread using runnable is not very flexible asvariables inside it has to be ‘final’

2) Creating frame before running thechokepoint

MosaicProgressmyBar = new MosaicProgress(0, "Collecting Images");
try
{
//make sure there is source imgselected
if(flickr==1 || google==1 || own== 1)
{
...

This method doesn’twork as well. It has the same effect as the thread. If I were to add in a ‘wait’before the chokepoint, the progress bar will be updated, however a error willpop up saying something regarding to wait.
It’s as though thechokepoint is skipped and the jigsaw tries to build a puzzle with the non-existenttemp file

3) Trying to runthe progress bar inside Photosaic/PhotosaicWindowclass

public class Photosaic extendsBufferedImage {
private int tileSize;
private static BufferedImage bufImg;
public static int barCount;
publicMosaicProgress myBar;
publicJProgressBar progressBar;
JFrame mosaicProgressFrame = new JFrame("MosaicProgress");
...

This way of doing doesn’tseem to affect the progress bar created here. Any changes to the bar are notbeing shown at all. If I were to do this inside PhotosaicWindow, it will have error accessing the progress barinside Photosaic class. Similarly, ifI were to shift the progress bar into PhotosaicWindow,It will be the same as the not-updating-concurrently issue.
** This is still under development at the moment **

0 comments:

Post a Comment