org.apache.batik.util
Class DocumentLoadRunnable

java.lang.Object
  |
  +--org.apache.batik.util.DocumentLoadRunnable
All Implemented Interfaces:
DocumentEventSource, java.lang.Runnable

public class DocumentLoadRunnable
extends java.lang.Object
implements java.lang.Runnable, DocumentEventSource

This class implements a document loading thread "runnable", allowing background loading of documents, and asynchronous notification of DocumentEvents.


Field Summary
protected  SVGDocumentFactory df
          The SVG document factory to use when creating SVG Documents.
protected  java.lang.String documentURI
          The document URI.
protected  java.util.Vector listeners
          The DocumentEventListener list.
 
Constructor Summary
DocumentLoadRunnable(java.lang.String uri)
          Create a new DocumentLoadRunnable for a given URI.
 
Method Summary
 void addDocumentListener(DocumentListener l)
          Associate a DocumentEventListener with this loader.
static java.lang.Thread createLoaderThread(java.lang.String uri, DocumentListener l, SVGDocumentFactory df)
          Creates a new thread which runs a new DocumentLoader runnable.
 void fireAsyncDocumentEvent(DocumentEvent e, boolean wait)
          Fire a document event to all listeners.
 SVGDocumentFactory getDocumentFactory()
          Return the associated SVGDocumentFactory for this loader.
 void removeDocumentListener(DocumentListener l)
          Remove a DocumentEventListener from this loader's listener list.
 void run()
          The main Runnable method.
 void setDocumentFactory(SVGDocumentFactory df)
          Associate an SVGDocumentFactory with this loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

documentURI

protected java.lang.String documentURI
The document URI.

df

protected SVGDocumentFactory df
The SVG document factory to use when creating SVG Documents.

listeners

protected java.util.Vector listeners
The DocumentEventListener list. Note: we use Vector (which provide synchronized access) since outside threads may attempt to add listeners!
Constructor Detail

DocumentLoadRunnable

public DocumentLoadRunnable(java.lang.String uri)
Create a new DocumentLoadRunnable for a given URI.
Parameters:
uri - a String representing the document's URI.
Method Detail

createLoaderThread

public static java.lang.Thread createLoaderThread(java.lang.String uri,
                                                  DocumentListener l,
                                                  SVGDocumentFactory df)
Creates a new thread which runs a new DocumentLoader runnable.
Parameters:
uri - a String representing the document's URI.
df - the SVGDocumentFactory for creating the document
l - a DocumentListener which should listen to this loader's events.

addDocumentListener

public void addDocumentListener(DocumentListener l)
Associate a DocumentEventListener with this loader.
Specified by:
addDocumentListener in interface DocumentEventSource

removeDocumentListener

public void removeDocumentListener(DocumentListener l)
Remove a DocumentEventListener from this loader's listener list.
Specified by:
removeDocumentListener in interface DocumentEventSource

setDocumentFactory

public void setDocumentFactory(SVGDocumentFactory df)
Associate an SVGDocumentFactory with this loader.

getDocumentFactory

public SVGDocumentFactory getDocumentFactory()
Return the associated SVGDocumentFactory for this loader.

fireAsyncDocumentEvent

public void fireAsyncDocumentEvent(DocumentEvent e,
                                   boolean wait)
Fire a document event to all listeners. Note that since java events are processed in the firing thread, not in the AWT event thread, we must wrap the event notification in an "invokeLater" or "invokeAndWait" call. If the delivering thread is already the AWT Event thread the event is delivered directly.
Specified by:
fireAsyncDocumentEvent in interface DocumentEventSource
Parameters:
e - the DocumentEvent to be asynchronously delivered.
wait - a boolean indicating whether we should wait for delivery

run

public void run()
The main Runnable method.
Specified by:
run in interface java.lang.Runnable


Copyright © 2000 Apache Software Foundation. All Rights Reserved.