org.virbo.autoplot
Class ScriptContext

java.lang.Object
  extended by org.python.core.PyObject
      extended by org.python.core.PyInstance
          extended by org.python.core.PyJavaInstance
              extended by org.virbo.autoplot.ScriptContext
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class ScriptContext
extends org.python.core.PyJavaInstance

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.python.core.PyObject
org.python.core.PyObject.ConversionException
 
Field Summary
 
Fields inherited from class org.python.core.PyInstance
__dict__, instclass
 
Fields inherited from class org.python.core.PyObject
exposed_name
 
Constructor Summary
ScriptContext()
           
 
Method Summary
static void _setOutputStream(java.io.OutputStream out)
          resets the output stream.
static void bind(java.lang.Object src, java.lang.String srcProp, java.lang.Object dst, java.lang.String dstProp)
          binds two bean properties together.
static void createGui()
          create a model with a GUI presentation layer.
static void dumpToDas2Stream(org.virbo.dataset.QDataSet ds, boolean ascii)
          serializes the dataset to a das2stream, a well-documented, open, streaming data format.
static void dumpToDas2Stream(org.virbo.dataset.QDataSet ds, java.lang.String file, boolean ascii)
          serializes the dataset to a das2stream, a well-documented, open, streaming data format.
static ApplicationModel getApplicationModel()
          returns the internal application model (the object that does all the business).
static org.virbo.dataset.QDataSet getDataSet(java.lang.String surl)
          load the data specified by URL into Autoplot's internal data model.
static org.virbo.dataset.QDataSet getDataSet(java.lang.String surl, org.das2.util.monitor.ProgressMonitor mon)
          load the data specified by URL into Autoplot's internal data model.
static java.lang.String[] getTimeRangesFor(java.lang.String surl, java.lang.String timeRange, java.lang.String format)
          return an array of URLs that match the spec for the time range provided.
static java.lang.String[] list(java.lang.String surl)
          returns a list of the files in the local or remote filesystem pointed to by surl.
static void peekAt(java.lang.Object o)
           
static void plot(java.lang.String surl)
          bring up the autoplot with the specified URL.
protected static void setApplicationModel(ApplicationModel m)
           
static void setCanvasSize(int width, int height)
          set the size of the canvas.
static void setDataSourceURL(java.lang.String surl)
          set the internal model's url to surl.
static void setTitle(java.lang.String title)
          set the title of the plot.
protected static void setView(AutoPlotUI v)
           
static void writeToPdf(java.lang.String filename)
          write out the current canvas to a pdf file.
static void writeToPng(java.io.OutputStream out)
          write out the current canvas to stdout.
static void writeToPng(java.lang.String filename)
          write out the current canvas to a png file.
 
Methods inherited from class org.python.core.PyJavaInstance
__cmp__, __delattr__, __init__, __repr__, __str__, _is, _isnot, hashCode, noField, readExternal, unassignableField, writeExternal
 
Methods inherited from class org.python.core.PyInstance
__abs__, __add__, __and__, __call__, __coerce_ex__, __complex__, __contains__, __delitem__, __div__, __divmod__, __eq__, __findattr__, __findattr__, __finditem__, __finditem__, __float__, __floordiv__, __ge__, __getitem__, __gt__, __hex__, __iadd__, __iand__, __idiv__, __ifloordiv__, __ilshift__, __imod__, __imul__, __int__, __invert__, __ior__, __ipow__, __irshift__, __isub__, __iter__, __iternext__, __itruediv__, __ixor__, __jfindattr__, __le__, __len__, __long__, __lshift__, __lt__, __mod__, __mul__, __ne__, __neg__, __nonzero__, __oct__, __or__, __pos__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __rfloordiv__, __rlshift__, __rmod__, __rmul__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __setattr__, __setitem__, __sub__, __tojava__, __truediv__, __unicode__, __xor__, fastGetClass, ifindclass, ifindfunction, ifindlocal, invoke_ex, invoke_ex, invoke_ex, invoke_ex, invoke, invoke, invoke, makeProxy
 
Methods inherited from class org.python.core.PyObject
__call__, __call__, __call__, __call__, __call__, __call__, __call__, __coerce__, __delattr__, __delete__, __delitem__, __delslice__, __delslice__, __dir__, __findattr__, __finditem__, __get__, __getattr__, __getattr__, __getitem__, __getnewargs__, __getslice__, __getslice__, __hash__, __idivmod__, __not__, __pow__, __rawdir__, __reduce__, __set__, __setattr__, __setitem__, __setitem__, __setslice__, __setslice__, _add, _and, _callextra, _cmp, _div, _divmod, _doget, _doget, _doset, _eq, _floordiv, _ge, _gt, _in, _jcall, _jcallexc, _jthrow, _le, _lshift, _lt, _mod, _mul, _ne, _notin, _or, _pow, _rshift, _sub, _truediv, _unsupportedop, _xor, addKeys, asInt, asLong, asName, asString, asStringOrNull, delDict, delType, dispatch__init__, equals, fastGetDict, getDict, getDoc, getType, impAttr, implementsDescrDelete, implementsDescrSet, invoke, invoke, isCallable, isDataDescr, isMappingType, isNumberType, isSequenceType, noAttributeError, readonlyAttributeError, runsupportedopMessage, safeRepr, setDict, setType, toString, typeSetup, unsupportedopMessage
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScriptContext

public ScriptContext()
Method Detail

setApplicationModel

protected static void setApplicationModel(ApplicationModel m)

setView

protected static void setView(AutoPlotUI v)

_setOutputStream

