Class ImageGenerator

All Implemented Interfaces:
ActionListener, EventListener, IdvConstants

public class ImageGenerator extends IdvManager
Manages the user interface for the IDV
Author:
IDV development team
  • Field Details

  • Constructor Details

    • ImageGenerator

      public ImageGenerator(IntegratedDataViewer idv)
      Create me with the IDV
      Parameters:
      idv - The IDV
    • ImageGenerator

      public ImageGenerator(IntegratedDataViewer idv, List scriptFiles)
      Create me with the IDV and start processing files
      Parameters:
      idv - The IDV
      scriptFiles - List of isl files
  • Method Details

    • processScriptFiles

      public void processScriptFiles(List scriptFiles)
      Process the list of isl files
      Parameters:
      scriptFiles - isl files
    • processScriptFile

      public boolean processScriptFile(String islFile)
      Process the isl files
      Parameters:
      islFile - file
      Returns:
      Was it successful
    • processScriptFile

      public boolean processScriptFile(String islFile, Hashtable properties)
      Process the script file
      Parameters:
      islFile - the ISL file
      properties - optional properties
      Returns:
      true if successful
    • processScriptFile

      public boolean processScriptFile(String islFile, Hashtable properties, boolean interactive)
      Process the script file
      Parameters:
      islFile - the ISL file
      properties - optional properties
      interactive - Is this call interactive. If not interactive then we don't pop up the error dialog
      Returns:
      true if successful
    • getResults

      public List<String> getResults()
    • getError

      public String getError()
    • processTagFor

      protected boolean processTagFor(Element node) throws Throwable
      Process the "for" tag
      Parameters:
      node - the tag node
      Returns:
      true if successful
      Throws:
      Throwable - an error
    • processTagFtp

      protected boolean processTagFtp(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagExport

      protected boolean processTagExport(Element node) throws Throwable
      Process the export tag. This allows one to export data from a display. It requires a display identifier
      Parameters:
      node - isl xml node
      Returns:
      everything is cool
      Throws:
      Throwable - On badness
    • processTagSave

      protected boolean processTagSave(Element node) throws Throwable
      Throws:
      Throwable
    • processTagPublish

      protected boolean processTagPublish(Element node) throws Throwable
      Throws:
      Throwable
    • processTagTrace

      protected boolean processTagTrace(Element node) throws Throwable
      Process the tag trace
      Parameters:
      node - the node
      Returns:
      true if processed
      Throws:
      Throwable - on badness
    • processTagRemovedisplays

      protected boolean processTagRemovedisplays(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagPrintcache

      protected boolean processTagPrintcache(Element node) throws Throwable
      Process the print cache tag
      Parameters:
      node - the XML node
      Returns:
      true if successful
      Throws:
      Throwable - on badness
    • processTagRemoveall

      protected boolean processTagRemoveall(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagSetfiles

      protected boolean processTagSetfiles(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagExists

      protected boolean processTagExists(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagBeep

      protected boolean processTagBeep(Element node) throws Throwable
      make a beep
      Parameters:
      node - the isl xml node
      Returns:
      true
      Throws:
      Throwable
    • processTagAsk

      protected boolean processTagAsk(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagEcho

      protected boolean processTagEcho(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagAsktocontinue

      protected boolean processTagAsktocontinue(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagGc

      protected boolean processTagGc(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagBreak

      protected boolean processTagBreak(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagContinue

      protected boolean processTagContinue(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagReturn

      protected boolean processTagReturn(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagProcedure

      protected boolean processTagProcedure(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagMkdir

      protected boolean processTagMkdir(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagStop

      protected boolean processTagStop(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • getPropertyValue

      protected String[] getPropertyValue(Element node) throws Throwable
      Get the property value
      Parameters:
      node - the XML node
      Returns:
      the values
      Throws:
      Throwable - on badness
    • processTagIdvproperty

      protected boolean processTagIdvproperty(Element node) throws Throwable
      Process IDV property tag
      Parameters:
      node - the XML node
      Returns:
      true if successful
      Throws:
      Throwable - on badness
    • processTagProperty

      protected boolean processTagProperty(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagMove

      protected boolean processTagMove(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagRename

      protected boolean processTagRename(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagDelete

      protected boolean processTagDelete(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagClear

      protected boolean processTagClear(Element node) throws Throwable
      Handle the clear tag
      Parameters:
      node - node
      Returns:
      ok
      Throws:
      Throwable - On badness
    • processTagAppend

      protected boolean processTagAppend(Element node) throws Throwable
      Handle the append tag
      Parameters:
      node - node
      Returns:
      ok
      Throws:
      Throwable - On badness
    • processTagIncrement

      protected boolean processTagIncrement(Element node) throws Throwable
      Handle the append tag
      Parameters:
      node - node
      Returns:
      ok
      Throws:
      Throwable - On badness
    • processTagReplace

      protected boolean processTagReplace(Element node) throws Throwable
      Handle the append tag
      Parameters:
      node - node
      Returns:
      ok
      Throws:
      Throwable - On badness
    • processTagCopy

      protected boolean processTagCopy(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagReload

      protected boolean processTagReload(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagExec

      protected boolean processTagExec(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagJython

      protected boolean processTagJython(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagFileset

      protected boolean processTagFileset(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagImport

      protected boolean processTagImport(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagLoadcatalog

      protected boolean processTagLoadcatalog(Element node) throws Throwable
      Load a catalog URL
      Parameters:
      node - The ISL node
      Returns:
      Keep going
      Throws:
      Throwable
    • processTagListdirectory

      protected boolean processTagListdirectory(Element node) throws Throwable
      Load a directory to the file chooser
      Parameters:
      node - The ISL node
      Returns:
      Keep going
      Throws:
      Throwable
    • processTagDatasource

      protected boolean processTagDatasource(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagJoin

      protected boolean processTagJoin(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagView

      protected boolean processTagView(Element node) throws Throwable
      Process the view tag
      Parameters:
      node - the element
      Returns:
      true if it was processed
      Throws:
      Throwable - problems
    • processTagAnimation

      protected boolean processTagAnimation(Element node) throws Throwable
      Handle the animation tag. The index attribute can either be a number or be "end"
      Parameters:
      node - the node
      Returns:
      true if successful
      Throws:
      Throwable - problems
    • processTagViewpoint

      protected boolean processTagViewpoint(Element node) throws Throwable
      Process the viewpoint tag
      Parameters:
      node - the node
      Returns:
      true if successful
      Throws:
      Throwable - problems
    • processTagCenter

      protected boolean processTagCenter(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagProjection

      protected boolean processTagProjection(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • findDisplayControl

      public DisplayControlImpl findDisplayControl(String id)
      Find the display control identified by the given id
      Parameters:
      id - The id of the display control. This can be the id or it can be a 'class:class name'
      Returns:
      The display control or null
    • findDisplayControl

      public DisplayControlImpl findDisplayControl(String id, List<DisplayControlImpl> controls)
      Find the display control
      Parameters:
      id - the control id
      controls - the list of controls
      Returns:
      the control or null
    • processTagBundle

      protected boolean processTagBundle(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagCall

      protected boolean processTagCall(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagCall

      protected boolean processTagCall(Element node, Element procNode) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      procNode - The procedure node
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagIf

      protected boolean processTagIf(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagOutput

      protected boolean processTagOutput(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagIsl

      protected boolean processTagIsl(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagGroup

      protected boolean processTagGroup(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagForeach

      protected boolean processTagForeach(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagMovie

      protected boolean processTagMovie(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagHtml

      protected boolean processTagHtml(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagPanel

      protected boolean processTagPanel(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • writeMovie

      public void writeMovie(String filename, String params) throws Exception
      Capture a movie and write it out. This is typically called by the jython scripting
      Parameters:
      filename - Movie filename
      params - xml parameters of the the form: "task arg=val arg2=val; task2 arg3=val"
      Throws:
      Exception - On badness
    • processTagImage

      protected boolean processTagImage(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagWait

      protected boolean processTagWait(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • processTagPause

      protected boolean processTagPause(Element node) throws Throwable
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
      Throws:
      Throwable - On badness
    • updateViewManagers

      protected void updateViewManagers()
      Update the view managers
    • processTagDisplayproperties

      protected boolean processTagDisplayproperties(Element node)
      Process tag display properties
      Parameters:
      node - the node
      Returns:
      true if successful
    • processTagDisplay

      protected boolean processTagDisplay(Element node)
      process the given node
      Parameters:
      node - Node to process
      Returns:
      keep going
    • error

      protected boolean error(String msg)
      Utility to print a message and return false.
      Parameters:
      msg - message
      Returns:
      false
    • error

      protected boolean error(String msg, Exception exc)
      Utility to print a message and return false.
      Parameters:
      msg - message
      exc - exception
      Returns:
      false
    • applyMacros

      public String applyMacros(Element node, String attr)
      Find the attribute value of the given node. Apply the macros to it.
      Parameters:
      node - Node to process
      attr - Attribute name
      Returns:
      The value
    • applyMacros

      public String applyMacros(Element node, String attr, String dflt)
      If the attribute does not exist return the dflt. Else return the value.
      Parameters:
      node - Node to process
      attr - Attribute name
      dflt - The default value to use if the attribute does not exist
      Returns:
      The value
    • applyMacros

      public int applyMacros(Element node, String attr, int dflt)
      If the attribute does not exist return the dflt. Else return the value.
      Parameters:
      node - Node to process
      attr - Attribute name
      dflt - The default value to use if the attribute does not exist
      Returns:
      The value
    • applyMacros

      public boolean applyMacros(Element node, String attr, boolean dflt)
      If the attribute does not exist return the dflt. Else return the value.
      Parameters:
      node - Node to process
      attr - Attribute name
      dflt - The default value to use if the attribute does not exist
      Returns:
      The value
    • applyMacros

      public Color applyMacros(Element node, String attr, Color dflt)
      If the attribute does not exist return the dflt. Else return the value.
      Parameters:
      node - Node to process
      attr - Attribute name
      dflt - The default value to use if the attribute does not exist
      Returns:
      The value
    • applyMacros

      public double applyMacros(Element node, String attr, double dflt)
      If the attribute does not exist return the dflt. Else return the value.
      Parameters:
      node - Node to process
      attr - Attribute name
      dflt - The default value to use if the attribute does not exist
      Returns:
      The value
    • applyMacros

      public String applyMacros(String s)
      Do the macro substitution
      Parameters:
      s - The string
      Returns:
      The expanded string
    • captureImage

      public void captureImage(String filename)
      Capture an image from the first active view managers
      Parameters:
      filename - The image filename
    • putIndex

      public void putIndex(Hashtable props, String name, int v)
      Put the index
      Parameters:
      props - the properties
      name - the name
      v - the index
    • pause

      public void pause()
      Wait until all displays are built
    • setDebug

      public void setDebug(boolean v)
      Toggle debug
      Parameters:
      v - debug
    • evaluateIsl

      public boolean evaluateIsl(String isl) throws Throwable
      Evaluate the given isl
      Parameters:
      isl - The isl
      Returns:
      success
      Throws:
      Throwable - On badness
    • loadBundle

      public void loadBundle(String bundleFile, List setFiles) throws Throwable
      Load the given bundle file
      Parameters:
      bundleFile - The bundle
      setFiles - This is a list, which may be null, of datasource patterns and file names to change
      Throws:
      Throwable - On badness
    • loadBundle

      public void loadBundle(String bundleFile, List setFiles, int width, int height) throws Throwable
      Load the given bundle file, list of datasets, width and height
      Parameters:
      bundleFile - The bundle
      setFiles - This is a list, which may be null, of datasource patterns and file names to change
      width - The width of the display area to use
      height - The height of the display are to use
      Throws:
      Throwable - an exception
    • loadBundle

      public void loadBundle(String bundleFile, List setFiles, int width, int height, String times, boolean clear) throws Throwable
      Load the given bundle file, list of datasets, width and height
      Parameters:
      bundleFile - The bundle
      setFiles - This is a list, which may be null, of datasource patterns and file names to change
      width - The width of the display area to use
      height - The height of the display are to use
      times - A string of times to use from the bundle file
      clear - If false then do not clear out the data sources and displays (which is otherwise the default)
      Throws:
      Throwable - an exception
    • writeImageToFile

      public void writeImageToFile(Image image, String file) throws Exception
      Write an Image to the specified file
      Parameters:
      image - Image to be written
      file - Name of output file (may use macros)
      Throws:
      Exception - On badness
    • makeXmlFromString

      protected static String makeXmlFromString(String s)
      Create XML from the input String
      Parameters:
      s - in the form: "task arg=val arg2=val; task2 arg3=val"
      Returns:
    • writeImage

      public void writeImage(String filename, String params, float qual) throws Exception, Throwable
      Get the image of the current display and write to file. Image may be modified by the params given in the form: tag1 arg=val arg2=val2; tag2 arg=val where 'tag' are ISL tags.
      Parameters:
      filename - Output filename (may be modified by macros)
      params - String of parameters
      qual - Quality (def=1.0)
      Throws:
      Exception - On badness
      Throwable - On badness
    • getImage

      public Image getImage() throws Exception
      Get the Image of the current display
      Returns:
      the Image
      Throws:
      Exception - On badness
    • resize

      protected Image resize(Image image, Element node)
      Resize the image
      Parameters:
      image - The image
      node - Node to process. This may contain a width or a height attribute.
      Returns:
      The resized image
    • resizeImage

      public BufferedImage resizeImage(BufferedImage image, String widthStr, String heightStr)
      Resize the image
      Parameters:
      image - The image
      widthStr - width of desired image (pixels)
      heightStr - height of desired image (pixels)
      Returns:
      The resized image
    • matteImage

      public BufferedImage matteImage(BufferedImage image, String bgString, int top, int left, int bottom, int right)
      Matte the image
      Parameters:
      image - The image
      bgString - color for the matte ("red", "green", etc)
      top - number of lines for the top (north) matte
      left - number of pixels for the left (west) matte
      bottom - number of lines for the bottom (south) matte
      right - number of pixels for the right (east) matte
      Returns:
      The matte'd image
    • processImage

      protected BufferedImage processImage(BufferedImage image, String filename, Element node, Hashtable props, ViewManager viewManager, Hashtable imageProps) throws Throwable
      Process the image
      Parameters:
      image - The image
      filename - File to write the image to
      node - Node to process
      props - Extra properties
      viewManager - The viewmanager this image came from
      imageProps - the image properties
      Returns:
      The processed image
      Throws:
      Throwable - On badness
    • getInsets

      public Insets getInsets(Element child, int dflt)
      Get the insets
      Parameters:
      child - the element
      dflt - the default value
      Returns:
      the Insets
    • doLatLonLabels

      public BufferedImage doLatLonLabels(Element child, ViewManager viewManager, BufferedImage image, Hashtable imageProps) throws Exception
      Process the lat/lon labels tag
      Parameters:
      child - the XML
      viewManager - the associated view manager
      image - the image to draw on
      imageProps - the image properties
      Returns:
      a new image
      Throws:
      Exception - on badness
    • doMatte

      public BufferedImage doMatte(BufferedImage image, Element child, int dfltSpace)
      Matte the image
      Parameters:
      image - the image
      child - the XML defining the matting
      dfltSpace - default spacing
      Returns:
      a new image
    • doMatte

      public BufferedImage doMatte(BufferedImage image, Element child, Insets insets)
      Matte the image
      Parameters:
      image - the image
      child - the matte specs
      insets - the insets
      Returns:
      a new image
    • doneCapturingMovie

      public void doneCapturingMovie()
      Called to notify this object that the movie capture is done
    • captureMovie

      public void captureMovie(String filename)
      Capture a movie from the first view manager
      Parameters:
      filename - The movie filename
    • captureMovie

      public void captureMovie(String filename, Element scriptingNode)
      Capture the movie
      Parameters:
      filename - The file
      scriptingNode - Node form isl.
    • getAnimationTime

      public Date getAnimationTime()
      Find the animation time of the first Animation in a view manager we find
      Returns:
      Animation time
    • fields

      public String fields(String datasource, String pattern)
      callable by jython to find the data choices that match the given pattern
      Parameters:
      datasource - data source
      pattern - pattern to match
      Returns:
      comma separated list of data choice names
    • debug

      protected void debug(String msg)
      Print the message if in debug mode
      Parameters:
      msg - The message
    • ftpPut

      public static void ftpPut(String server, String userName, String password, String destination, byte[] bytes) throws Exception
      Do an FTP put of the given bytes
      Parameters:
      server - server
      userName - user name on server
      password - password on server
      destination - Where to put the bytes
      bytes - The bytes
      Throws:
      Exception - On badness
    • getLetter

      public String getLetter(int i)
      Get the letter for the index
      Parameters:
      i - the index
      Returns:
      the letter
    • getRoman

      public String getRoman(int i)
      Get the roman numeral
      Parameters:
      i - the index
      Returns:
      the corresponding number