com.metamatrix.console.util
Class StaticUtilities

java.lang.Object
  extended by com.metamatrix.console.util.StaticUtilities

public class StaticUtilities
extends java.lang.Object

Class containing miscellaneous useful static utility methods.


Field Summary
static int MAX_MODAL_DIALOG_TEXT_WIDTH
           
static int PREFERRED_MODAL_DIALOG_TEXT_WIDTH
           
 
Constructor Summary
StaticUtilities()
           
 
Method Summary
static java.util.Vector arrayToVector(java.lang.Object[] array)
           
static java.awt.Color averageRGBVals(java.awt.Color[] colors)
          Return the average color of an array of colors.
static java.awt.Point centerFrame(java.awt.Dimension frameSize)
          Version of centerFrame() (above) to get the screen size itself.
static java.awt.Point centerFrame(java.awt.Dimension frameSize, java.awt.Dimension screenSize)
          Return a Point at which a frame should be located to center it on the screen, given the frame size and the screen size.
static java.lang.String deleteChar(java.lang.String sSource, char charToRemove)
          Drop any occurrences of the indicated character from the String provided, and return the resulting String.
static java.util.List descendantsOfComponent(java.awt.Component startComp)
          Return a List, not necessarily in any particular order, of all descendant Components of a Component.
static void disableComponents(java.awt.Container ct)
           
static void displayModalDialogWithOK(java.awt.Component parent, java.lang.String header, java.lang.String msg)
          Display a modal dialog with an 'OK' button.
static void displayModalDialogWithOK(java.awt.Component parent, java.lang.String header, java.lang.String msg, int messageType)
          Display a modal dialog with an 'OK' button.
static void displayModalDialogWithOK(java.lang.String hdr, java.lang.String msg)
          Display a modal dialog with an 'OK' button.
static void displayModalDialogWithOK(java.lang.String hdr, java.lang.String msg, int messageType)
          Display a modal dialog with an 'OK' button.
static java.util.Vector doubleArrayToVector(java.lang.Object[][] array)
           
static void endWait()
           
static void endWait(java.awt.Component childComponent)
          Clear the wait cursor on the frame that contains the specified childComponent
static java.text.SimpleDateFormat getDefaultDateFormat()
           
static java.lang.String getDirectoryName(java.lang.String fullFileName)
           
static java.lang.String getFileName(java.lang.String fullFileName)
           
static java.lang.String[] getLineBreakSubstrings(java.lang.String str)
          Return the segments of a string that are between linebreaks in the input string.
static int greatestCommonDivisor(int[] array)
          Return the greatest common divisor of an array of positive integers.
static java.lang.String insertLineBreaks(java.lang.String str, int preferredMaxLineLen, int maxMaxLineLen)
          Insert linefeed characters into an input string such that the resulting string has no segments more than maxLineLen characters in length, and strings are never broken within a word (unless this is unavoidable because a word occupies more than a whole line).
static java.util.Collection intersectionOf(java.util.Collection collections)
          Return a Collection representing the intersection of given Collections.
static void invokeAndWaitSafe(java.lang.Runnable runnable)
          Invoke the specified operation in the Swing thread, and wait until it completes.
static void invokeLaterSafe(java.lang.Runnable runnable)
          Invoke the specified operation in the Swing thread, and don't necessarily wait until it completes.
static boolean isShowingWaitCursor()
           
static void jiggleSplitter(javax.swing.JSplitPane splitPane)
          Attempt to force a repaint on a split pane by moving the splitter by one pixel and then back again.
static int leastCommonMultiple(int[] array)
          Return the least common multiple of an array of integers.
static int longestNonBlankStringSegment(java.lang.String str)
          Return the longest segment between blanks within a String.
static java.lang.String parseDelimitedStringGetRight(java.lang.String sTheString, java.lang.String sDelim)
           
static int[] primeFactors(int num)
          Return the prime factors of a number.
static java.lang.String roundToNumDecimalPlaces(double inputVal, int numDecPlaces)
          / Returns a string representing a value rounded to a given number of decimal places.
static void setDateFormat(java.lang.String format)
           
static void startWait()
           
static void startWait(java.awt.Component childComponent)
          Start the wait cursor on the frame that contains the specified childComponent
static java.lang.String[] tokenize(java.lang.String str)
          Return an array of tokens in a String.
static java.util.Collection unionOf(java.util.Collection collections)
          Return a Collection representing the union of given Collections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFERRED_MODAL_DIALOG_TEXT_WIDTH

public static final int PREFERRED_MODAL_DIALOG_TEXT_WIDTH
See Also:
Constant Field Values

MAX_MODAL_DIALOG_TEXT_WIDTH

public static final int MAX_MODAL_DIALOG_TEXT_WIDTH
See Also:
Constant Field Values
Constructor Detail

StaticUtilities

public StaticUtilities()
Method Detail

roundToNumDecimalPlaces

public static java.lang.String roundToNumDecimalPlaces(double inputVal,
                                                       int numDecPlaces)
/ Returns a string representing a value rounded to a given number of decimal places. / Example : roundToNumDecimalPlaces(Math.PI, 4) would return "3.1416". Trailing zeroes / are always included. / numDecPlaces argument must be from 0 to 10, returns null if not.


centerFrame

public static java.awt.Point centerFrame(java.awt.Dimension frameSize,
                                         java.awt.Dimension screenSize)
Return a Point at which a frame should be located to center it on the screen, given the frame size and the screen size.


centerFrame

