csound
asked on
ProgressMonitorInputStream
Can anyone please tell me how to assign ProgressMonitorInputStream to the following code? So that we can see how far the process has completed.
ArrayList images=new ArrayList();
ZipInputStream zin = new ZipInputStream(new FileInputStream(filename)) ;
ZipEntry zent= zin.getNextEntry();
JPEGImageDecoder decoder1=JPEGCodec.createJ PEGDecoder (zin);
BufferedImage bi1=decoder1.decodeAsBuffe redImage() ;
AffineTransformOp aop1=new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BIL INEAR);
BufferedImageFilter bif1=new BufferedImageFilter(aop1);
FilteredImageSource fsource1=new FilteredImageSource(bi1.ge tSource(), bif1);
Image img1=Toolkit.getDefaultToo lkit().cre ateImage(f source1);
images.add(new ImageIcon(img1, "Map"));
zin.closeEntry();
zent=zin.getNextEntry();
while(! zent .getName().equals("data.se r"))
{
JPEGImageDecoder decoder2=JPEGCodec.createJ PEGDecoder (zin);
BufferedImage bi2=decoder2.decodeAsBuffe redImage() ;
AffineTransformOp aop2=new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BIL INEAR);
BufferedImageFilter bif2=new BufferedImageFilter(aop2);
FilteredImageSource fsource2=new FilteredImageSource(bi2.ge tSource(), bif2);
Image img2=Toolkit.getDefaultToo lkit().cre ateImage(f source2);
String imgName=new File(zent.getName()).getNa me();
images.add(new ImageIcon(img2, imgName.endsWith(".jpg")?i mgName.sub string(0,i mgName.len gth()-4):i mgName));
zent=zin.getNextEntry();
}
ObjectInputStream oin = new ObjectInputStream(zin);
Object data= oin.readObject();
zin.closeEntry();
ArrayList images=new ArrayList();
ZipInputStream zin = new ZipInputStream(new FileInputStream(filename))
ZipEntry zent= zin.getNextEntry();
JPEGImageDecoder decoder1=JPEGCodec.createJ
BufferedImage bi1=decoder1.decodeAsBuffe
AffineTransformOp aop1=new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BIL
BufferedImageFilter bif1=new BufferedImageFilter(aop1);
FilteredImageSource fsource1=new FilteredImageSource(bi1.ge
Image img1=Toolkit.getDefaultToo
images.add(new ImageIcon(img1, "Map"));
zin.closeEntry();
zent=zin.getNextEntry();
while(! zent .getName().equals("data.se
{
JPEGImageDecoder decoder2=JPEGCodec.createJ
BufferedImage bi2=decoder2.decodeAsBuffe
AffineTransformOp aop2=new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BIL
BufferedImageFilter bif2=new BufferedImageFilter(aop2);
FilteredImageSource fsource2=new FilteredImageSource(bi2.ge
Image img2=Toolkit.getDefaultToo
String imgName=new File(zent.getName()).getNa
images.add(new ImageIcon(img2, imgName.endsWith(".jpg")?i
zent=zin.getNextEntry();
}
ObjectInputStream oin = new ObjectInputStream(zin);
Object data= oin.readObject();
zin.closeEntry();
It would be more appropriate IMHO to use a progress monitor on zip entries rather than use ProgressMonitorInputStream
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ZipInputStream zin = new ZipInputStream(
new ProgressMonitorInputStream (comp, "Unzipping...",
new FileInputStream(filename)) );
new ProgressMonitorInputStream
new FileInputStream(filename))
ASKER
-> CEHJ
what's IMHO?
what's IMHO?
in my humble opinion. But give it a try with objects' suggestion first.
ASKER
The progress monitor does not get displayed..
It may not need to, it only displays if the reading takes a while.
How big is your zip file?
http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html
How big is your zip file?
http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html
ASKER
The progress monitor does not get displayed..
You can adjust the settings using the ProgressMonitor class.
ASKER
The file size was about 70K.
ASKER
So I have to
ProgressMonitorInputStream pmi=new ProgressMonitorInputStream (comp, "Unzipping...",
new FileInputStream(filename)) ;
ProgressMonitor pm=pmi.getProgressMonitor( );
//do some setting
ZipInputStream zin = new ZipInputStream(
pmi);
Is this correct?
ProgressMonitorInputStream
new FileInputStream(filename))
ProgressMonitor pm=pmi.getProgressMonitor(
//do some setting
ZipInputStream zin = new ZipInputStream(
pmi);
Is this correct?
It seems to me the processing overhead is confined to what's going on in your loop, which is a good reason why the progress monitor should not be attached to the input stream
csound> Is this correct?
yes
cehj> It seems to me the processing overhead is confined to
cehj> what's going on in your loop, which is a good reason why
cehj> the progress monitor should not be attached to the input stream
But the loop is reading the stream?
yes
cehj> It seems to me the processing overhead is confined to
cehj> what's going on in your loop, which is a good reason why
cehj> the progress monitor should not be attached to the input stream
But the loop is reading the stream?
I suppose if the next read of the stream is going to have to wait on the processing, then it can be made to amount to the same thing yes.