Class Rtest

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--RtestBase
                                |
                                +--Rtest
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.MenuContainer, java.io.Serializable, java.awt.event.WindowListener

public class Rtest
extends RtestBase

Class Rtest - evaluate R scripts with data supplied from MAExplorer via the MJA API. Each R analysis is defined by a R LayOut (RLO). Each RLO is saved in an internal RLO database managed by the mjaReval MJA class. These specify the evaluation environment for the .R script when evaluated by R. The R program is then run as a separate process using a System.exec()

When executed, an R script is allowed to generate multiple output files that may include the following format templateValues: text, tab-delimited text, PDF, JPG, etc. There may be also multiple data input files requested by the R script. These are generated by mjaReval class methods as specified by the RLO database entry. Note: during R execution, all files are read and written from the {project}/Temp directory, the R current working directory. They may be copied to or from this directory from or to other directories as required.


  • data is exported from MAExplorer to tab-delimited data files {Project}/Temp/. These will then be read by R when your script is evaluated.
  • The output of R is saved to any number of files into {project}/Temp and then moved to {Project}/Report/ where they may then be displayed or read by MAExplorer if required.
  • The .R scripts are shared with all instances of MAExplorer and are kept in {MAExplorer installation}/R/
  • The startup script is generated by an mjaReval method and placed in the {project}/Temp directory where it will be used by a System.exec() call.

    This example is under construction, but can serve as a model of some the Open Java API interface and writing a simple MAEPlugin.

    This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The MAExplorer Mozilla and Legal files are available on http://maexplorer.sourceforge.net/.

    Version:
    $Date: 2003/06/18 19:10:37 $ $Revision: 1.80 $
    Author:
    P. Lemkin (NCI-Frederick); G. Thornwall (SAIC-Frederick); W.G. Alvord and Lubomirski (CSS/DMS/NCI-Frederick), Frederick, MD; S. Sundaram, SRA/BIMAS/CIT-NIH.
    See Also:
    MAExplorer Home, Reval, MJAReval, Serialized Form

    Inner classes inherited from class java.awt.Frame
    java.awt.Frame.AccessibleAWTFrame
     
    Inner classes inherited from class java.awt.Window
    java.awt.Window.AccessibleAWTWindow
     
    Inner classes inherited from class java.awt.Container
    java.awt.Container.AccessibleAWTContainer
     
    Inner classes inherited from class java.awt.Component
    java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
     
    Field Summary
    (package private)  MaeJavaAPI mja
               
    (package private)  MJAproperty mjaProperty
               
    (package private)  MJAreport mjaReport
               
    (package private)  MJAReval mjaReval
              instance of Reval
    (package private)  MJAutil mjaUtil
               
    (package private)  MJAReval mr
               
     
    Fields inherited from class RtestBase
    appendTextFlag, BANNER, buttonPanel, clearReportButton, clientBrowserTitle, clientDatabase, clientName, clientPrefixName, clientPrjPath, closeButton, CONSOLE_FLAG, dataBkgrd, dataColor, dataTF, DATE, DBUG_APPEND_REPORT, DBUG_FLAG, dbugCheckbox, dbugFlag, DEF_MAX_ANALSYSES, deleteRLOButton, editRLOButton, EPILOGUE_END, EPILOGUE_START, evalButton, fileSep, guiReadyFlag, helpButton, helpMsg, inputPanel, inputTF, isWindowsFlag, javaHome, MIN_WINDOW_HEIGHT, MIN_WINDOW_WIDTH, msgBkgrd, msgColor, msgFont, msgTF, nAnalyses, nCols, nDemoAnalyses, NEVER, newRLOButton, nRows, osName, pe, preferredHeight, preferredWidth, PROLOGUE_END, PROLOGUE_START, reportText, reportTextArea, REVISION, rgd, rt, saveAllDemoRLOsButton, saveasButton, saveReportAsTextFileFlag, scriptChoice, showDemoRLOsCheckbox, showDemoRLOsFlag, showPlotsButton, showRLOButton, showRscriptButton, spaces, titleFont, topPanel, userDir, VERSION
     
    Fields inherited from class java.awt.Frame
    base, CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, frameSerializedDataVersion, HAND_CURSOR, icon, ICONIFIED, mbManagement, menuBar, MOVE_CURSOR, N_RESIZE_CURSOR, nameCounter, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, ownedWindows, resizable, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, serialVersionUID, state, SW_RESIZE_CURSOR, TEXT_CURSOR, title, W_RESIZE_CURSOR, WAIT_CURSOR, weakThis
     
    Fields inherited from class java.awt.Window
    active, dbg, focusMgr, inputContext, inputContextLock, OPENED, ownedWindowList, showWithParent, warningString, windowListener, windowSerializedDataVersion
     
    Fields inherited from class java.awt.Container
    component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads
     
    Fields inherited from class java.awt.Component
    accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
     
    Fields inherited from interface java.awt.image.ImageObserver
    ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
     
    Constructor Summary
    Rtest(MaeJavaAPI mja)
              Rtest() - Constructor
     
    Method Summary
    (package private)  java.lang.String cvtSpacesToUnderscores(java.lang.String str)
              cvtSpacesToUnderscores() - replace spaces and other illegal file name characters with '_' chars to make file names highly portable.
    : space( ) ; " { } < > = , ? \ / % * ! @ & | ' ` \t
    (package private)  void displayPDF(java.lang.String pdfFile)
              displayPDF() - Display PDF file in adobe, for use in stand-alone.
    (package private)  void displayURL(java.lang.String urlStr)
              displayURL() - Display URL file in system Web browser, for use in stand-alone mode.
    (package private)  java.lang.String[] getListOfMenuStubNames()
              getListOfMenuStubNames() - get list of menu stub names
    (package private)  void popupAlertMsg(java.lang.String title, java.lang.String msg, int nRows, int nCols)
              popupAlertMsg() - popup alert message in a scrollable text area.
    (package private)  java.lang.String readTextFromFile(java.lang.String fileName, java.lang.String loadingMsg)
              readTextFromFile() - read text from text file.
    (package private)  java.lang.String rmvRtnChars(java.lang.String str)
              rmvRtnChars() - remove return chars.
    (package private)  void showMsg(java.lang.String msg)
              showMsg() - display message in client GUI
    (package private)  boolean writeTextToFile(java.lang.String textFileName, java.lang.String textReport)
              writeTextToFile() - save text string as text file.
     
    Methods inherited from class RtestBase
    actionPerformed, appendReport, buildGUI, close, drawReportText, extractUserRscript, genEpilogue, genPrologue, getPreferredSize, getUseGenRbit, handleEvent, initializeDataAndGUI, initRtest, itemStateChanged, paint, rebuildScriptChoices, saveTextReport, showCurrentRplots, showData, showGuiMsg, update, updateCurGene, updateFilter, updateLabels, updateSlider, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
     
    Methods inherited from class java.awt.Frame
    , addNotify, addToFrameList, constructComponentName, finalize, getAccessibleContext, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, initIDs, isResizable, paramString, postProcessKeyEvent, readObject, remove, removeFromFrameList, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle, writeObject
     
    Methods inherited from class java.awt.Window
    addOwnedWindow, addWindowListener, adjustListeningChildren, applyResourceBundle, applyResourceBundle, connectOwnedWindow, dispatchEventImpl, dispose, eventEnabled, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isActive, isShowing, nextFocus, ownedInit, pack, postEvent, postWindowEvent, preProcessKeyEvent, processEvent, processWindowEvent, removeOwnedWindow, removeWindowListener, resetGC, setCursor, setFocusOwner, setWarningString, show, toBack, toFront, transferFocus
     
    Methods inherited from class java.awt.Container
    add, add, add, add, add, addContainerListener, addImpl, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, numListening, paintComponents, paintHeavyweightComponents, postsOldMouseEvents, preferredSize, print, printComponents, printHeavyweightComponents, processContainerEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setFont, setLayout, validate, validateTree
     
    Methods inherited from class java.awt.Component
    action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
     
    Methods inherited from class java.lang.Object
    clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
     
    Methods inherited from interface java.awt.MenuContainer
    getFont, postEvent
     

    Field Detail

    mja

    MaeJavaAPI mja

    mjaProperty

    MJAproperty mjaProperty

    mjaReport

    MJAreport mjaReport

    mjaUtil

    MJAutil mjaUtil

    mjaReval

    MJAReval mjaReval
    instance of Reval

    mr

    MJAReval mr
    Constructor Detail

    Rtest

    public Rtest(MaeJavaAPI mja)
    Rtest() - Constructor
    See Also:
    MJAproperty.getMaeCurProjectPath(), MJAproperty.getMaeBrowserTitle(), MJAproperty.getMaeDatabaseTitle(), MJAproperty.getMaeDbSubsetTitle(), RtestBase.initializeDataAndGUI(), RtestBase.showData(java.lang.String, java.awt.Color, java.awt.Color), RtestBase.showGuiMsg(java.lang.String, java.awt.Color, java.awt.Color)
    Method Detail

    showMsg

    void showMsg(java.lang.String msg)
    showMsg() - display message in client GUI
    Overrides:
    showMsg in class RtestBase
    Parameters:
    msg - message to display

    readTextFromFile

    java.lang.String readTextFromFile(java.lang.String fileName,
                                      java.lang.String loadingMsg)
    readTextFromFile() - read text from text file.
    Overrides:
    readTextFromFile in class RtestBase
    Parameters:
    fileName - full path name of text file
    loadingMsg - to display while loading, null if no message
    Returns:
    text if suceed else null

    writeTextToFile

    boolean writeTextToFile(java.lang.String textFileName,
                            java.lang.String textReport)
    writeTextToFile() - save text string as text file.
    Overrides:
    writeTextToFile in class RtestBase
    Parameters:
    textFileName - full path name of text file
    textReport - text to save in file
    Returns:
    true if succeed.

    popupAlertMsg

    void popupAlertMsg(java.lang.String title,
                       java.lang.String msg,
                       int nRows,
                       int nCols)
    popupAlertMsg() - popup alert message in a scrollable text area. Press close to continue. If the auto popdown is set (Edit menu | Preferences submenut) then popdown the window after a timeout else it requires manually pressing the Close button.
    Overrides:
    popupAlertMsg in class RtestBase
    Parameters:
    title - is the optional title for the popup window
    msg - is the message for the popup window
    nRows - is the # of rows for the popup window, 20 if specify 0
    nCols - is the # of columns for the popup window, 80 if specify 0

    displayURL

    void displayURL(java.lang.String urlStr)
    displayURL() - Display URL file in system Web browser, for use in stand-alone mode. This assumes that you have added the proper plugin to your browser for this data if required.
     Examples:
     displayURL("http://www.javaworld.com")
     displayURL("file://c:\\docs\\index.html")
     displayURL("file:///user/joe/index.html");
     displayURL("file:///user/joe/image.xml");
     displayURL("file:///user/joe/iimage.svg");
    
    Under Unix, the system browser is hard-coded to be 'netscape'. Netscape must be in your PATH for this to work.
    Under Windows, this will bring up the default browser under windows, usually either Netscape or Microsoft IE. The default browser is determined by the OS.
    adapted from : http://www.javaworld.com/javaworld/javatips/jw-javatip66_p.html
    NOTE: param url the file's url(the url must start with either "http://" or"file://"). [TODO] Handle the Mac better.
    Overrides:
    displayURL in class RtestBase
    Parameters:
    url - to display in popup browser
    Returns:
    false if error.

    displayPDF

    void displayPDF(java.lang.String pdfFile)
    displayPDF() - Display PDF file in adobe, for use in stand-alone. Under Unix, the system browser is hard-coded to be 'Acrobat'. Acrobat must be in your PATH for this to work.
    Under Windows, this will bring up Acrobat (if installed).
    adapted from : http://www.javaworld.com/javaworld/javatips/jw-javatip66_p.html
    Overrides:
    displayPDF in class RtestBase
    Parameters:
    pdfFile - file to display in Adobe Acrobat
    Returns:
    false if error.

    cvtSpacesToUnderscores

    java.lang.String cvtSpacesToUnderscores(java.lang.String str)
    cvtSpacesToUnderscores() - replace spaces and other illegal file name characters with '_' chars to make file names highly portable.
    : space( ) ; " { } < > = , ? \ / % * ! @ & | ' ` \t
    Overrides:
    cvtSpacesToUnderscores in class RtestBase
    Parameters:
    str - to be converted
    Returns:
    converted string

    rmvRtnChars

    java.lang.String rmvRtnChars(java.lang.String str)
    rmvRtnChars() - remove return chars. Map '\r' or "\r\n" to '\n' chars.
    Overrides:
    rmvRtnChars in class RtestBase
    Parameters:
    String - str to process
    Returns:
    String with '\r' removed.

    getListOfMenuStubNames

    java.lang.String[] getListOfMenuStubNames()
    getListOfMenuStubNames() - get list of menu stub names
    Overrides:
    getListOfMenuStubNames in class RtestBase
    Returns:
    list of Menu Stub Names