Class JythonControl

All Implemented Interfaces:
ActionListener, ItemListener, PropertyChangeListener, EventListener, HyperlinkListener, Sharable, DataChangeListener, DisplayControl, Prototypable, ControlListener, DisplayListener

public class JythonControl extends GridDisplayControl
Allows for the creation of a display by an end user through the use of Jython
Version:
$Revision: 1.39 $
Author:
Jeff McWhirter/Don Murray
  • Field Details

  • Constructor Details

    • JythonControl

      public JythonControl()
      Ctor
  • Method Details

    • init

      public boolean init(DataChoice dataChoice) throws VisADException, RemoteException
      Called to make this kind of Display Control; also calls code to made the Displayable. This method is called from inside DisplayControlImpl init(several args).
      Overrides:
      init in class DisplayControlImpl
      Parameters:
      dataChoice - the DataChoice of the moment.
      Returns:
      true if successful
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Error
    • initDone

      public void initDone()
      init done. call some jython
      Overrides:
      initDone in class DisplayControlImpl
    • shouldAddAnimationListener

      protected boolean shouldAddAnimationListener()
      A hook to allow derived classes to tell us to add this as an animation listener
      Overrides:
      shouldAddAnimationListener in class DisplayControlImpl
      Returns:
      Add as animation listener
    • timeChanged

      protected void timeChanged(Real time)
      Respond to a timeChange event
      Overrides:
      timeChanged in class DisplayControlImpl
      Parameters:
      time - new time
    • getVar

      public Object getVar(Object varName)
      Get a variable.
      Parameters:
      varName - variable name
      Returns:
      variable corresponding to the name
    • setVar

      public void setVar(Object varName, Object value)
      Set a variable.
      Parameters:
      varName - variable name
      value - variable value
    • fixRange

      public void fixRange()
    • writeToPlugin

      public void writeToPlugin()
      Generate the control's XML
    • resetData

      protected void resetData() throws VisADException, RemoteException
      We have new data. Reload
      Overrides:
      resetData in class DisplayControlImpl
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getDataList

      public List getDataList() throws RemoteException, VisADException
      Get the list of DataChoices
      Returns:
      list of DataChoices
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Error
    • execJython

      public void execJython(String method)
      Execute the jython method
      Parameters:
      method - jython method to call
    • sample

      public Data sample() throws RemoteException, VisADException
      Sample the first data at the probe position
      Returns:
      sampled data
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleAtTime

      public Data sampleAtTime() throws RemoteException, VisADException
      Sample the first data at the probe position and at the current animation time
      Returns:
      sampled data
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleIndex

      public Data sampleIndex(int index, boolean atTime) throws RemoteException, VisADException
      Sample the data at the index at the probe position
      Parameters:
      index - Index in the data list
      atTime - If true then also sample at the current animation time
      Returns:
      sampled data
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleAll

      public List sampleAll() throws RemoteException, VisADException
      Sample all the data at the probe point
      Returns:
      Sampled data
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleAllAtTime

      public List sampleAllAtTime() throws RemoteException, VisADException
      Sample all the data at the probe point at the current animation time
      Returns:
      sampled data
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleDataAtProbe

      public Data sampleDataAtProbe(FieldImpl field) throws RemoteException, VisADException
      Sample the field at the probe location
      Parameters:
      field - field to sample
      Returns:
      sampled data
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleData

      public Data sampleData(EarthLocationTuple[] loc, FieldImpl field) throws RemoteException, VisADException
      Sample at location
      Parameters:
      loc - location
      field - field to sample
      Returns:
      sampled data
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getAnimationTime

      public Real getAnimationTime() throws RemoteException, VisADException
      Get current animation time or null of none
      Returns:
      animation time
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getAnimationTimes

      public List getAnimationTimes() throws RemoteException, VisADException
      Get all animation times or null if none
      Returns:
      animation time
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getTimesFromData

      public List getTimesFromData() throws RemoteException, VisADException
      Get times from data
      Returns:
      animation time
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleData

      public Data sampleData(EarthLocationTuple[] loc, FieldImpl field, boolean atTime) throws RemoteException, VisADException
      Sample the field at the location and maybe at the animation time
      Parameters:
      loc - location
      field - field
      atTime - if true then also sample at anim time
      Returns:
      sampled data
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • getChangeParameterLabel

      protected String getChangeParameterLabel()
      Return the appropriate label text for the menu.
      Overrides:
      getChangeParameterLabel in class DisplayControlImpl
      Returns:
      the label text
    • addNewData

      protected void addNewData(List newChoices) throws VisADException, RemoteException
      Gets called whne user has chosen new data
      Overrides:
      addNewData in class DisplayControlImpl
      Parameters:
      newChoices - new data choices
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • selectData

      public void selectData(String message)
      Hook to allow jython to call to bring up data choice selector
      Parameters:
      message - message to use in dialog
    • addData

      public void addData(String message)
      Hook to allow jython to call to bring up data choice selector
      Parameters:
      message - message to use in dialog
    • addData

      public void addData(String message, String callback)
      Hook to allow jython to call to bring up data choice selector
      Parameters:
      message - message to use in dialog
      callback - The jython procedure to callback
    • replaceData

      public void replaceData(String message)
      Hook to allow jython to call to bring up data choice selector
      Parameters:
      message - message to use in dialog
    • replaceData

      public void replaceData(String message, String callback)
      Hook to allow jython to call to bring up data choice selector
      Parameters:
      message - message to use in dialog
      callback - The jython procedure to callback
    • selectData

      public void selectData(String message, String callback, boolean replace, boolean multiples, List categories)
      Hook to allow jython to call to bring up data choice selector
      Parameters:
      message - message to use in dialog
      callback - The jython procedure to callback
      replace - If true then we remove the current list of data choices and replace it with the selected ones.
      multiples - Select multiples
      categories - Possibly null list of data categories to use
    • doRemove

      public void doRemove() throws RemoteException, VisADException
      Remove this control.
      Specified by:
      doRemove in interface DisplayControl
      Overrides:
      doRemove in class DisplayControlImpl
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Error
    • getCurrentProbe

      public Displayable getCurrentProbe()
      Get the probe being used.
      Returns:
      current probe.
    • getProbePosition

      public Object getProbePosition() throws VisADException, RemoteException
      Get the probe's position
      Returns:
      position of the probe
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Error
    • setProbePosition

      public void setProbePosition(Object p)
      Set the probe position property.
      Parameters:
      p - position for probe.
    • getProbeXYZ

      public double[][] getProbeXYZ() throws VisADException, RemoteException
      Return the current probe position in X/Y space.
      Returns:
      a 2-D array of the form data[N][0] = X, data[N][1] = Y, data[N][2] = Z
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Error
    • getProbeLocation

      public EarthLocationTuple[] getProbeLocation() throws VisADException, RemoteException
      Return an array that holds the location of the current probe. For point, level and vertical probes the length is 1 For the horizonal probe the length 2 (the end points of the probe line) For the area probe the length is 4 (upper-left, upper-right, lower-right, lower-left)
      Returns:
      An array holding the probe location
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Error
    • receiveShareData

      public void receiveShareData(Sharable from, Object dataId, Object[] data)
      Method called by other classes that share the probe.
      Specified by:
      receiveShareData in interface Sharable
      Overrides:
      receiveShareData in class DisplayControlImpl
      Parameters:
      from - other class.
      dataId - type of sharing
      data - Array of data being shared. In this case, the first (and only?) object in the array is the level
    • doMakeContents

      public Container doMakeContents()
      Make some Plan view controls for the UI.
      Overrides:
      doMakeContents in class DisplayControlImpl
      Returns:
      create the contents for the UI.
    • getExtraLegendComponent

      protected JComponent getExtraLegendComponent(int legendType)
      Return the extra legend component
      Overrides:
      getExtraLegendComponent in class DisplayControlImpl
      Parameters:
      legendType - side or bottom
      Returns:
      component to put in legend
    • addJythonComponent

      public void addJythonComponent(Component comp)
      Add a python component
      Parameters:
      comp - component to add
    • setLegendComponent

      public void setLegendComponent(Component comp)
      Hook to call from jython to add in the legend component
      Parameters:
      comp - legend component
    • setJythonComponent

      public void setJythonComponent(Component comp)
      Hook to call from jython to define gui
      Parameters:
      comp - gui
    • getSaveMenuItems

      protected void getSaveMenuItems(List items, boolean forMenuBar)
      Add the relevant file menu items into the list
      Overrides:
      getSaveMenuItems in class DisplayControlImpl
      Parameters:
      items - List of menu items
      forMenuBar - Is this for the menu in the window's menu bar or for a popup menu in the legend
    • getFileMenuItems

      protected void getFileMenuItems(List items, boolean forMenuBar)
      add to menu
      Overrides:
      getFileMenuItems in class DisplayControlImpl
      Parameters:
      items - list of menu items to add to
      forMenuBar - for menu bar
    • getEditMenuItems

      protected void getEditMenuItems(List items, boolean forMenuBar)
      add to menu
      Overrides:
      getEditMenuItems in class DisplayControlImpl
      Parameters:
      items - list of menu items to add to
      forMenuBar - for menu bar
    • getViewMenuItems

      protected void getViewMenuItems(List items, boolean forMenuBar)
      add to menu
      Overrides:
      getViewMenuItems in class DisplayControlImpl
      Parameters:
      items - list of menu items to add to
      forMenuBar - for menu bar
    • addFileMenuItem

      public void addFileMenuItem(String name, String method)
      Hook to call from jython to add to menu
      Parameters:
      name - menu item name
      method - jython method name to call
    • addSaveMenuItem

      public void addSaveMenuItem(String name, String method)
      Hook to call from jython to add to menu
      Parameters:
      name - menu item name
      method - jython method name to call
    • addViewMenuItem

      public void addViewMenuItem(String name, String method)
      Hook to call from jython to add to menu
      Parameters:
      name - menu item name
      method - jython method name to call
    • addEditMenuItem

      public void addEditMenuItem(String name, String method)
      Hook to call from jython to add to menu
      Parameters:
      name - menu item name
      method - jython method name to call
    • setProbeType

      public void setProbeType(String value)
      Set the ProbeType property.
      Parameters:
      value - The new value for ProbeType
    • getProbeType

      public String getProbeType()
      Get the ProbeType property.
      Returns:
      The ProbeType
    • setDeveloperMode

      public void setDeveloperMode(boolean value)
      Set the DeveloperMode property.
      Parameters:
      value - The new value for DeveloperMode
    • getDeveloperMode

      public boolean getDeveloperMode()
      Get the DeveloperMode property.
      Returns:
      The DeveloperMode
    • setMyName

      public void setMyName(String value)
      Set the MyName property.
      Parameters:
      value - The new value for MyName
    • getMyName

      public String getMyName()
      Get the MyName property.
      Returns:
      The MyName
    • setDataCategories

      public void setDataCategories(String value)
      Set the CategoryString property.
      Parameters:
      value - The new value for CategoryString
    • getDataCategories

      public String getDataCategories()
      Get the CategoryString property.
      Returns:
      The CategoryString
    • setJythonDisplayCategory

      public void setJythonDisplayCategory(String value)
      Set the DisplayCategory property.
      Parameters:
      value - The new value for DisplayCategory
    • getJythonDisplayCategory

      public String getJythonDisplayCategory()
      Get the DisplayCategory property.
      Returns:
      The DisplayCategory
    • setJythonCode

      public void setJythonCode(String value)
      Set the JythonCode property.
      Parameters:
      value - The new value for JythonCode
    • getJythonCode

      public String getJythonCode()
      Get the JythonCode property.
      Returns:
      The JythonCode
    • setJythonCodeURL

      public void setJythonCodeURL(String value)
      Set the JythonCode property.
      Parameters:
      value - The new value for JythonCode
    • getJythonCodeURL

      public String getJythonCodeURL()
      Get the JythonCode property.
      Returns:
      The JythonCode