Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.util
Class GuiUtils

java.lang.Object
  extended by net.java.sip.communicator.util.GuiUtils

public class GuiUtils
extends Object

The StringUtils class is used through this ui implementation for some special operations with strings.

Author:
Yana Stamcheva, Lyubomir Marinov, Adam Netocny

Field Summary
static long MILLIS_PER_DAY
          Number of milliseconds in a standard day.
static long MILLIS_PER_HOUR
          Number of milliseconds in a standard hour.
static long MILLIS_PER_MINUTE
          Number of milliseconds in a standard minute.
static long MILLIS_PER_SECOND
          Number of milliseconds in a second.
 
Constructor Summary
GuiUtils()
           
 
Method Summary
static void addWindow(Window w)
          Adds a Window into window list
static int compareDates(Date date1, Date date2)
          Compares the two dates.
static int compareDates(long date1, long date2)
          Compares the two dates.
static int compareDatesOnly(long date1, long date2)
          Compares the two dates.
static int countOccurrences(String text, char needle)
          Counts occurrences of the needle character in the given text.
static String formatDate(Date date)
          Formats the given date.
static String formatDate(long date)
          Formats the given date.
static void formatDate(long date, StringBuffer dateStrBuf)
          Formats the given date as: Month DD, YYYY and appends it to the given dateStrBuf string buffer.
static String formatSeconds(long millis)
          Formats the given long to X hour, Y min, Z sec.
static String formatTime(Date date)
          Formats the time for the given date.
static String formatTime(Date startDate, Date endDate)
          Formats the time period duration for the given start date and end date.
static String formatTime(long time)
          Formats the time for the given date.
static String formatTime(long start, long end)
          Formats the time period duration for the given start date and end date.
static int getComponentIndex(Component c, Container container)
          Returns the index of the given component in the given container.
static Rectangle2D getDefaultStringSize(String text)
          Returns the bounds of the given string.
static Dimension getStringSize(Component c, String text)
          Returns the size of the given text computed towards to the given component.
static int getStringWidth(Component c, String text)
          Returns the width in pixels of a text.
static Window[] getWindows()
          Returns an array of all Windows, both owned and ownerless, created by this application.
static void removeWindow(Window w)
          Removes a Window into window list
static String replaceSpecialRegExpChars(String text)
          Replaces some chars that are special in a regular expression.
static void updateComponentTreeUI(Component c)
          A simple minded look and feel change: ask each node in the tree to updateUI() -- that is, to initialize its UI property with the current look and feel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MILLIS_PER_SECOND

public static final long MILLIS_PER_SECOND
Number of milliseconds in a second.

See Also:
Constant Field Values

MILLIS_PER_MINUTE

public static final long MILLIS_PER_MINUTE
Number of milliseconds in a standard minute.

See Also:
Constant Field Values

MILLIS_PER_HOUR

public static final long MILLIS_PER_HOUR
Number of milliseconds in a standard hour.

See Also:
Constant Field Values

MILLIS_PER_DAY

public static final long MILLIS_PER_DAY
Number of milliseconds in a standard day.

See Also:
Constant Field Values
Constructor Detail

GuiUtils

public GuiUtils()
Method Detail

replaceSpecialRegExpChars

public static String replaceSpecialRegExpChars(String text)
Replaces some chars that are special in a regular expression.

Parameters:
text - The initial text.
Returns:
the formatted text

getStringWidth

public static int getStringWidth(Component c,
                                 String text)
Returns the width in pixels of a text.

Parameters:
c - the component where the text is contained
text - the text to measure
Returns:
the width in pixels of a text.

getStringSize

public static Dimension getStringSize(Component c,
                                      String text)
Returns the size of the given text computed towards to the given component.

Parameters:
c - the component where the text is contained
text - the text to measure
Returns:
the dimensions of the text

getDefaultStringSize

public static Rectangle2D getDefaultStringSize(String text)
Returns the bounds of the given string.

Parameters:
text - the string to measure
Returns:
the bounds of the given string

countOccurrences

public static int countOccurrences(String text,
                                   char needle)
Counts occurrences of the needle character in the given text.

Parameters:
text - the text in which we search
needle - the character we're looking for
Returns:
the count of occurrences of the needle chat in the given text

compareDates

public static int compareDates(Date date1,
                               Date date2)
