Class Util

java.lang.Object
  |
  +--Util

class Util
extends java.lang.Object

The Util class contains common utility functions used by the rest of MAExplorer. These include, several string-numeric converters, messages to the three message lines in the top page as well as special string array parsing, font string name to int size, ratio color setting, zoom toggle mapping, etc.

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/07/15 20:31:01 $ $Revision: 1.26 $
Author:
P. Lemkin(NCI), G. Thornwall(SAIC), NCI-Frederick, Frederick, MD
See Also:
MAExplorer Home

Field Summary
private static boolean appendHistoryFlag
          Flag: set if appending command history to historyFile
private static boolean appendMsgFlag
          Flag: set if appending msg to historyFile
(package private) static int cmdHistoryNbr
          Command history number gets incremented each time a command is logged.
(package private) static float defaultFloat
          default float value for conversions
(package private) static int defaultInt
          default int value for conversions
private static FileIO fio
          link to global FileIO instance
private static java.lang.String historyFileName
          Full path name of history file if enabled.
(package private) static boolean historyIsVisibleFlag
          History window visibility flag
(package private) static LogTextFrame historyTextFrame
          Log History text frame.
(package private) static MAExplorer mae
          link to global MAExplorer instance
private static java.lang.String msgFileName
          Full path name of msg file if enabled.
(package private) static boolean msgIsVisibleFlag
          Message window visibility flag
(package private) static LogTextFrame msgTextFrame
          Log msg text frames.
(package private) static java.lang.String mStatus
          Copy of last ShowMsg() printed
 
Constructor Summary
(package private) Util(MAExplorer mae)
          Util() - constructor for Utility package
 
Method Summary
(package private) static java.lang.String addQuotesIfSpace(java.lang.String str)
          addQuotesIfSpace() - add "..." around string if it contains a space but don't add quotes if it already has a leading ".
(package private) static boolean checkImagesDirExists()
          checkImagesDirExists() - check if images directory exists
(package private) static java.lang.String chkDirFinalSeparator(java.lang.String sPath, java.lang.String fS)
          chkDirFinalSeparator() - make dir path end in fileSeparator.
(package private)  void cleanup()
          cleanup() - cleanup global static allocated variables in this class If statics are added later to this class, then set them to null here.
(package private) static java.lang.String cvd2s(double v, int precision)
          cvd2s() - convert double to string with precision # of digits If precision > 0 then limit # of digits in fraction
(package private) static java.lang.String cvf2s(float v, int precision)
          cvf2s() - convert float to string with precision # of digits.
(package private) static java.lang.String cvFileNameWithMod(java.lang.String fileName, java.lang.String mod)
          cvFileNameWithMod() - insert modifier string before file extension
(package private) static int cvFontS2I(java.lang.String fontSizeStr)
          cvFontS2I() - convert font size "8Ppt", "10pt", "12pt", or "14pt" to int
(package private) static java.lang.String cvLongToHex(long data)
          cvLongToHex() - convert long to hex string
(package private) static java.lang.String[] cvs2Array(java.lang.String str, int maxExpected, java.lang.String delimiterChr)
          cvs2Array() - cvt arg list "1,4,3,6,..." to "," - delim String[].
(package private) static double cvs2d(java.lang.String str)
          cvs2d() - convert String to double
(package private) static double cvs2d(java.lang.String str, double defaultValue)
          cvs2d() - convert String to double with default value
(package private) static float cvs2f(java.lang.String str)
          cvs2f() - convert String to float
(package private) static float cvs2f(java.lang.String str, float defaultValue)
          cvs2f() - convert String to float with default value
(package private) static int cvs2i(java.lang.String str)
          cvs2i() - convert String to int
(package private) static int cvs2i(java.lang.String str, int defaultValue)
          cvs2i() - convert String to int with default value
(package private) static int[] cvs2iArray(java.lang.String str, int maxExpected, java.lang.String delimChr)
          cvs2iArray() - convert String arg list "1,4,3,6,..." to int[]
(package private) static java.lang.String cvtBackslash2Fwdslash(java.lang.String sInput)
          cvtBackslash2Fwdslash() - convert '\\' to '/' in the string
(package private) static boolean cvtEnvPaths2Properties()
          cvtEnvPaths2Properties() - get all system ENV variables and set them as separate Java properties so we can get them individually from System.getProperty(var) calls.
(package private) static 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.
(package private) static java.lang.String cvtStrArrayToStr(java.lang.String[] strData)
          cvtStrArrayToStr() - create(String) from String[] array with "\n"
