org.eclipse.ohf.stem.ui.ge.kml
Class StemKml

java.lang.Object
  extended by org.eclipse.ohf.stem.ui.ge.kml.StemKml

public class StemKml
extends java.lang.Object

StemKML works with GEInterface to handle tne KML side of the interface between STEM and GoogleEarth. Refer to GEInterface for more information.

  *   
  
  - PolygonMap  Map 
       Map of info to generate a set of Polygons
       The key is the area 
       
  - aspect   SEIR value
  - cycle    Nth time interval
  
 
 During operation, when appropriate The "controlxxxx.kml" file 
 will be rewriten with new instructions.
 StemView will call generatePolygons() to generate a control file
 that will display all of the county/areas of the map with the 
 appropriate color fill to match the corresponding Stem map.
 
 When the user selects a specific county/area on the map,
 then StemView will call the generatePolygon method.


Field Summary
static java.lang.String CONTEXT
          Servlet context.
 
Constructor Summary
StemKml()
          Constructor
 
Method Summary
 void generatePolygons(java.lang.String controlFileName, java.util.Map<java.lang.String,GEData> geData, Aspect aspect, long cycle)
          Create the KML control file to display all of the polygon (county) areas Call the implementation of IKmlDisplay to create and write the kml file.
static java.lang.String getControlFile()
          Generate the name used for KML Control.
static java.lang.String getControlFN(java.lang.String folder, java.lang.String template, Aspect aspect, long cycle)
          Set the filename based on the Template and the current aspect and cycle number.
static java.lang.String getDisplayAreaFile()
          Generate the name used for KML when using the DisplayArea utility function
static java.lang.String getHex(int v)
          get the Hex value corresponding to an int value.
static java.lang.String getServerUrl()
          obtain the URL used to access the GE Servlets.
 void init()
          initialization currently we have nothing to do
static java.lang.String initWebServer()
          Startup and verify a web server to run the GEServlet servlets.
static boolean isWaitForKML()
           
static void launch(java.lang.String controlFileName)
          Launch the KML file to GoogleEarth
static void launchGE()
          Create a GoogleEarth empty control files and launch it so that googleEarth starts up.
static java.lang.String launchNetworkLink(java.lang.String folder, java.lang.String file)
          create and launch a network link file that will read the kml files that we will be generating.
static void setWaitForKML(boolean waitForKML)
          Set true if option should be passed to servlet
static java.lang.String startWebServer()
          Startup an internal web server to run the GEServlet servlets.
static boolean verifyGE()
          Verify that GoogleEarth is installed by checking that the KML filetype is known.
static void writeNetLink(java.lang.String fn, int interval, java.lang.String url)
          Write the network Link file that will tell GoogleEarth how to make callbacks to the servlet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT

public static final java.lang.String CONTEXT
Servlet context.

See Also:
Constant Field Values
Constructor Detail

StemKml

public StemKml()
Constructor

Method Detail

init

public void init()
initialization currently we have nothing to do


verifyGE

public static boolean verifyGE()
Verify that GoogleEarth is installed by checking that the KML filetype is known.

Returns:
true if the KML file type is known.

launchGE

public static void launchGE()
                     throws org.w3c.dom.DOMException
Create a GoogleEarth empty control files and launch it so that googleEarth starts up.

Throws:
org.w3c.dom.DOMException

getControlFile

public static java.lang.String getControlFile()
Generate the name used for KML Control.

Returns:
Fully qualified filename (e.g. c:/tmp/control.kml)

getDisplayAreaFile

public static java.lang.String getDisplayAreaFile()
Generate the name used for KML when using the DisplayArea utility function

Returns:
Fully qualified filename (e.g. c:/tmp/control.kml)

launchNetworkLink

public static java.lang.String launchNetworkLink(java.lang.String folder,
                                                 java.lang.String file)
create and launch a network link file that will read the kml files that we will be generating.

Parameters:
folder - Folder that contains KML files
file - If not null then pass this name to the servlet.
Returns:
URL used

writeNetLink

public static void writeNetLink(java.lang.String fn,
                                int interval,
                                java.lang.String url)
                         throws org.w3c.dom.DOMException
Write the network Link file that will tell GoogleEarth how to make callbacks to the servlet.

Parameters:
fn - folder + fn to write
interval - How often to call back (seconds)
url - Where to call back + parms
Throws:
org.w3c.dom.DOMException

generatePolygons

public void generatePolygons(java.lang.String controlFileName,
                             java.util.Map<java.lang.String,GEData> geData,
                             Aspect aspect,
                             long cycle)
Create the KML control file to display all of the polygon (county) areas Call the implementation of IKmlDisplay to create and write the kml file.

Parameters:
controlFileName - File where KML will be written
geData - Map of GEData objects
aspect - which type of map (population,susceptiple...
cycle - current number of cycle being displayed

getHex

public static java.lang.String getHex(int v)
get the Hex value corresponding to an int value. This has leading zeros.

Parameters:
v - value to translate.
Returns:
Hex String

launch

public static void launch(java.lang.String controlFileName)
Launch the KML file to GoogleEarth

Parameters:
controlFileName - absolute file path or a url

initWebServer

public static java.lang.String initWebServer()
Startup and verify a web server to run the GEServlet servlets. If specified it will try to start the embedded web server If not or it that fialied then it will check if an external server was specified and try to access it.

Returns:
url for host and port example: http://127.0.0.1:54345/ It will return null if unable to start server or if server does not support our servlets

startWebServer

public static java.lang.String startWebServer()
Startup an internal web server to run the GEServlet servlets.

Returns:
url for host and port example: http://127.0.0.1:54345/ It will return null if unable to start server

getServerUrl

public static java.lang.String getServerUrl()
obtain the URL used to access the GE Servlets.

Returns:
The URL as a string, null if unable to access a valid web server.

getControlFN

public static java.lang.String getControlFN(java.lang.String folder,
                                            java.lang.String template,
                                            Aspect aspect,
                                            long cycle)
Set the filename based on the Template and the current aspect and cycle number.

Parameters:
folder - Folder where kml files are written
template -
aspect - aspect to be displayed
cycle -
Returns:
resulting absolute filename

isWaitForKML

public static boolean isWaitForKML()
Returns:
true if option should be passed to servlet

setWaitForKML

public static void setWaitForKML(boolean waitForKML)
Set true if option should be passed to servlet

Parameters:
waitForKML -