ice.storm
Class Pilot

java.lang.Object
  extended byice.storm.Pilot
Direct Known Subclasses:
LPilot, ThePilot

public abstract class Pilot
extends Object

Pilot (rendering module). An implementation of a Pilot depends only on main Storm classes and on the low-level library used. For example for an OpenGL based ASC pilot, the pilot class will depend on Storm classes and Magician library.

Pilot lifetime:

        Pilot (pilot) is loaded
        pilot.init(gfxToolkit);
        Component c = pilot.createComponent();
        if (c==null)
                pilot is lightweight and can be painted anywhere
        else
                container.add(c);

        pilot.clear();
        pilot.parse();
        ....
        pilot.dispose();

Author:
Alexey Goloshubin, ICEsoft

Constructor Summary
Pilot()
           
 
Method Summary
 void applySnapshot(Object snap)
           
 void beforeUnload()
           
 void clear(String contentType)
          Clear the displayed content
 Component createComponent()
          Ask the pilot to create its GUI.
 StormPrinter createPrinter()
          Ask the pilot to create a StormPrinter instance that can be used to print the pilot's content
 void dispose()
          When the pilot is no longer needed, the system calls this method to allow the pilot to get rid of all resources it has been using.
 Object execDynamicMethodOnWindow(DynamicObject window, String name, Object[] args, DynEnv env)
           
 Viewport findOrCreateViewport(String viewportName)
          Utility method which will either create a new viewport or it will return an existing viewport which has the same viewport name.
 Viewport findOrCreateViewport(String viewportName, String location)
          Utility method which will either create a new viewport with knowledge of the content URI or it will return an existing viewport which has the same viewport name.
 void firePropertyChange(String propName, Object oldValue, Object newValue)
          Fire a property change event.
 void getAllPilotInstances(Vector result)
          Append to result all pilots that are instances of the same type as this pilot.
 DocPane getDocPane()
           
 DynamicObject getDocumentObject()
          Get pilot notion of a document object for scripters
 Object getDynamicValueOnWindow(DynamicObject window, String name, DynEnv env)
           
 Viewport getPilotViewport()
          Get hold of an viewport for this pilot from Storm.
 Object getSnapshot()
           
 StormBase getStorm()
          Get StormBase that manages the pilot.
 UrlMaster getUrlMaster()
          Deprecated. As of 6.1, no instance of UrlMaster is needed for the contained utility methods. Please use URLResolver.
 Container getViewportContainer()
          Get the nearest graphical container that this pilot viewport lives in.
 String getViewportId()
          Get the id of the viewport in which this pilot lives
 Object getViewportProperty(String name)
          Get a configuation property set for the viewport in which this pilot lives
 void gotoRef(String ref)
          If the Storm is asked to go to a URL with a Ref and the pilot is already displaing the URL, this method will be called to tell the pilot to go to a Ref in the document.
 void init(String componentToolkitName)
          Initialize a pilot.
 boolean isDetached()
          If this method returns true, then the pilot is considered to be detached and it will not participate in normal Storm/viewport activity.
 boolean isStopRequested()
          Check if stop loading has been requested on the pilot viewport
 void modifiedByScript()
          Deprecated. Pilot is notified by Storm via this callback that somebody may have modified some information in the pilot. For example, a scripter may have updated the styles from another thread and pilot should make sure to validate its view.
 void onLoadingDone()
           
 void onLowMemory()
          Tells the pilot to free resources while still be somewhat useful
 void parse(ContentLoader cl)
          Parse the data from the ContentLoader
 void parsingDone()
           
 boolean refExists(String ref)
           
 void refresh()
          This one can be called when e.g a lightweight pilot change it size, or something else out side the pilot context that require the pilot to redraw itself.
 void refreshViewport()
          Pilot can use this method to notify storm that something inside the pilot has been changed and its viewport should be refreshed It is the only way a lightweight pilot (LPilot) can repaint itself.
 void renderContent(String loc, String contentType, String viewportName)
          Display content from a specified location in the specified viewport.
 void resume()
          Tells the pilot to wake up from the "suspend" mode.
 int setDynamicValueOnWindow(DynamicObject window, String name, Object value, DynEnv env)
           
protected  void setZoom(int zoom)
          Set zooming value.
 void stopLoading()
          Tells the pilot to stop loading
 void suspend()
          Tells the pilot to go into "suspend" mode and use as little resources as possible.
 void updateFrameList()
          Make sure that storm has proper list of child vieports representing all frame objects that should be visible to scripts.
 void viewportBecameActive()
          Using this method pilot can tell Storm that the pilot/viewport has become currently active
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pilot

public Pilot()
Method Detail

getStorm

public StormBase getStorm()
Get StormBase that manages the pilot.


init

public void init(String componentToolkitName)
Initialize a pilot. After the pilot class is loaded this method, is the first one to get called. It provides the pilot with the context information as well as the name of the viewoprt it is in.

Parameters:
componentToolkitName - pilot context

dispose

public void dispose()
When the pilot is no longer needed, the system calls this method to allow the pilot to get rid of all resources it has been using. After a call to this method th epilot will no longer be used.


setZoom

protected void setZoom(int zoom)
Set zooming value. 256 means 100%, 128 means 50% etc