(package private) static java.lang.String cvtStrArrayToStr(java.lang.String[] strData, int len)
          cvtStrArrayToStr() - create(String) from String[] array with "\n" w/len Fast method creates a tmp Character [] of required size and stuffs it, then converts it to a string at one time instead of repeatedly using concat(i.e.
(package private) static java.lang.String cvtStrArrayToStr(java.lang.String[] strData, java.lang.String delim, java.lang.String terminator)
          cvtStrArrayToDelimStr() - create delimited(String) from String[] array with terminator as last character.
(package private) static java.lang.String cvtValueToStars(float val, float valMax, int maxStars, boolean rightFillFlag)
          cvtValueToStars() - cvt val in[0:valMax] to "****"+" " string where the maximum # of stars for v==vMax is specified.
(package private) static java.lang.String dateStr()
          dateStr() - return a new Date string of the current day and time
(package private)  boolean displayPDF(java.lang.String pdfFile)
          displayPDF() - Display PDF file in adobe, for use in stand-alone.
(package private)  boolean displayURL(java.lang.String url)
          displayURL() - Display URL file in system Web browser, for use in stand-alone mode.
(package private) static int findIndexForKey(java.lang.String[] data, java.lang.String key)
          findIndexForKey() - lookup index of key in data[].
(package private) static java.lang.String getCurDateStr()
          getCurDateStr() - return date string in the format of YYMMDDHHMMSS.
(package private) static java.lang.String getRatioStr()
          getRatioStr() - get "F1/F2", "Cy3/Cy5" or "Cy5/Cy3", etc.
(package private) static int nextZoomMag(int val, int maxVal)
          nextZoomMag() - modulo 1X, 2X, 5X, 10X, 20X, 50X, 100X, 200X, 500X, 1000X
(package private) static 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) static void popupAlertMsgLine(java.lang.String msg)
          popupAlertMsgLine) - popup ALERT message line and then timeout.
(package private) static boolean popupDryrotMsgsAndQuit()
          popupDryrotMsgsAndQuit() - if any dryrot, tell us and die...
(package private)  boolean popupImageOfHPsample(MaHybridSample ms)
          popupImageOfHPsample() - popup image of current gene in Web browser.
(package private)  void popupViewer(java.net.URL urlBase, java.lang.String fileIn, java.lang.String windowName)
          popupViewer() - popup a web browser for the help HTML file.
(package private) static java.lang.String prepForFileURL(java.lang.String str)
          prepForFileURL() - map "\" to "/" chars in string to use for URL
(package private) static void printCurrentMemoryUsage(java.lang.String msg)
          printCurrentMemoryUsage() - print: %free, total memory usage and timeOfday
(package private)  java.lang.String rmvDupIMAGEstr(java.lang.String str)
          rmvDupIMAGEstr() - remove duplicate "IMAGE:xxxx:" prefix from string.
static java.lang.String rmvFinalSubDirectory(java.lang.String dirStr, java.lang.String optDir, boolean chkMAEtreeFlag)
          rmvFinalSubDirectory() - remove trailing ".../dir/" if it exists otherwise return original string.
(package private)  java.lang.String rmvIMAGEstr(java.lang.String str)
          rmvIMAGEstr() - - remove "IMAGE:" prefix from string.
(package private) static java.lang.String rmvRtnChars(java.lang.String str)
          rmvRtnChars() - remove return chars.
(package private) static void saveCmdHistory(java.lang.String msg)
          saveCmdHistory() - print msg to showMsg1() and also save in command history and message logs if logging is enabled as well.
(package private) static void saveCmdHistory(java.lang.String msg, boolean doShowMsgFlag)
          saveCmdHistory() - save msg in command history and message logs if logging is enabled.
(package private) static void saveMsgHistory(java.lang.String msg, boolean doShowMsgFlag)
          saveMsgHistory() - save msg in message logs if logging is enabled.
(package private) static boolean setHistoryFileLogging(java.lang.String histFileName, boolean isVisibleFlag, boolean appendLogDataFlag)
          setHistoryFileLogging() - set up history file logging.
(package private)  boolean setHistoryLoggingState(boolean isVisibleFlag, boolean appendHistFlag)
          setHistoryLoggingState() - set the history logging state on/off.
(package private) static void setLogHistoryWindowVisible(boolean isVisibleFlag)
          setLogHistoryWindowVisible() - make the popup window visible or invisible
(package private) static void setLogMsgWindowVisible(boolean isVisibleFlag)
          setLogMsgWindowVisible() - make the popup window visible or invisible
(package private) static boolean setMsgFileLogging(java.lang.String msgFileName, boolean isVisibleFlag, boolean appendMsgDataFlag)
          setMsgFileLogging() - set up message file logging.