Compares the two dates. The comparison is based only on the day, month and year values. Returns 0 if the two dates are equals, a value < 0 if the first date is before the second one and > 0 if the first date is after the second one.

Parameters:
date1 - the first date to compare
date2 - the second date to compare with
Returns:
Returns 0 if the two dates are equals, a value < 0 if the first date is before the second one and > 0 if the first date is after the second one

compareDates

public static int compareDates(long date1,
                               long date2)
Compares the two dates. The comparison is based only on the day, month and year values. Returns 0 if the two dates are equals, a value < 0 if the first date is before the second one and > 0 if the first date is after the second one.

Parameters:
date1 - the first date to compare
date2 - the second date to compare with
Returns:
Returns 0 if the two dates are equals, a value < 0 if the first date is before the second one and > 0 if the first date is after the second one

compareDatesOnly

public static int compareDatesOnly(long date1,
                                   long date2)
Compares the two dates. The comparison is based only on the day, month and year values. Returns 0 if the two dates are equals, a value < 0 if the first date is before the second one and > 0 if the first date is after the second one.

Parameters:
date1 - the first date to compare
date2 - the second date to compare with
Returns:
Returns 0 if the two dates are equals, a value < 0 if the first date is before the second one and > 0 if the first date is after the second one

formatDate

public static String formatDate(Date date)
Formats the given date. The result format is the following: [Month] [Day], [Year]. For example: Dec 24, 2000.

Parameters:
date - the date to format
Returns:
the formatted date string

formatDate

public static String formatDate(long date)
Formats the given date. The result format is the following: [Month] [Day], [Year]. For example: Dec 24, 2000.

Parameters:
date - the date to format
Returns:
the formatted date string

formatDate

public static void formatDate(long date,
                              StringBuffer dateStrBuf)
Formats the given date as: Month DD, YYYY and appends it to the given dateStrBuf string buffer.

Parameters:
date - the date to format
dateStrBuf - the StringBuffer, where to append the formatted date

formatTime

public static String formatTime(Date date)
Formats the time for the given date. The result format is the following: [Hour]:[Minute]:[Second]. For example: 12:25:30.

Parameters:
date - the date to format
Returns:
the formatted hour string

formatTime

public static String formatTime(long time)
Formats the time for the given date. The result format is the following: [Hour]:[Minute]:[Second]. For example: 12:25:30.

Parameters:
time - the date to format
Returns:
the formatted hour string

formatTime

public static String formatTime(Date startDate,
                                Date endDate)
Formats the time period duration for the given start date and end date. The result format is the following: [Hour]:[Minute]:[Second]. For example: 12:25:30.

Parameters:
startDate - the start date
endDate - the end date
Returns:
the formatted hour string

formatTime

public static String formatTime(long start,
                                long end)
Formats the time period duration for the given start date and end date. The result format is the following: [Hour]:[Minute]:[Second]. For example: 12:25:30.

Parameters:
start - the start date in milliseconds
end - the end date in milliseconds
Returns:
the formatted hour string

formatSeconds

public static String formatSeconds(long millis)
Formats the given long to X hour, Y min, Z sec.

Parameters:
millis - the time in milliseconds to format
Returns:
the formatted seconds

getWindows

public static Window[] getWindows()
Returns an array of all Windows, both owned and ownerless, created by this application. If called from an applet, the array includes only the Windows accessible by that applet.

Warning: this method may return system created windows, such as a print dialog. Applications should not assume the existence of these dialogs, nor should an application assume anything about these dialogs such as component positions, LayoutManagers or serialization.

Returns:
Returns an array of all Windows.

addWindow

public static void addWindow(Window w)
Adds a Window into window list

Parameters:
w - Window to be added.

removeWindow

public static void removeWindow(Window w)
Removes a Window into window list

Parameters:
w - Window to be removed.

updateComponentTreeUI

public static void updateComponentTreeUI(Component c)
A simple minded look and feel change: ask each node in the tree to updateUI() -- that is, to initialize its UI property with the current look and feel.

Parameters:
c - UI component.

getComponentIndex

public static int getComponentIndex(Component c,
                                    Container container)
Returns the index of the given component in the given container.

Parameters:
c - the Component to look for
container - the parent container, where this component is added
Returns:
the index of the component in the container or -1 if no such component is contained in the container

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.