isDetached

public boolean isDetached()
If this method returns true, then the pilot is considered to be detached and it will not participate in normal Storm/viewport activity. Instead the Storm will only call: init(), clear(), parse() methods and no reference to the pilot will be kept. The default return value is false.


clear

public void clear(String contentType)
Clear the displayed content


parse

public void parse(ContentLoader cl)
           throws IOException
Parse the data from the ContentLoader

Throws:
IOException

gotoRef

public void gotoRef(String ref)
If the Storm is asked to go to a URL with a Ref and the pilot is already displaing the URL, this method will be called to tell the pilot to go to a Ref in the document.


refExists

public boolean refExists(String ref)

stopLoading

public void stopLoading()
Tells the pilot to stop loading


modifiedByScript

public void modifiedByScript()
Deprecated. Pilot is notified by Storm via this callback that somebody may have modified some information in the pilot. For example, a scripter may have updated the styles from another thread and pilot should make sure to validate its view.


suspend

public void suspend()
Tells the pilot to go into "suspend" mode and use as little resources as possible.


resume

public void resume()
Tells the pilot to wake up from the "suspend" mode.


onLowMemory

public void onLowMemory()
Tells the pilot to free resources while still be somewhat useful


createComponent

public Component createComponent()
Ask the pilot to create its GUI. Note that some lightweight pilots may return null


createPrinter

public StormPrinter createPrinter()
Ask the pilot to create a StormPrinter instance that can be used to print the pilot's content


getDynamicValueOnWindow

public Object getDynamicValueOnWindow(DynamicObject window,
                                      String name,
                                      DynEnv env)

setDynamicValueOnWindow

public int setDynamicValueOnWindow(DynamicObject window,
                                   String name,
                                   Object value,
                                   DynEnv env)

execDynamicMethodOnWindow

public Object execDynamicMethodOnWindow(DynamicObject window,
                                        String name,
                                        Object[] args,
                                        DynEnv env)

getDocumentObject

public DynamicObject getDocumentObject()
Get pilot notion of a document object for scripters


updateFrameList

public void updateFrameList()
Make sure that storm has proper list of child vieports representing all frame objects that should be visible to scripts.


getSnapshot

public Object getSnapshot()

applySnapshot

public void applySnapshot(Object snap)

parsingDone

public void parsingDone()

onLoadingDone

public void onLoadingDone()

beforeUnload

public void beforeUnload()

refresh

public void refresh()
This one can be called when e.g a lightweight pilot change it size, or something else out side the pilot context that require the pilot to redraw itself.


getViewportId

public final String getViewportId()
Get the id of the viewport in which this pilot lives


getPilotViewport

public final Viewport getPilotViewport()
Get hold of an viewport for this pilot from Storm.


getDocPane

public DocPane getDocPane()

getAllPilotInstances

public final void getAllPilotInstances(Vector result)
Append to result all pilots that are instances of the same type as this pilot.


getViewportProperty

public final Object getViewportProperty(String name)
Get a configuation property set for the viewport in which this pilot lives

Parameters:
name - property name
Returns:
property value

firePropertyChange

public final void firePropertyChange(String propName,
                                     Object oldValue,
                                     Object newValue)
Fire a property change event. This method will send out a property event attached to the viewport this Pilot is associated with

Parameters:
propName - the property name
oldValue - the old value of the property
newValue - the new value of the property

renderContent

public final void renderContent(String loc,
                                String contentType,
                                String viewportName)
Display content from a specified location in the specified viewport.

Parameters:
loc - location of the content
contentType - content type of the data. If this parameter is non-null its value overrides any contentType data received during loading.
viewportName - the name of the viewport to render the content into

findOrCreateViewport

public final Viewport findOrCreateViewport(String viewportName)
Utility method which will either create a new viewport or it will return an existing viewport which has the same viewport name.

Parameters:
viewportName - the name of the viewport which is used for the creation of a new viewport if the the viewport name can not be found in the current list of viewports
Returns:
return a new viewport with the specified name

findOrCreateViewport

public final Viewport findOrCreateViewport(String viewportName,
                                           String location)
Utility method which will either create a new viewport with knowledge of the content URI or it will return an existing viewport which has the same viewport name.

Parameters:
viewportName - the name of the viewport which is used for the creation of a new viewport if the the viewport name can not be found in the current list of viewports
location - if a new viewport is created the locaiton URI is set to the new viewport
Returns:
return a new viewport with the specified name
Since:
6.1

isStopRequested

public final boolean isStopRequested()
Check if stop loading has been requested on the pilot viewport


refreshViewport

public final void refreshViewport()
Pilot can use this method to notify storm that something inside the pilot has been changed and its viewport should be refreshed It is the only way a lightweight pilot (LPilot) can repaint itself.


viewportBecameActive

public final void viewportBecameActive()
Using this method pilot can tell Storm that the pilot/viewport has become currently active


getViewportContainer

public final Container getViewportContainer()
Get the nearest graphical container that this pilot viewport lives in.

Returns:
graphical container

getUrlMaster

public final UrlMaster getUrlMaster()
Deprecated. As of 6.1, no instance of UrlMaster is needed for the contained utility methods. Please use URLResolver.