NASA World Wind

gov.nasa.worldwindx.examples.kml
Class KMLViewer.WorkerThread

java.lang.Object
  extended by java.lang.Thread
      extended by gov.nasa.worldwindx.examples.kml.KMLViewer.WorkerThread
All Implemented Interfaces:
Runnable
Enclosing class:
KMLViewer

public static class KMLViewer.WorkerThread
extends Thread

A Thread that loads a KML file and displays it in an AppFrame.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  KMLViewer.AppFrame appFrame
          Indicates the AppFrame the KML file content is displayed in.
protected  Object kmlSource
          Indicates the source of the KML file loaded by this thread.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
KMLViewer.WorkerThread(Object kmlSource, KMLViewer.AppFrame appFrame)
          Creates a new worker thread from a specified kmlSource and appFrame.
 
Method Summary
protected  KMLRoot parse()
          Parse the KML document.
 void run()
          Loads this worker thread's KML source into a new KMLRoot, then adds the new KMLRoot to this worker thread's AppFrame.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

appFrame

protected KMLViewer.AppFrame appFrame
Indicates the AppFrame the KML file content is displayed in. Initialized during construction.


kmlSource

protected Object kmlSource
Indicates the source of the KML file loaded by this thread. Initialized during construction.

Constructor Detail

KMLViewer.WorkerThread

public KMLViewer.WorkerThread(Object kmlSource,
                              KMLViewer.AppFrame appFrame)
Creates a new worker thread from a specified kmlSource and appFrame.

Parameters:
kmlSource - the source of the KML file to load. May be a File, a URL, or an InputStream, or a String identifying a file path or URL.
appFrame - the AppFrame in which to display the KML source.
Method Detail

parse

protected KMLRoot parse()
                 throws IOException,
                        XMLStreamException
Parse the KML document.

Returns:
The parsed document.
Throws:
IOException - if the document cannot be read.
XMLStreamException - if document cannot be parsed.

run

public void run()
Loads this worker thread's KML source into a new KMLRoot, then adds the new KMLRoot to this worker thread's AppFrame. The KMLRoot's AVKey.DISPLAY_NAME field contains a display name created from either the KML source or the KML root feature name.

If loading the KML source fails, this prints the exception and its stack trace to the standard error stream, but otherwise does nothing.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

NASA World Wind