?
Solved

ProgressMonitorInputStream

Posted on 2003-03-12
14
Medium Priority
?
316 Views
Last Modified: 2010-03-31
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.createJPEGDecoder(zin);
     BufferedImage bi1=decoder1.decodeAsBufferedImage();
     AffineTransformOp aop1=new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR);
     BufferedImageFilter bif1=new BufferedImageFilter(aop1);
     FilteredImageSource fsource1=new FilteredImageSource(bi1.getSource(), bif1);
     Image img1=Toolkit.getDefaultToolkit().createImage(fsource1);



     images.add(new ImageIcon(img1, "Map"));
     zin.closeEntry();
     zent=zin.getNextEntry();

     while(! zent .getName().equals("data.ser"))
         {
          JPEGImageDecoder decoder2=JPEGCodec.createJPEGDecoder(zin);
          BufferedImage bi2=decoder2.decodeAsBufferedImage();
          AffineTransformOp aop2=new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR);
          BufferedImageFilter bif2=new BufferedImageFilter(aop2);
          FilteredImageSource fsource2=new FilteredImageSource(bi2.getSource(), bif2);
          Image img2=Toolkit.getDefaultToolkit().createImage(fsource2);
          String imgName=new File(zent.getName()).getName();
          images.add(new ImageIcon(img2, imgName.endsWith(".jpg")?imgName.substring(0,imgName.length()-4):imgName));
          zent=zin.getNextEntry();
         }

     ObjectInputStream oin = new ObjectInputStream(zin);

     Object data= oin.readObject();

     zin.closeEntry();
0
Comment
Question by:csound
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 4
14 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 8123854
It would be more appropriate IMHO to use a progress monitor on zip entries rather than use ProgressMonitorInputStream
0
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 8123913
ZipInputStream zin = new ZipInputStream(
   new ProgressMonitorInputStream(comp, "Unzipping...",
new FileInputStream(filename)));
   
0
 
LVL 92

Expert Comment

by:objects
ID: 8123914
ZipInputStream zin = new ZipInputStream(
   new ProgressMonitorInputStream(comp, "Unzipping...",
new FileInputStream(filename)));
   
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:csound
ID: 8123928
-> CEHJ
what's IMHO?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8123946
in my humble opinion. But give it a try with objects' suggestion first.
0
 

Author Comment

by:csound
ID: 8124040
The progress monitor does not get displayed..
0
 
LVL 92

Expert Comment

by:objects
ID: 8124058
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

0
 

Author Comment

by:csound
ID: 8124063
The progress monitor does not get displayed..
0
 
LVL 92

Expert Comment

by:objects
ID: 8124070
You can adjust the settings using the ProgressMonitor class.
0
 

Author Comment

by:csound
ID: 8124077
The file size was about 70K.
0
 

Author Comment

by:csound
ID: 8124112
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?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8124127
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
0
 
LVL 92

Expert Comment

by:objects
ID: 8124153
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?

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8124208
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.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question