public static void _setOutputStream(java.io.OutputStream out)
resets the output stream. This method is used internally, do not use this routine.

Parameters:
out -

setCanvasSize

public static void setCanvasSize(int width,
                                 int height)
set the size of the canvas. This is only used when the GUI is not used, and in headless mode, otherwise the GUI controls the size of the canvas.

Parameters:
width -
height -

setDataSourceURL

public static void setDataSourceURL(java.lang.String surl)
                             throws java.lang.InterruptedException
set the internal model's url to surl. The data set will be loaded, and writeToPng and writeToSvg can be used in headless mode.

Parameters:
surl -
Throws:
java.lang.InterruptedException

plot

public static void plot(java.lang.String surl)
                 throws java.lang.InterruptedException
bring up the autoplot with the specified URL.

Parameters:
surl -
Throws:
java.lang.InterruptedException

writeToPng

public static void writeToPng(java.lang.String filename)
                       throws java.lang.InterruptedException,
                              java.io.IOException
write out the current canvas to a png file.

Parameters:
filename -
Throws:
java.lang.InterruptedException
java.io.IOException

peekAt

public static void peekAt(java.lang.Object o)
                   throws java.io.IOException
Throws:
java.io.IOException

writeToPng

public static void writeToPng(java.io.OutputStream out)
                       throws java.lang.InterruptedException,
                              java.io.IOException
write out the current canvas to stdout. This is introduced to support servers.

Parameters:
OutputStream - out
Throws:
java.lang.InterruptedException
java.io.IOException

writeToPdf

public static void writeToPdf(java.lang.String filename)
                       throws java.lang.InterruptedException,
                              java.io.IOException
write out the current canvas to a pdf file.

Parameters:
filename -
Throws:
java.lang.InterruptedException
java.io.IOException

getTimeRangesFor

public static java.lang.String[] getTimeRangesFor(java.lang.String surl,
                                                  java.lang.String timeRange,
                                                  java.lang.String format)
                                           throws java.io.IOException,
                                                  java.text.ParseException
return an array of URLs that match the spec for the time range provided.

Parameters:
surl - an autoplot url with an aggregation specifier.
timeRange - a string that is parsed to a time range, such as "2001"
format - format for the result, such as "%Y-%m-%d"
Returns:
a list of URLs without the aggregation specifier.
Throws:
java.io.IOException - if the remote folder cannot be listed.
java.text.ParseException - if the timerange cannot be parsed.

setTitle

public static void setTitle(java.lang.String title)
set the title of the plot.

Parameters:
title -

createGui

public static void createGui()
create a model with a GUI presentation layer. If the GUI is already created, then this does nothing.


getApplicationModel

public static ApplicationModel getApplicationModel()
returns the internal application model (the object that does all the business). This provides access to the internal model for power users.

Returns:
ApplicationModel object

bind

public static void bind(java.lang.Object src,
                        java.lang.String srcProp,
                        java.lang.Object dst,
                        java.lang.String dstProp)
binds two bean properties together. Bindings are bidirectional, but the initial copy is from src to dst. In MVC terms, src should be the model and dst should be a view. The properties must fire property change events for the binding mechanism to work. Example: model= getApplicationModel() bind( model.getPlot(), "title", model.getPlot().getXAxis(), "label" )

Parameters:
src - java bean such as model.getPlot()
srcProp - a property name such as "title"
dst - java bean such as model.getPlot().getXAxis()
dstProp - a property name such as "label"

getDataSet

public static org.virbo.dataset.QDataSet getDataSet(java.lang.String surl,
                                                    org.das2.util.monitor.ProgressMonitor mon)
                                             throws java.lang.Exception
load the data specified by URL into Autoplot's internal data model. This will block until the load is complete, and a ProgressMonitor object can be used to monitor the load. TODO: combine this with dumpToDas2Stream, so that the stream can contain progress information for the consumer.

Parameters:
ds -
Throws:
java.lang.Exception

getDataSet

public static org.virbo.dataset.QDataSet getDataSet(java.lang.String surl)
                                             throws java.lang.Exception
load the data specified by URL into Autoplot's internal data model. This will block until the load is complete.

Parameters:
ds -
Throws:
java.lang.Exception

dumpToDas2Stream

public static void dumpToDas2Stream(org.virbo.dataset.QDataSet ds,
                                    boolean ascii)
serializes the dataset to a das2stream, a well-documented, open, streaming data format. (that's a joke.) Currently, to keep the channel open, the stream is created in a buffer and then the buffer is sent. TODO: write a stream-producing code that doesn't close the output stream.

Parameters:
ds -

dumpToDas2Stream

public static void dumpToDas2Stream(org.virbo.dataset.QDataSet ds,
                                    java.lang.String file,
                                    boolean ascii)
                             throws java.io.IOException
serializes the dataset to a das2stream, a well-documented, open, streaming data format. (that's a joke.) Currently, to keep the channel open, the stream is created in a buffer and then the buffer is sent. TODO: write a stream-producing code that doesn't close the output stream.

Parameters:
ds -
Throws:
java.io.IOException

list

public static java.lang.String[] list(java.lang.String surl)
                               throws java.net.MalformedURLException,
                                      java.io.IOException
returns a list of the files in the local or remote filesystem pointed to by surl. print list( 'http://www.papco.org/data/de/eics/*' ) --> '81355_eics_de_96s_v01.cdf', '81356_eics_de_96s_v01.cdf', '81357_eics_de_96s_v01.cdf', ...

Parameters:
surl -
Returns:
Throws:
java.net.MalformedURLException
java.io.IOException