(package private)  boolean setMsgLoggingState(boolean isVisibleFlag, boolean appndMsgFlag)
          setMsgLoggingState() - set the messages logging state on/off.
(package private) static boolean setPseudoArrayColorSpectrumMap(java.awt.Color[] spectrumColor, float[] spectrumRange)
          setPseudoArrayColorSpectrumMap() - set pseudoarray color map spectrum data.
(package private) static boolean setPseudoArrayRatioColorMap(java.awt.Color[] ratioColor, float[] ratioRange, int maxColors)
          setPseudoArrayRatioColorMap() - set pseudoarray ratios color map data.
(package private) static java.awt.Color setRatioColor(float ratio, java.awt.Color[] ratioColor, float[] ratioRange, int maxColors)
          setRatioColor() - map data ratio to color in current color scheme Color is in(ratioMin : ratioMax].
(package private) static boolean setupColorRatioRange(float delta, java.awt.Color[] ratioColor, float[] ratioRange, int maxColors, boolean useNegRangeFlag)
          setupColorRatioRange() - setup ratio color map iteratively w/spacing delta.
(package private) static boolean setupColorSpectrumRange(java.awt.Color[] ratioColor, float[] ratioRange, int maxColors, boolean redIsZeroFlag)
          setupColorSpectrumRange() - setup spectrumcolor map data range [0.0:1.0].
(package private) static void showFeatures(java.lang.String genbankData, java.lang.String genomicData)
          showFeatures() - print features to txtField2 and txtField3
(package private) static void showMsg(java.lang.String msg)
          showMsg() - print msg to showStatus() and to txtField1
(package private) static void showMsg1(java.lang.String msg, boolean saveTitleFlag, java.awt.Color fg, java.awt.Color bg)
          showMsg1() - print msg to showStatus() and to txtField1 and change color
(package private) static void showMsg1(java.lang.String msg, java.awt.Color fg, java.awt.Color bg)
          showMsg1() - print msg to showStatus() and to txtField1 and change color
(package private) static void showMsg2(java.lang.String msg2)
          showMsg2() - print msg2 to txtField2
(package private) static void showMsg2(java.lang.String msg2, java.awt.Color fg, java.awt.Color bg)
          showMsg2() - print msg2 to txtField2 and change color
(package private) static void showMsg3(java.lang.String msg3)
          showMsg3() - print msg3 to txtField3
(package private) static void showMsg3(java.lang.String msg3, java.awt.Color fg, java.awt.Color bg)
          showMsg3() - print msg3 to txtField3 ALSO: side effect of setting cursor to WAIT_CURSOR if the(fg,bg) is not(black,white).
(package private) static void sleepMsec(int sleepMsec)
          sleepMsec() - sleep nMsec where nMsec must be >= 0 milliseconds.
(package private) static java.lang.String timeStr()
          timeStr() - return a new daytime HH:MM:SS string of the current time.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

mae

static MAExplorer mae
link to global MAExplorer instance

fio

private static FileIO fio
link to global FileIO instance

mStatus

static java.lang.String mStatus
Copy of last ShowMsg() printed

defaultInt

static int defaultInt
default int value for conversions

defaultFloat

static float defaultFloat
default float value for conversions

msgTextFrame

static LogTextFrame msgTextFrame
Log msg text frames. If enabled, this logs all showMsgXXX() output that contains all messages.

msgIsVisibleFlag

static boolean msgIsVisibleFlag
Message window visibility flag

msgFileName

private static java.lang.String msgFileName
Full path name of msg file if enabled.

appendMsgFlag

private static boolean appendMsgFlag
Flag: set if appending msg to historyFile

cmdHistoryNbr

static int cmdHistoryNbr
Command history number gets incremented each time a command is logged.

historyTextFrame

static LogTextFrame historyTextFrame
Log History text frame. If enabled, this logs all commands

historyIsVisibleFlag

static boolean historyIsVisibleFlag
History window visibility flag

historyFileName

private static java.lang.String historyFileName
Full path name of history file if enabled.

appendHistoryFlag

private static boolean appendHistoryFlag
Flag: set if appending command history to historyFile
Constructor Detail

Util

Util(MAExplorer mae)
Util() - constructor for Utility package
Parameters:
mae - is MAExplorer instance
Method Detail

setMsgFileLogging

static boolean setMsgFileLogging(java.lang.String msgFileName,
                                 boolean isVisibleFlag,
                                 boolean appendMsgDataFlag)
setMsgFileLogging() - set up message file logging. If it is a standalone application then you can also create a message log file.
Parameters:
historyFileName - is the name of the history file excluding the path
appendLogDataFlag - indicates that history accumulates between viewing sessions.
Returns:
true if logging is successfully set up. You then log messages by calls to showMsgXXX().
See Also:
LogTextFrame