public static java.awt.Point centerFrame(java.awt.Dimension frameSize)
Version of centerFrame() (above) to get the screen size itself.


insertLineBreaks

public static java.lang.String insertLineBreaks(java.lang.String str,
                                                int preferredMaxLineLen,
                                                int maxMaxLineLen)
Insert linefeed characters into an input string such that the resulting string has no segments more than maxLineLen characters in length, and strings are never broken within a word (unless this is unavoidable because a word occupies more than a whole line).

Parameters:
str - input String
int - preferredMaxLineLen preferred maximum allowable length of any segment in the string without inserting linebreaks
int - maxMaxLineLen absolute maximum allowable length of any segment in the string without inserting linebreeaks
Returns:
String the modified String

getLineBreakSubstrings

public static java.lang.String[] getLineBreakSubstrings(java.lang.String str)
Return the segments of a string that are between linebreaks in the input string. The linebreaks themselves are not included in any of the substrings.


displayModalDialogWithOK

public static void displayModalDialogWithOK(java.awt.Component parent,
                                            java.lang.String header,
                                            java.lang.String msg,
                                            int messageType)
Display a modal dialog with an 'OK' button.


displayModalDialogWithOK

public static void displayModalDialogWithOK(java.awt.Component parent,
                                            java.lang.String header,
                                            java.lang.String msg)
Display a modal dialog with an 'OK' button.


displayModalDialogWithOK

public static void displayModalDialogWithOK(java.lang.String hdr,
                                            java.lang.String msg,
                                            int messageType)
Display a modal dialog with an 'OK' button.


displayModalDialogWithOK

public static void displayModalDialogWithOK(java.lang.String hdr,
                                            java.lang.String msg)
Display a modal dialog with an 'OK' button.


setDateFormat

public static void setDateFormat(java.lang.String format)

getDefaultDateFormat

public static java.text.SimpleDateFormat getDefaultDateFormat()

longestNonBlankStringSegment

public static int longestNonBlankStringSegment(java.lang.String str)
Return the longest segment between blanks within a String. If the String is null, returns -1.


tokenize

public static java.lang.String[] tokenize(java.lang.String str)
Return an array of tokens in a String.


deleteChar

public static java.lang.String deleteChar(java.lang.String sSource,
                                          char charToRemove)
Drop any occurrences of the indicated character from the String provided, and return the resulting String.


descendantsOfComponent

public static java.util.List descendantsOfComponent(java.awt.Component startComp)
Return a List, not necessarily in any particular order, of all descendant Components of a Component. Will use getContentPane() for JFrames and JDialogs. The Component itself is included as the first entry in the list.


primeFactors

public static int[] primeFactors(int num)
Return the prime factors of a number. If the number is <= 1, return only the number itself. Should not be used with very large numbers.


intersectionOf

public static java.util.Collection intersectionOf(java.util.Collection collections)
Return a Collection representing the intersection of given Collections.


unionOf

public static java.util.Collection unionOf(java.util.Collection collections)
Return a Collection representing the union of given Collections.


greatestCommonDivisor

public static int greatestCommonDivisor(int[] array)
Return the greatest common divisor of an array of positive integers. If any of the values is not positive, returns -1.


leastCommonMultiple

public static int leastCommonMultiple(int[] array)
Return the least common multiple of an array of integers. If any integer is <= 0, returns -1.


jiggleSplitter

public static void jiggleSplitter(javax.swing.JSplitPane splitPane)
Attempt to force a repaint on a split pane by moving the splitter by one pixel and then back again.


startWait

public static void startWait(java.awt.Component childComponent)
Start the wait cursor on the frame that contains the specified childComponent


startWait

public static void startWait()

endWait

public static void endWait(java.awt.Component childComponent)
Clear the wait cursor on the frame that contains the specified childComponent


endWait

public static void endWait()

isShowingWaitCursor

public static boolean isShowingWaitCursor()

averageRGBVals

public static java.awt.Color averageRGBVals(java.awt.Color[] colors)
Return the average color of an array of colors.


disableComponents

public static void disableComponents(java.awt.Container ct)

getFileName

public static java.lang.String getFileName(java.lang.String fullFileName)

getDirectoryName

public static java.lang.String getDirectoryName(java.lang.String fullFileName)

parseDelimitedStringGetRight

public static java.lang.String parseDelimitedStringGetRight(java.lang.String sTheString,
                                                            java.lang.String sDelim)

arrayToVector

public static java.util.Vector arrayToVector(java.lang.Object[] array)

doubleArrayToVector

public static java.util.Vector doubleArrayToVector(java.lang.Object[][] array)

invokeAndWaitSafe

public static void invokeAndWaitSafe(java.lang.Runnable runnable)
                              throws java.lang.Throwable
Invoke the specified operation in the Swing thread, and wait until it completes. If the current thread is the Swing thread, it executes the operation in the current thread. If the current thread is not the Swing thread, it calls SwingUtilities.invokeAndWait().

Parameters:
runnable -
Throws:
Execption
java.lang.Throwable
Since:
4.3

invokeLaterSafe

public static void invokeLaterSafe(java.lang.Runnable runnable)
Invoke the specified operation in the Swing thread, and don't necessarily wait until it completes. If the current thread is the Swing thread, it executes the operation in the current thread.. If the current thread is not the Swing thread, it calls SwingUtilities.invokeLater().

Parameters:
runnable -
Throws:
Execption
Since:
4.3


Copyright © 2009. All Rights Reserved.