diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/net/java/joglutils/msg/test/BasicFetcher.java | 206 | ||||
-rw-r--r-- | src/net/java/joglutils/msg/test/DisplayShelf.java | 17 | ||||
-rw-r--r-- | src/net/java/joglutils/msg/test/DisplayShelfRenderer.java | 116 | ||||
-rw-r--r-- | src/net/java/joglutils/msg/test/Fetcher.java | 77 | ||||
-rw-r--r-- | src/net/java/joglutils/msg/test/ProgressEvent.java | 78 | ||||
-rw-r--r-- | src/net/java/joglutils/msg/test/ProgressListener.java | 54 |
6 files changed, 498 insertions, 50 deletions
diff --git a/src/net/java/joglutils/msg/test/BasicFetcher.java b/src/net/java/joglutils/msg/test/BasicFetcher.java new file mode 100644 index 0000000..277e7fb --- /dev/null +++ b/src/net/java/joglutils/msg/test/BasicFetcher.java @@ -0,0 +1,206 @@ +/* + * Copyright 2007 Sun Microsystems, Inc., 4150 Network Circle, + * Santa Clara, California 95054, U.S.A. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Sun Microsystems nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.java.joglutils.msg.test; + +import java.awt.EventQueue; +import java.awt.image.*; +import java.io.*; +import java.net.*; +import java.util.*; +import java.util.concurrent.*; +import javax.imageio.*; + +/** + * Basic implementation of Fetcher using ImageIO and a single-threaded + * ExecutorService. + * + * @author Kenneth Russell + */ + +public class BasicFetcher<IDENT> implements Fetcher<IDENT> { + private volatile ArrayList<ProgressListener> listeners = new ArrayList<ProgressListener>(); + private Map<FetchKey, Future<BufferedImage>> activeTasks = new HashMap<FetchKey, Future<BufferedImage>>(); + + private ExecutorService threadPool; + + public BasicFetcher() { + threadPool = Executors.newSingleThreadExecutor(new ThreadFactory() { + public Thread newThread(Runnable r) { + Thread t = Executors.defaultThreadFactory().newThread(r); + t.setPriority(Thread.NORM_PRIORITY - 2); + return t; + } + }); + } + + public synchronized BufferedImage getImage(final Object imageDescriptor, + final IDENT clientIdentifier, + final int requestedImageSize) { + FetchKey key = new FetchKey(imageDescriptor, clientIdentifier, requestedImageSize); + Future<BufferedImage> result = activeTasks.get(key); + if (result != null) { + try { + return result.get(1, TimeUnit.MILLISECONDS); + } catch (Exception e) { + return null; + } + } + + FutureTask<BufferedImage> task = new FutureTask<BufferedImage>(new Callable<BufferedImage>() { + public BufferedImage call() { + try { + if (imageDescriptor instanceof File) { + return ImageIO.read((File) imageDescriptor); + } else if (imageDescriptor instanceof URL) { + return ImageIO.read((URL) imageDescriptor); + } else { + throw new RuntimeException("Unsupported ImageDescriptorType " + imageDescriptor.getClass().getName()); + } + } catch (Exception e) { + System.out.println("Exception loading " + imageDescriptor + ":"); + e.printStackTrace(); + return null; + } finally { + fireProgressEnd(new ProgressEvent(BasicFetcher.this, + imageDescriptor, + clientIdentifier, + 1.0f, + true)); + } + } + }); + activeTasks.put(key, task); + threadPool.execute(task); + return null; + } + + public void cancelDownload(Object imageDescriptor, + IDENT clientIdentifier, + int requestedImageSize) { + } + + public synchronized void addProgressListener(ProgressListener listener) { + ArrayList<ProgressListener> newListeners = (ArrayList<ProgressListener>) listeners.clone(); + newListeners.add(listener); + listeners = newListeners; + } + + public synchronized void removeProgressListener(ProgressListener listener) { + ArrayList<ProgressListener> newListeners = (ArrayList<ProgressListener>) listeners.clone(); + newListeners.remove(listener); + listeners = newListeners; + } + + //---------------------------------------------------------------------- + // Internals only below this point + // + + class FetchKey { + private Object imageDescriptor; + private IDENT clientIdentifier; + private int requestedImageSize; + + public FetchKey(Object imageDescriptor, + IDENT clientIdentifier, + int requestedImageSize) { + this.imageDescriptor = imageDescriptor; + this.clientIdentifier = clientIdentifier; + this.requestedImageSize = requestedImageSize; + } + + public Object getImageDescriptor () { return imageDescriptor; } + public IDENT getClientIdentifier () { return clientIdentifier; } + public int getRequestedImageSize() { return requestedImageSize; } + + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (getClass() != o.getClass()) return false; + + FetchKey other = (FetchKey) o; + return (requestedImageSize == other.requestedImageSize && + imageDescriptor.equals(other.imageDescriptor) && + clientIdentifier.equals(other.clientIdentifier)); + } + + public int hashCode() { + int result; + result = clientIdentifier.hashCode(); + result = 29 * result + imageDescriptor.hashCode(); + result = 29 * result + requestedImageSize; + return result; + } + } + + private synchronized void fireProgressStart(final ProgressEvent e) { + List<ProgressListener> curListeners = listeners; + for (ProgressListener listener : curListeners) { + final ProgressListener finalListener = listener; + invokeLaterOnEDT(new Runnable() { + public void run() { + finalListener.progressStart(e); + } + }); + } + } + + private synchronized void fireProgressUpdate(final ProgressEvent e) { + List<ProgressListener> curListeners = listeners; + for (ProgressListener listener : curListeners) { + final ProgressListener finalListener = listener; + invokeLaterOnEDT(new Runnable() { + public void run() { + finalListener.progressUpdate(e); + } + }); + } + } + + private synchronized void fireProgressEnd(final ProgressEvent e) { + List<ProgressListener> curListeners = listeners; + for (ProgressListener listener : curListeners) { + final ProgressListener finalListener = listener; + invokeLaterOnEDT(new Runnable() { + public void run() { + finalListener.progressEnd(e); + } + }); + } + } + + private void invokeLaterOnEDT(Runnable runnable) { + if (EventQueue.isDispatchThread()) { + runnable.run(); + } else { + EventQueue.invokeLater(runnable); + } + } +} diff --git a/src/net/java/joglutils/msg/test/DisplayShelf.java b/src/net/java/joglutils/msg/test/DisplayShelf.java index 02d9e28..de08225 100644 --- a/src/net/java/joglutils/msg/test/DisplayShelf.java +++ b/src/net/java/joglutils/msg/test/DisplayShelf.java @@ -43,12 +43,17 @@ import java.awt.Frame; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.event.*; +import java.net.*; import javax.swing.*; import javax.media.opengl.*; -/** A test implementing a 3D display shelf component. */ +/** + * A test implementing a 3D display shelf component. + * + * @author Kenneth Russell + */ public class DisplayShelf { public static void main(String[] args) { @@ -119,8 +124,16 @@ public class DisplayShelf { "http://download.java.net/media/jogl/builds/ds_tmp/dj.zfqfgoas.200x200-75.jpg", "http://download.java.net/media/jogl/builds/ds_tmp/mzi.uswlslxx.200x200-75.jpg" }; + DefaultListModel model = new DefaultListModel(); + for (String str : images) { + try { + model.addElement(new URL(str)); + } catch (Exception e) { + e.printStackTrace(); + } + } - DisplayShelfRenderer renderer = new DisplayShelfRenderer(images); + DisplayShelfRenderer renderer = new DisplayShelfRenderer(model); GLCanvas canvas = new GLCanvas(new GLCapabilities(), null, renderer.getSharedContext(), null); canvas.setFocusable(true); canvas.addGLEventListener(renderer); diff --git a/src/net/java/joglutils/msg/test/DisplayShelfRenderer.java b/src/net/java/joglutils/msg/test/DisplayShelfRenderer.java index 6d87a87..e9eb1ea 100644 --- a/src/net/java/joglutils/msg/test/DisplayShelfRenderer.java +++ b/src/net/java/joglutils/msg/test/DisplayShelfRenderer.java @@ -44,7 +44,9 @@ import java.awt.event.*; import java.awt.image.*; import java.net.*; import java.util.*; -import javax.imageio.*; + +import javax.swing.*; +import javax.swing.event.*; import javax.media.opengl.*; import com.sun.opengl.util.j2d.*; @@ -55,6 +57,13 @@ import net.java.joglutils.msg.math.*; import net.java.joglutils.msg.misc.*; import net.java.joglutils.msg.nodes.*; +/** + * A test implementing a 3D display shelf component. This renderer is + * pluggable into any JOGL GLAutoDrawable. + * + * @author Kenneth Russell + */ + public class DisplayShelfRenderer implements GLEventListener { private float DEFAULT_ASPECT_RATIO = 0.665f; // This also affects the spacing @@ -74,14 +83,14 @@ public class DisplayShelfRenderer implements GLEventListener { private PerspectiveCamera camera; static class TitleGraph { - String url; + Object imageDescriptor; Separator sep = new Separator(); Transform xform = new Transform(); Texture2 texture = new Texture2(); Coordinate3 coords = new Coordinate3(); - TitleGraph(String url) { - this.url = url; + TitleGraph(Object imageDescriptor) { + this.imageDescriptor = imageDescriptor; } } @@ -94,7 +103,8 @@ public class DisplayShelfRenderer implements GLEventListener { private Separator root; private Separator imageRoot; - private String[] images; + private Fetcher<Integer> fetcher; + private ListModel model; private List<TitleGraph> titles = new ArrayList<TitleGraph>(); private GLRenderAction ra = new GLRenderAction(); private int targetIndex; @@ -132,14 +142,24 @@ public class DisplayShelfRenderer implements GLEventListener { private Texture2 clockTexture; private volatile boolean doneLoading; - public DisplayShelfRenderer(String[] images) { + class DownloadListener implements ProgressListener<Integer> { + public void progressStart(ProgressEvent<Integer> evt) {} + public void progressUpdate(ProgressEvent<Integer> evt) {} + public void progressEnd(ProgressEvent<Integer> evt) { + updateImage(evt.getClientIdentifier()); + } + } + + public DisplayShelfRenderer(ListModel model) { // Create a small pbuffer with which we share textures and display // lists to avoid having to reload textures during repeated calls // to init() sharedPbuffer = GLDrawableFactory.getFactory().createGLPbuffer(new GLCapabilities(), null, 1, 1, null); sharedPbuffer.display(); - this.images = images; + this.fetcher = new BasicFetcher<Integer>(); + fetcher.addProgressListener(new DownloadListener()); + this.model = model; root = new Separator(); time = new SystemTime(); time.rebase(); @@ -246,9 +266,9 @@ public class DisplayShelfRenderer implements GLEventListener { TriangleSet tris = new TriangleSet(); tris.setNumTriangles(2); - int i = 0; - for (String image : images) { - TitleGraph graph = new TitleGraph(image); + for (int i = 0; i < model.getSize(); i++) { + Object obj = model.getElementAt(i); + TitleGraph graph = new TitleGraph(obj); titles.add(graph); computeCoords(graph.coords, DEFAULT_ASPECT_RATIO); graph.xform.getTransform().setTranslation(new Vec3f(i, 0, 0)); @@ -282,6 +302,7 @@ public class DisplayShelfRenderer implements GLEventListener { // Now produce the floor geometry float maxSpacing = DEFAULT_HEIGHT * Math.max(STACKED_SPACING_FRAC, Math.max(SELECTED_SPACING_FRAC, EDITED_SPACING_FRAC)); + int i = model.getSize(); float minx = -i * maxSpacing; float maxx = 2 * i * maxSpacing; // Furthest back from the camera @@ -352,11 +373,15 @@ public class DisplayShelfRenderer implements GLEventListener { } }); - startLoading(); startClockAnimation(); recomputeTargetYZ(false); forceRecompute = true; recompute(); + + // Get the loading started + for (int j = 0; j < titles.size(); j++) { + updateImage(j); + } } } @@ -454,43 +479,6 @@ public class DisplayShelfRenderer implements GLEventListener { midy + (int) (bigHandSz * Math.sin(minAngle))); } - private void startLoading() { - final List<TitleGraph> queuedGraphs = new ArrayList<TitleGraph>(); - queuedGraphs.addAll(titles); - - Thread loaderThread = new Thread(new Runnable() { - public void run() { - try { - while (queuedGraphs.size() > 0) { - TitleGraph graph = queuedGraphs.remove(0); - BufferedImage img = null; - try { - img = ImageIO.read(new URL(graph.url)); - } catch (Exception e) { - System.out.println("Exception loading " + graph.url + ":"); - e.printStackTrace(); - } - if (img != null) { - graph.sep.replaceChild(clockTexture, graph.texture); - graph.texture.setTexture(img, false); - // Figure out the new aspect ratio based on the image's width and height - float aspectRatio = (float) img.getWidth() / (float) img.getHeight(); - // Compute new coordinates - computeCoords(graph.coords, aspectRatio); - // Schedule a repaint - drawable.repaint(); - } - } - } finally { - doneLoading = true; - } - } - }); - // Avoid having the loader thread preempt the rendering thread - loaderThread.setPriority(Thread.NORM_PRIORITY - 2); - loaderThread.start(); - } - private void startClockAnimation() { Thread clockAnimThread = new Thread(new Runnable() { public void run() { @@ -506,6 +494,38 @@ public class DisplayShelfRenderer implements GLEventListener { clockAnimThread.start(); } + private void updateImage(int id) { + TitleGraph graph = titles.get(id); + // Re-fetch + BufferedImage img = fetcher.getImage(graph.imageDescriptor, + Integer.valueOf(id), + -1); + if (img != null) { + // We don't need the image descriptor any more + graph.imageDescriptor = null; + graph.sep.replaceChild(clockTexture, graph.texture); + graph.texture.setTexture(img, false); + // Figure out the new aspect ratio based on the image's width and height + float aspectRatio = (float) img.getWidth() / (float) img.getHeight(); + // Compute new coordinates + computeCoords(graph.coords, aspectRatio); + // Schedule a repaint + drawable.repaint(); + } + + // See whether we're completely done loading + boolean done = true; + for (TitleGraph cur : titles) { + if (cur.imageDescriptor != null) { + done = false; + break; + } + } + if (done) { + doneLoading = true; + } + } + private void recomputeTargetYZ(boolean animate) { if (singleImageMode) { // Compute a target Y and Z depth based on the image we want to view diff --git a/src/net/java/joglutils/msg/test/Fetcher.java b/src/net/java/joglutils/msg/test/Fetcher.java new file mode 100644 index 0000000..d37967c --- /dev/null +++ b/src/net/java/joglutils/msg/test/Fetcher.java @@ -0,0 +1,77 @@ +/* + * Copyright 2007 Sun Microsystems, Inc., 4150 Network Circle, + * Santa Clara, California 95054, U.S.A. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Sun Microsystems nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.java.joglutils.msg.test; + +import java.awt.image.*; + +/** + * Defines how elements in the ListModel associated with the + * ImageBrowser are converted into images that can be rendered + * on-screen. <P> + * + * The IDENT type is the client's identifier for a particular image + * which is used in operations like progress callbacks. For example, + * this might be the index into the ListModel of the image we're + * talking about. <P> + * + * @author Jasper Potts + * @author Kenneth Russell + * @author Richard Bair + */ + +public interface Fetcher<IDENT> { + /** Requests the particular image associated with the given + element (of arbitrary type) from the ListModel of the + ImageBrowser. The <CODE>requestedImageSize</CODE> parameter + indicates the desired maximum dimension (width or height) of + the returned image. Passing a negative number for this + parameter results in always fetching the full-size image. + Fetchers that perform their work asynchronously will return + null if the image is not available immediately. In this case, + progress callbacks will be fired promptly to allow the caller + to display an indication of download progress. */ + public BufferedImage getImage(Object imageDescriptor, + IDENT clientIdentifier, + int requestedImageSize); + + /** Cancels a previously-registered download request from this + Fetcher -- one which resulted in null being returned from + getImage(). */ + public void cancelDownload(Object imageDescriptor, + IDENT clientIdentifier, + int requestedImageSize); + + /** Adds a progress listener to this Fetcher. */ + public void addProgressListener(ProgressListener listener); + + /** Removes a progress listener from this Fetcher. */ + public void removeProgressListener(ProgressListener listener); +} diff --git a/src/net/java/joglutils/msg/test/ProgressEvent.java b/src/net/java/joglutils/msg/test/ProgressEvent.java new file mode 100644 index 0000000..72110de --- /dev/null +++ b/src/net/java/joglutils/msg/test/ProgressEvent.java @@ -0,0 +1,78 @@ +/* + * Copyright 2007 Sun Microsystems, Inc., 4150 Network Circle, + * Santa Clara, California 95054, U.S.A. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Sun Microsystems nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.java.joglutils.msg.test; + +import java.util.EventObject; + +/** + * Represents a progress event during downloading or uploading of an + * image. + * + * @author Kenneth Russell + */ + +public class ProgressEvent<IDENT> extends EventObject { + private Object imageDescriptor; + private IDENT clientIdentifier; + private float fractionCompleted; + private boolean isDownload; + + public ProgressEvent(Fetcher<IDENT> source, + Object imageDescriptor, + IDENT clientIdentifier, + float fractionCompleted, + boolean isDownload) { + super(source); + this.imageDescriptor = imageDescriptor; + this.clientIdentifier = clientIdentifier; + this.fractionCompleted = fractionCompleted; + this.isDownload = isDownload; + } + + public Object getImageDescriptor() { + return imageDescriptor; + } + + public IDENT getClientIdentifier() { + return clientIdentifier; + } + + /** Returns a fraction between 0.0f and 1.0f, or a negative number + if we weren't able to make a determination of the estimated + image size. */ + public float getFractionCompleted() { + return fractionCompleted; + } + + public boolean isDownload() { + return isDownload; + } +} diff --git a/src/net/java/joglutils/msg/test/ProgressListener.java b/src/net/java/joglutils/msg/test/ProgressListener.java new file mode 100644 index 0000000..93e4db5 --- /dev/null +++ b/src/net/java/joglutils/msg/test/ProgressListener.java @@ -0,0 +1,54 @@ +/* + * Copyright 2007 Sun Microsystems, Inc., 4150 Network Circle, + * Santa Clara, California 95054, U.S.A. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Sun Microsystems nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package net.java.joglutils.msg.test; + +/** + * Provides notification of upload or download progress. The IDENT + * type is that used by the client to identify the particular element + * (image) being operated upon. + * + * @author Kenneth Russell + */ + +public interface ProgressListener<IDENT> { + /** Begins progress notification for a particular item which is + identified by the ProgressEvent. NOTE: this may be called + multiple times; clients must handle this case. */ + public void progressStart(ProgressEvent<IDENT> evt); + + /** Updates progress notification for a particular item which is + identified by the ProgressEvent. */ + public void progressUpdate(ProgressEvent<IDENT> evt); + + /** Ends progress notification for a particular item which is + identified by the ProgressEvent. */ + public void progressEnd(ProgressEvent<IDENT> evt); +} |