com.compomics.util
Class Util

java.lang.Object
  extended by com.compomics.util.Util

public class Util
extends Object

Includes general help methods that are used by the other classes.

Author:
Harald Barsnes

Constructor Summary
Util()
           
 
Method Summary
static String color2Hex(Color color)
          Converts a color to hex format for use in HTML tags.
static boolean deleteDir(File dir)
          Deletes all files and subdirectories under dir.
static String getFileName(String filePath)
          An OS independent getName alternative.
static double getPpmError(double theoreticalMzValue, double massError)
          Returns the ppm value of the given mass error relative to its theoretical m/z value.
static double roundDouble(double d, int places)
          Rounds a double value to the wanted number of decimalplaces.
static String tableToText(JTable table, String separator, ProgressDialogX progressDialog, boolean removeHtml)
          Returns the table as a separated text file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

roundDouble

public static double roundDouble(double d,
                                 int places)
Rounds a double value to the wanted number of decimalplaces.

Parameters:
d - the double to round of
places - number of decimal places wanted
Returns:
double - the new double

deleteDir

public static boolean deleteDir(File dir)
Deletes all files and subdirectories under dir. Returns true if all deletions were successful. If a deletion fails, the method stops attempting to delete and returns false.

Parameters:
dir -
Returns:
rue if all deletions were successful

getPpmError

public static double getPpmError(double theoreticalMzValue,
                                 double massError)
Returns the ppm value of the given mass error relative to its theoretical m/z value.

Parameters:
theoreticalMzValue - the theoretical mass
massError - the mass error
Returns:
the mass error as a ppm value relative to the theoretical mass

color2Hex

public static String color2Hex(Color color)
Converts a color to hex format for use in HTML tags.

Parameters:
color - the color to convert
Returns:
the color in hex format

getFileName

public static String getFileName(String filePath)
An OS independent getName alternative. Useful if the path is provided as a hardcoded string and opened in a different OS.

Parameters:
filePath - the file path as a string
Returns:
the file name, or the complete path of no file name is detected

tableToText

public static String tableToText(JTable table,
                                 String separator,
                                 ProgressDialogX progressDialog,
                                 boolean removeHtml)
Returns the table as a separated text file.

Parameters:
table - the table to turn in to text
separator - the text separator
progressDialog - the progress dialog
removeHtml - if true, html is converted to text
Returns:
the table as a separated text file


Copyright © 2011. All Rights Reserved.