setHistoryFileLogging

static boolean setHistoryFileLogging(java.lang.String histFileName,
                                     boolean isVisibleFlag,
                                     boolean appendLogDataFlag)
setHistoryFileLogging() - set up history file logging. If it is a standalone application then we can also create a history log file.
Parameters:
historyFileName - is the name of the history file excluding the path
isVisibleFlag - makes the history window visible.
appendLogDataFlag - indicates that history accumulates between viewing sessions.
Returns:
true if logging is successfully set up. You then log messages by calls to showMsgXXX().
See Also:
LogTextFrame

setMsgLoggingState

boolean setMsgLoggingState(boolean isVisibleFlag,
                           boolean appndMsgFlag)
setMsgLoggingState() - set the messages logging state on/off. This only applies if it had been previously enabled.
Parameters:
isVisibleFlag - makes the message logging window visible.
appndMsgFlag - indicates that message logging accumulates between viewing sessions.
Returns:
true if able to change the state.
See Also:
setLogMsgWindowVisible(boolean)

setHistoryLoggingState

boolean setHistoryLoggingState(boolean isVisibleFlag,
                               boolean appendHistFlag)
setHistoryLoggingState() - set the history logging state on/off. This only applies if it had been previously enabled.
Parameters:
isVisibleFlag - makes the history window visible.
appendLogDataFlag - indicates that history accumulates between viewing sessions.
Returns:
true if able to change the state.
See Also:
setLogHistoryWindowVisible(boolean)

setLogMsgWindowVisible

static void setLogMsgWindowVisible(boolean isVisibleFlag)
setLogMsgWindowVisible() - make the popup window visible or invisible
Parameters:
isVisibleFlag - makes the history window visible.
See Also:
LogTextFrame.setLogWindowVisible(boolean), setMsgFileLogging(java.lang.String, boolean, boolean)

setLogHistoryWindowVisible

static void setLogHistoryWindowVisible(boolean isVisibleFlag)
setLogHistoryWindowVisible() - make the popup window visible or invisible
Parameters:
isVisibleFlag - makes the message logging window visible.
See Also:
LogTextFrame.setLogWindowVisible(boolean), setHistoryFileLogging(java.lang.String, boolean, boolean)

saveCmdHistory

static void saveCmdHistory(java.lang.String msg)
saveCmdHistory() - print msg to showMsg1() and also save in command history and message logs if logging is enabled as well.
Parameters:
msg - is the command message to log
See Also:
saveCmdHistory(java.lang.String)

saveCmdHistory

static void saveCmdHistory(java.lang.String msg,
                           boolean doShowMsgFlag)
saveCmdHistory() - save msg in command history and message logs if logging is enabled.
Parameters:
msg - is the command message to log
doShowMsgFlag - if set is set, then print msg to showMsg1() as well.
See Also:
LogTextFrame.appendLogLn(java.lang.String), showMsg(java.lang.String)

saveMsgHistory

static void saveMsgHistory(java.lang.String msg,
                           boolean doShowMsgFlag)
saveMsgHistory() - save msg in message logs if logging is enabled. If doShowMsgFlag is set, then print msg to showMsg1().
Parameters:
msg - is the command message to log
isVisibleFlag - makes the message logging window visible.
See Also:
LogTextFrame.appendLogLn(java.lang.String), showMsg(java.lang.String)

showMsg

static void showMsg(java.lang.String msg)
showMsg() - print msg to showStatus() and to txtField1
Parameters:
msg - is the command message to show
See Also:
Applet.showStatus(java.lang.String), showMsg1(java.lang.String, java.awt.Color, java.awt.Color)

showMsg1

static void showMsg1(java.lang.String msg,
                     java.awt.Color fg,
                     java.awt.Color bg)
showMsg1() - print msg to showStatus() and to txtField1 and change color
Parameters:
msg - is the command message to show
fg - is foreground color
bg - is background color
See Also:
Applet.showStatus(java.lang.String), showMsg1(java.lang.String, java.awt.Color, java.awt.Color)

showMsg1

static void showMsg1(java.lang.String msg,
                     boolean saveTitleFlag,
                     java.awt.Color fg,
                     java.awt.Color bg)
showMsg1() - print msg to showStatus() and to txtField1 and change color
Parameters:
msg - is the command message to show
saveTitleFlag - to save the title(not used)
fg - is foreground color
bg - is background color
See Also:
LogTextFrame.appendLogLn(java.lang.String), Applet.showStatus(java.lang.String), showMsg1(java.lang.String, java.awt.Color, java.awt.Color)

showFeatures

static void showFeatures(java.lang.String genbankData,
                         java.lang.String genomicData)
showFeatures() - print features to txtField2 and txtField3
Parameters:
genbankData - is the msg2 data to show
genomicData - is the msg3 data to show
See Also:
showMsg2(java.lang.String), showMsg3(java.lang.String)

showMsg2

static void showMsg2(java.lang.String msg2)
showMsg2() - print msg2 to txtField2
Parameters:
msg2 - is the msg2 data to show
See Also:
showMsg2(java.lang.String)

showMsg2

static void showMsg2(java.lang.String msg2,
                     java.awt.Color fg,
                     java.awt.Color bg)
showMsg2() - print msg2 to txtField2 and change color
Parameters:
msg2 - is the command message to show
fg - is foreground color
bg - is background color
See Also:
LogTextFrame.appendLogLn(java.lang.String)

showMsg3

static void showMsg3(java.lang.String msg3)
showMsg3() - print msg3 to txtField3
Parameters:
msg3 - is the command message to show
See Also:
showMsg3(java.lang.String)

showMsg3

static void showMsg3(java.lang.String msg3,
                     java.awt.Color fg,
                     java.awt.Color bg)
showMsg3() - print msg3 to txtField3 ALSO: side effect of setting cursor to WAIT_CURSOR if the(fg,bg) is not(black,white).
Parameters:
msg3 - is the command message to show
fg - is foreground color
bg - is background color
See Also:
LogTextFrame.appendLogLn(java.lang.String)

popupAlertMsgLine

static void popupAlertMsgLine(java.lang.String msg)
popupAlertMsgLine) - popup ALERT message line and then timeout. Do a local timeout if localTimeoutMsec>0.
Parameters:
msg - is the command message to show
See Also:
PopupDialogQuery, PopupDialogQuery.alertTimeout(java.lang.String), showMsg(java.lang.String)

popupAlertMsg

static void popupAlertMsg(java.lang.String title,
                          java.lang.String msg,
                          int nRows,
                          int nCols)
popupAlertMsg() - popup alert message in a scrollable text area. If the timeoutMsec is >0, then close the window after this time.
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
See Also:
ShowStringPopup, ShowStringPopup.updateText(java.lang.String), sleepMsec(int)

popupDryrotMsgsAndQuit

static boolean popupDryrotMsgsAndQuit()
popupDryrotMsgsAndQuit() - if any dryrot, tell us and die...
Returns:
false if not quiting
See Also:
MAExplorer.quit(), ShowStringPopup, ShowStringPopup.updateText(java.lang.String), UserState.createMAEstartupFileStr(boolean), sleepMsec(int), showMsg2(java.lang.String)

rmvDupIMAGEstr

java.lang.String rmvDupIMAGEstr(java.lang.String str)
rmvDupIMAGEstr() - remove duplicate "IMAGE:xxxx:" prefix from string. This is a SPECIAL microarray I.M.A.G.E URL hack!!! If the string contains "IMAGE:IMAGE:" or "IMAGE:ATCC:" then slice out the first "IMAGE:"
Parameters:
str - I.M.A.G.E. id that may have extra "IMAGE:" string
Returns:
cleaned up string.

rmvIMAGEstr

java.lang.String rmvIMAGEstr(java.lang.String str)
rmvIMAGEstr() - - remove "IMAGE:" prefix from string. This is a SPECIAL microarray I.M.A.G.E URL hack!!! If the string contains "IMAGE:" remove it. If it contains "ATCC:", return null. else return the str.
Parameters:
str - I.M.A.G.E. id that may have "IMAGE:" or "ATCC:"
Returns:
cleaned up string

popupViewer

void popupViewer(java.net.URL urlBase,
                 java.lang.String fileIn,
                 java.lang.String windowName)
popupViewer() - popup a web browser for the help HTML file.
Parameters:
urlBase - is the base URL
fileIn - is the file to display
windowName - is the window to use if not null
See Also:
FileIO.logMsgln(java.lang.String), MAExplorer.logDRYROTerr(java.lang.String), showMsg(java.lang.String), showMsg2(java.lang.String), showMsg3(java.lang.String), displayURL(java.lang.String), rmvDupIMAGEstr(java.lang.String)

displayURL

boolean displayURL(java.lang.String url)
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.gif");
 displayURL("file:///user/joe/image.pdf");
 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.
Parameters:
url - to display in popup browser
Returns:
false if error.
See Also:
MAExplorer.logDRYROTerr(java.lang.String), showMsg2(java.lang.String), showMsg3(java.lang.String)

displayPDF

boolean 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
[TODO] Handle the Mac better.
Parameters:
pdfFile - file to display in Adobe Acrobat
Returns:
false if error.
See Also:
MAExplorer.logDRYROTerr(java.lang.String), showMsg2(java.lang.String), showMsg3(java.lang.String)

checkImagesDirExists

static boolean checkImagesDirExists()
checkImagesDirExists() - check if images directory exists
Returns:
true if MAE maeDir/Images/ subdirectory exists.

popupImageOfHPsample

boolean popupImageOfHPsample(MaHybridSample ms)
popupImageOfHPsample() - popup image of current gene in Web browser.
 Verify data exists before process:
    1) has Database_ID data corresponding to xxxx in images
    2) has maeDir/Images/xxxx.jpg,
Parameters:
ms - is the sample to display
Returns:
true if succeed
See Also:
MAExplorer.logDRYROTerr(java.lang.String), showMsg(java.lang.String), checkImagesDirExists(), displayURL(java.lang.String), popupViewer(java.net.URL, java.lang.String, java.lang.String), prepForFileURL(java.lang.String)

getCurDateStr

static java.lang.String getCurDateStr()
getCurDateStr() - return date string in the format of YYMMDDHHMMSS. Note: Adds "0" to first single digit if value is 1-9.

cvf2s

static java.lang.String cvf2s(float v,
                              int precision)
cvf2s() - convert float to string with precision # of digits. If precision > 0 then limit # of digits in fraction
Parameters:
v - is value to convert
i - is the # of digits precision in the mantissa
Returns:
string approximating "%0.pd" If abs(v) < pow(10.0,-p) then return "+0" or "-0"

cvd2s

static java.lang.String cvd2s(double v,
                              int precision)
cvd2s() - convert double to string with precision # of digits If precision > 0 then limit # of digits in fraction
Parameters:
v - is value to convert
i - is the # of digits precision in the mantissa
Returns:
string approximating "%0.pd" If abs(v) < pow(10.0,-p) then return "+0" or "-0"

cvs2d

static double cvs2d(java.lang.String str)
cvs2d() - convert String to double
Parameters:
str - to convert
Returns:
numeric value, else defaultFloat if bad string

cvs2d

static double cvs2d(java.lang.String str,
                    double defaultValue)
cvs2d() - convert String to double with default value
Parameters:
str - to convert
defaultValue - if bad numeric string
Returns:
numeric value

cvs2f

static float cvs2f(java.lang.String str)
cvs2f() - convert String to float
Parameters:
str - to convert
Returns:
numeric value, else defaultFloat if bad string

cvs2f

static float cvs2f(java.lang.String str,
                   float defaultValue)
cvs2f() - convert String to float with default value
Parameters:
str - to convert
defaultValue - if bad numeric string
Returns:
numeric value

cvs2i

static int cvs2i(java.lang.String str)
cvs2i() - convert String to int
Parameters:
str - to convert
Returns:
numeric value, else defaultInt if bad string

cvs2i

static int cvs2i(java.lang.String str,
                 int defaultValue)
cvs2i() - convert String to int with default value
Parameters:
str - to convert
defaultValue - if bad numeric string
Returns:
numeric value

cvs2iArray

static int[] cvs2iArray(java.lang.String str,
                        int maxExpected,
                        java.lang.String delimChr)
cvs2iArray() - convert String arg list "1,4,3,6,..." to int[]
Parameters:
str - string containt a list of Strings
maxExpected - # of numbers to be parsed
delimChr - delimiter to be used
Returns:
array of ints else null if problem

cvs2Array

static java.lang.String[] cvs2Array(java.lang.String str,
                                    int maxExpected,
                                    java.lang.String delimiterChr)
cvs2Array() - cvt arg list "1,4,3,6,..." to "," - delim String[]. If there are more than maxExpected number of args in string, ignore them and just return what has been parsed so far.
Parameters:
str - string containt a list of Strings
maxExpected - # of numbers to be parsed [DEPRICATED and ignored]
delimChr - delimiter to be used
Returns:
array of Strings else null if problem

cvtBackslash2Fwdslash

static java.lang.String cvtBackslash2Fwdslash(java.lang.String sInput)
cvtBackslash2Fwdslash() - convert '\\' to '/' in the string
Parameters:
sInput - is input string
return - converted string

addQuotesIfSpace

static java.lang.String addQuotesIfSpace(java.lang.String str)
addQuotesIfSpace() - add "..." around string if it contains a space but don't add quotes if it already has a leading ".
Parameters:
str - to convert
Returns:
converted string

dateStr

static java.lang.String dateStr()
dateStr() - return a new Date string of the current day and time
Returns:
a new Date string of the current day and time

timeStr

static java.lang.String timeStr()
timeStr() - return a new daytime HH:MM:SS string of the current time.
Returns:
a new daytime HH:MM:SS string of the current time

printCurrentMemoryUsage

static void printCurrentMemoryUsage(java.lang.String msg)
printCurrentMemoryUsage() - print: %free, total memory usage and timeOfday
Parameters:
msg - to display with this memory snapshot
See Also:
FileIO.logMsgln(java.lang.String), cvd2s(double, int), timeStr()

prepForFileURL

static java.lang.String prepForFileURL(java.lang.String str)
prepForFileURL() - map "\" to "/" chars in string to use for URL
Parameters:
string - to prep
Returns:
possibly remapped string

findIndexForKey

static int findIndexForKey(java.lang.String[] data,
                           java.lang.String key)
findIndexForKey() - lookup index of key in data[]. Get length from array and skip testing NULL fields.
Parameters:
data - is data to search
key - is key to use in searching data
Returns:
-1 if it is not found.

cvLongToHex

static java.lang.String cvLongToHex(long data)
cvLongToHex() - convert long to hex string

nextZoomMag

static int nextZoomMag(int val,
                       int maxVal)
nextZoomMag() - modulo 1X, 2X, 5X, 10X, 20X, 50X, 100X, 200X, 500X, 1000X
Parameters:
val - is the value to use in computing next zoom value mod maxVal
maxVal - is the maximum value to use
is - the next zoom value, else 1 if failed

setupColorSpectrumRange

static boolean setupColorSpectrumRange(java.awt.Color[] ratioColor,
                                       float[] ratioRange,
                                       int maxColors,
                                       boolean redIsZeroFlag)
