|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
jsky.util.gui.ProgressBarFilterInputStream
public class ProgressBarFilterInputStream
Monitors reading from a given stream or URL and updates a given progress bar and text field to show the amount of data read so far.
Field Summary | |
---|---|
protected boolean |
interrupted
Set this to interrupt the reading and throw an exception |
protected javax.swing.DefaultBoundedRangeModel |
model
The model for the progress bar |
protected int |
nread
The number of bytes read so far |
protected ProgressBarUtil |
progressBar
The progress bar to use |
protected int |
size
The size of the data in bytes, if known, otherwise 0 |
protected long |
updateTime
Time in ms of last update (used to slow down text field updates) |
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
ProgressBarFilterInputStream(ProgressBarUtil progressBar,
javax.swing.JTextField statusField,
java.io.InputStream in,
int size)
Constructs an object to monitor the progress of an input stream using a given progress bar and text field. |
|
ProgressBarFilterInputStream(ProgressBarUtil progressBar,
javax.swing.JTextField statusField,
java.net.URL url)
Constructs an object to monitor the progress of an input stream using a given progress bar and text field. |
|
ProgressBarFilterInputStream(StatusPanel statusPanel,
java.net.URL url)
Constructs an object to monitor the progress of an input stream using a given StatusPanel object. |
Method Summary | |
---|---|
void |
checkForInterrupt()
Throw an exception if interrupt() was called on this stream. |
void |
clear()
Reset the progress bar to the idle state |
void |
close()
Overrides FilterInputStream.close
to close the progress bar as well as the stream. |
int |
getSize()
Return the size of the data to read |
void |
interrupt()
Interrupt the reading (causes the next read() to throw an exception). |
boolean |
isInterrupted()
Return true if reading was interrupted |
static void |
main(java.lang.String[] args)
Test main |
int |
read()
Overrides FilterInputStream.read
to update the progress bar after the read. |
int |
read(byte[] b,
int off,
int len)
Overrides FilterInputStream.read
to update the progress bar after the read. |
void |
reset()
Overrides FilterInputStream.reset
to reset the progress bar as well as the stream. |
protected void |
setNumBytesRead(int n)
Set the number of bytes that have been read, update the display (but not too often) and check for interrupt requests. |
void |
setSize(int size)
Set the size of the data to read |
long |
skip(long n)
Overrides FilterInputStream.skip
to update the progress bar after the skip. |
Methods inherited from class java.io.FilterInputStream |
---|
available, mark, markSupported, read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ProgressBarUtil progressBar
protected javax.swing.DefaultBoundedRangeModel model
protected int nread
protected int size
protected long updateTime
protected boolean interrupted
Constructor Detail |
---|
public ProgressBarFilterInputStream(ProgressBarUtil progressBar, javax.swing.JTextField statusField, java.io.InputStream in, int size)
progressBar
- the progress bar to usestatusField
- text field used to display status informationin
- the input stream to be monitoredsize
- the size in bytes of the date to be read, or 0 if not knownpublic ProgressBarFilterInputStream(ProgressBarUtil progressBar, javax.swing.JTextField statusField, java.net.URL url)
progressBar
- the progress bar to usestatusField
- text field used to display status informationurl
- the URL to readpublic ProgressBarFilterInputStream(StatusPanel statusPanel, java.net.URL url)
statusPanel
- used to display status informationurl
- the URL to readMethod Detail |
---|
public void interrupt()
public boolean isInterrupted()
public void checkForInterrupt() throws java.io.IOException
java.io.IOException
public void setSize(int size)
protected void setNumBytesRead(int n)
public void clear()
public int getSize()
public int read() throws java.io.IOException
FilterInputStream.read
to update the progress bar after the read.
read
in class java.io.FilterInputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
FilterInputStream.read
to update the progress bar after the read.
read
in class java.io.FilterInputStream
java.io.IOException
public long skip(long n) throws java.io.IOException
FilterInputStream.skip
to update the progress bar after the skip.
skip
in class java.io.FilterInputStream
java.io.IOException
public void close() throws java.io.IOException
FilterInputStream.close
to close the progress bar as well as the stream.
close
in interface java.io.Closeable
close
in class java.io.FilterInputStream
java.io.IOException
public void reset() throws java.io.IOException
FilterInputStream.reset
to reset the progress bar as well as the stream.
reset
in class java.io.FilterInputStream
java.io.IOException
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |