halo.userinterface.gui.tools
Class Tools

java.lang.Object
  extended by halo.userinterface.gui.tools.Tools

public class Tools
extends java.lang.Object

Class containing several tools used for the graphical user interface

Author:
Stefanie Kaufmann

Constructor Summary
Tools()
           
 
Method Summary
static java.lang.String alignLabel(java.lang.String txt, int width, java.awt.FontMetrics fm)
          Formats a text for a dialog window
static double calculateMedianForHalfLives(double time, Data data, CorrectionFactors corr)
          Calculates the average median over all three available half-life calculation methods
static java.io.File displaySaveDialog(java.awt.Component comp, java.lang.String text, javax.swing.filechooser.FileFilter filter)
          Displays a dialog that asks the user if he wants to save something into a file
static java.util.ArrayList<java.lang.String> getColumnLabels(java.io.File file)
          Reads the header/description line of a given file and provides all column labels (columns separated by tabulator) as a list
static boolean hasLineColumns(java.lang.String line, int columns)
          Checks whether a line consists of at least the given number of columns, whereas columns are separated through any whitespace sign
static boolean isLineValid(java.lang.String line)
          Tests if a given line is composed of the letters a-z (case ignored), numbers or whitespace symbols like TAB
static boolean testValidityForFile(java.io.File file, int columns, boolean permitUnusualLetters)
          Tests the correctness of a given file according to format (= minimal number of columns has to be correct) and letters (= are there any unusual letters present?)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tools

public Tools()
Method Detail

getColumnLabels

public static java.util.ArrayList<java.lang.String> getColumnLabels(java.io.File file)
Reads the header/description line of a given file and provides all column labels (columns separated by tabulator) as a list

Parameters:
file - The file containing the expression data
Returns:
A list containing all column labels

isLineValid

public static boolean isLineValid(java.lang.String line)
Tests if a given line is composed of the letters a-z (case ignored), numbers or whitespace symbols like TAB

Parameters:
line - The line that will be tested
Returns:
TRUE if the line is valid, FALSE otherwise

hasLineColumns

public static boolean hasLineColumns(java.lang.String line,
                                     int columns)
Checks whether a line consists of at least the given number of columns, whereas columns are separated through any whitespace sign

Parameters:
line - The line that will be checked for validity
columns - The minimal number of columns that has to be in this line
Returns:
TRUE if the line consists of this many columns or more

testValidityForFile

public static boolean testValidityForFile(java.io.File file,
                                          int columns,
                                          boolean permitUnusualLetters)
Tests the correctness of a given file according to format (= minimal number of columns has to be correct) and letters (= are there any unusual letters present?) according to the first line after the commentary

Parameters:
file - The input file that will be tested
columns - The minimal number of columns that has to be present in the file
Returns:
TRUE if the file is valid

alignLabel

public static java.lang.String alignLabel(java.lang.String txt,
                                          int width,
                                          java.awt.FontMetrics fm)
Formats a text for a dialog window

Parameters:
txt - The original text
width - The width of the line
fm - The font metrics
Returns:
The formatted text

displaySaveDialog

public static java.io.File displaySaveDialog(java.awt.Component comp,
                                             java.lang.String text,
                                             javax.swing.filechooser.FileFilter filter)
Displays a dialog that asks the user if he wants to save something into a file

Parameters:
comp - The mother component
text - The text of the dialog
filter - The file filter for the output file
Returns:
The file that has been chosen

calculateMedianForHalfLives

public static double calculateMedianForHalfLives(double time,
                                                 Data data,
                                                 CorrectionFactors corr)
Calculates the average median over all three available half-life calculation methods

Parameters:
time - The labeling time for the calculations
data - The data
corr - The correction factors from normalization
Returns:
The average median