setupColorSpectrumRange() - setup spectrumcolor map data range [0.0:1.0]. Delta is 1.0/(maxColors-1). If redIsZeroFlag, then RED is 0.0 else RED is 1.0. Note: maxColors MUST BE 9!!!! [TODO] setup Dichromasy colors.
Parameters:
ratioColor[is - the color mapping
ratioRange - is the color values
maxColors - is the size of arrays
redIsZeroFlag - set red as zero else red is 1.0
Returns:
true if ok.

setPseudoArrayRatioColorMap

static boolean setPseudoArrayRatioColorMap(java.awt.Color[] ratioColor,
                                           float[] ratioRange,
                                           int maxColors)
setPseudoArrayRatioColorMap() - set pseudoarray ratios color map data. The Ratio Color Map is used with the Ratio PseudoArray images.
Parameters:
ratioColor[is - the color mapping [0:MAX_COLORS-1]
ratioRange - is the ratio range values [0:MAX_COLORS-1]
Returns:
true if ok.

setPseudoArrayColorSpectrumMap

static boolean setPseudoArrayColorSpectrumMap(java.awt.Color[] spectrumColor,
                                              float[] spectrumRange)
setPseudoArrayColorSpectrumMap() - set pseudoarray color map spectrum data. The Spectrum Map is used with the p-value PseudoArray image.
Parameters:
spectrumColor - is the color mapping [0:MAX_COLORS-1]
spectrumRange - is the range value [0:MAX_COLORS-1].
maxColors - is the size of arrays
Returns:
true if ok.

setupColorRatioRange

static boolean setupColorRatioRange(float delta,
                                    java.awt.Color[] ratioColor,
                                    float[] ratioRange,
                                    int maxColors,
                                    boolean useNegRangeFlag)
setupColorRatioRange() - setup ratio color map iteratively w/spacing delta. Note the range is centerVal-midColor*delta to 1+maxColor*delta which maps from deep RED(min) to BLACK(1.0) to deep RED(max). Note: maxColors MUST BE 9!!!! If testing X/Y Ratio(useNegRangeFlag is FALSE): X/Y > 1 is RED X/Y < 1 is GREEN If testing X-Y Zscore(useNegRangeFlag is TRUE): X-Y > 0 is RED X-Y < 0 is GREEN [TODO] 1. make it work correctly with clusterGram 2. add additive color map RED+GREEN = YELLOW and if saturated then it is WHITE.
Parameters:
delta - is the difference between color values computed
ratioColor - is the color mapping
ratioRange - is the color values
maxColors - is the size of arrays
useNegRangeFlag - allow negative range values
Returns:
true if ok.

setRatioColor

static java.awt.Color setRatioColor(float ratio,
                                    java.awt.Color[] ratioColor,
                                    float[] ratioRange,
                                    int maxColors)
setRatioColor() - map data ratio to color in current color scheme Color is in(ratioMin : ratioMax]. i.e. ratioMin < ratio <= ratioMax for ratio < ratioRange[midColor], and ratioMin <= ratio < ratioMax for ratio >ratioRange[midColor].
Parameters:
ratio - is the value to map
ratioColor - is the color mapping
ratioRange - is the color values
maxColors - is the size of arrays
Returns:
color else if failed, return ratioColor[maxColors].

cvFontS2I

static int cvFontS2I(java.lang.String fontSizeStr)
cvFontS2I() - convert font size "8Ppt", "10pt", "12pt", or "14pt" to int
Parameters:
fontSizeStr - is the string name of the font size
Returns:
integer value of font size

cvtStrArrayToStr

static java.lang.String cvtStrArrayToStr(java.lang.String[] strData,
                                         int len)
cvtStrArrayToStr() - create(String) from String[] array with "\n" w/len Fast method creates a tmp Character [] of required size and stuffs it, then converts it to a string at one time instead of repeatedly using concat(i.e. +=).
Parameters:
strData - is array of strings
len - is size of array of string(could be less thatn strData.length)
Returns:
single '\n' separated string

cvtStrArrayToStr

static java.lang.String cvtStrArrayToStr(java.lang.String[] strData)
cvtStrArrayToStr() - create(String) from String[] array with "\n"
Parameters:
strData - is array of strings
Returns:
single '\n' separated string
See Also:
cvtStrArrayToStr(java.lang.String[], int)

cvtStrArrayToStr

static java.lang.String cvtStrArrayToStr(java.lang.String[] strData,
                                         java.lang.String delim,
                                         java.lang.String terminator)
cvtStrArrayToDelimStr() - create delimited(String) from String[] array with terminator as last character.
Parameters:
strData - is array of strings
delim - is the delimiter to use
terminator - is the end of string terminator to use
Returns:
delimited string

cvtValueToStars

static java.lang.String cvtValueToStars(float val,
                                        float valMax,
                                        int maxStars,
                                        boolean rightFillFlag)
cvtValueToStars() - cvt val in[0:valMax] to "****"+" " string where the maximum # of stars for v==vMax is specified. The rest of the string is filled with spaces. maxStars is clipped at 30.
Parameters:
val - is value to be converted to starts
valMax - is maximum value expected
maxStars - is max # of stars to use for largest value
rightFillFlag - if true will right fill the string with spaces
Returns:
list of "*********"

cvtSpacesToUnderscores

static 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
 
Parameters:
str - to be converted
Returns:
converted string

chkDirFinalSeparator

static java.lang.String chkDirFinalSeparator(java.lang.String sPath,
                                             java.lang.String fS)
chkDirFinalSeparator() - make dir path end in fileSeparator. Note: Mac Bug found and fixed by Jai Evans 10/12/00.
Parameters:
sPath - is the path to chk
fS - is the file separator
Returns:
directory path at end of file separator

getRatioStr

static java.lang.String getRatioStr()
getRatioStr() - get "F1/F2", "Cy3/Cy5" or "Cy5/Cy3", etc. string. Analyze the mae.useRatioDataFlag and mae.useCy5OverCy3Flag
Returns:
the new string and set it into mae.reportRatioStr.

rmvFinalSubDirectory

public static java.lang.String rmvFinalSubDirectory(java.lang.String dirStr,
                                                    java.lang.String optDir,
                                                    boolean chkMAEtreeFlag)
rmvFinalSubDirectory() - remove trailing ".../dir/" if it exists otherwise return original string. If remove the sub directory and optDir is not null, then add it back with a delimiter.
Parameters:
dirStr - is path to edit
optDir - is optional directory to add
chkMAEtreeFlag - also check MAE tree validity and make it if needed
Returns:
final subdirectory

cvtEnvPaths2Properties

static boolean cvtEnvPaths2Properties()
cvtEnvPaths2Properties() - get all system ENV variables and set them as separate Java properties so we can get them individually from System.getProperty(var) calls.
Returns:
true if succeed

cvFileNameWithMod

static java.lang.String cvFileNameWithMod(java.lang.String fileName,
                                          java.lang.String mod)
cvFileNameWithMod() - insert modifier string before file extension
Parameters:
fileName - (with file extension)
mod - to insert before file extension
Returns:
new file name

sleepMsec

static void sleepMsec(int sleepMsec)
sleepMsec() - sleep nMsec where nMsec must be >= 0 milliseconds.
Parameters:
sleepMsec - # of milliseconds to sleep

rmvRtnChars

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

cleanup

void cleanup()
cleanup() - cleanup global static allocated variables in this class If statics are added later to this class, then set them to null here.