    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class jclass.bwt.BWTUtil

    java.lang.Object
       |
       +----jclass.bwt.BWTUtil

public class BWTUtil
extends Object

Various static utility routines.

##

CENTER
images
  Table of double-buffer images for each thread.
LEFT
RIGHT

##

BWTUtil()

##

brighter(Color)
  Calculates the color even when it is saturated, for example, when it is black or white.
copyList(boolean[], int, boolean)
  Returns a lengthened copy of a list.
copyList(int[], int, int)
  Returns a lengthened copy of a list.
copyList(Object[], int, Object)
  Returns a lengthened copy of a list.
countChar(char[], int, char, int, int)
  Counts the occurrences of the char between start and end-1.
countChar(String, char, int, int)
  Counts the occurrences of the char between start and end-1.
darker(Color)
  Calculates the color even when it is saturated, for example, when it is black or white.
draw(Component, Graphics, Object, int, Rectangle)
  Draws the value as a String, JCString or Image.
drawDashedLine(Graphics, int, int, int, int)
  Draws a dashed line.
drawDashedRect(Graphics, int, int, int, int)
  Draws a dashed rectangle.
getApplet(Component)
  Follows the component's parents until a parent applet is found.
getAppletContext(Applet)
  Gets the component's applet's context.
getBrowser()
  Returns an int corresponding to the "browser" System property:

       BWTEnum.BROWSER_APPLETVIEWER    AppletViewer
       BWTEnum.BROWSER_EXPLORER        MS Internet Explorer
       BWTEnum.BROWSER_INTERPRETER     Running as a mainline
       BWTEnum.BROWSER_NETSCAPE        Netscape Navigator
       BWTEnum.BROWSER_OTHER           Other

getFrame(Component)
  Gets the component's parent frame.
getHeight(Object, Component)
  Gets the value's height using the component's font.
getHeight(Object, Component, Font)
  Gets the value's height using the specified font.
getJavaVersion()
  Returns an int corresponding to the "java.version" System property:

       JDK 1.0.2   102
       JDK 1.1.0   110

getNumLines(Object)
  Gets the number of newlines in the value.
getOS()
  Returns an int corresponding to the "os.name" System property: BWTEnum.OS_UNIX or OS_OTHER
getVisibleScreenLoc(Component, int, int, int, int)
  Returns the position that ensures that the component is visible on the screen.
getWidth(Object, Component)
  Gets the value's width using the component's font.
getWidth(Object, Component, Font)
  Gets the value's width using the specified font.
getWidth(Vector, JCMultiColumnInterface)
  Gets the total width of all the vector's elements.
inBrowser(Component)
  Returns true if the component is in an applet in a browser (ie its AppletContext is not null).
instanceOf(Object, String)
  Returns true if one of the object's superclasses' names contains the string
intersects(Component, int, int, int, int)
  Checks whether the rectangle intersects the component.
isParent(Component, Component)
  Returns true if the container is equal to the component, or is its parent or grandparent.
toHorizAlignment(int)
  Gets the horizontal component of an alignment.
trace()
  DEBUG
translateFromParent(Container, Component, int, int)
  Translates a point in a parent's co-ordinate system to its child's.
translateToParent(Container, Component, int, int)
  Translates a point in a child's co-ordinate system to its parent's.
wallPaper(Component, Graphics, Image)
  Draws the image repeatedly across the component, from left to right and top to bottom.

##

images

      protected static Hashtable images

  Table of double-buffer images for each thread.

LEFT

      public final static int LEFT

CENTER

      public final static int CENTER

RIGHT

      public final static int RIGHT

##

BWTUtil

      public BWTUtil()

##

copyList

      public final static Object[] copyList(Object list[],
                                            int len,
                                            Object def)

  Returns a lengthened copy of a list.

  Parameters:
    list - list to be lengthened
    def - default value for new items
    len - the desired new length. If the list's length is less than or equal to this value, the list is simply returned

copyList

      public final static int[] copyList(int list[],
                                         int len,
                                         int def)

  Returns a lengthened copy of a list.

  Parameters:
    list - list to be lengthened
    def - default value for new items
    len - the desired new length. If the list's length is less than or equal to this value, the list is simply returned

copyList

      public final static boolean[] copyList(boolean list[],
                                             int len,
                                             boolean def)

  Returns a lengthened copy of a list.

  Parameters:
    list - list to be lengthened
    def - default value for new items
    len - the desired new length. If the list's length is less than or equal to this value, the list is simply returned

intersects

      public final static boolean intersects(Component comp,
                                             int x,
                                             int y,
                                             int w,
                                             int h)

  Checks whether the rectangle intersects the component.

countChar

      public static int countChar(String s,
                                  char c,
                                  int start,
                                  int end)

  Counts the occurrences of the char between start and end-1.

countChar

      public static int countChar(char array[],
                                  int array_len,
                                  char c,
                                  int start,
                                  int end)

  Counts the occurrences of the char between start and end-1.

translateToParent

      public static Point translateToParent(Container parent,
                                            Component child,
                                            int x,
                                            int y)

  Translates a point in a child's co-ordinate system to its parent's.

  Parameters:
    parent - a parent or grandparent of the child
    x,y - co-ordinates in child's system

translateFromParent

      public static Point translateFromParent(Container parent,
                                              Component child,
                                              int x,
                                              int y)

  Translates a point in a parent's co-ordinate system to its child's.

  Parameters:
    parent - a parent or grandparent of the child
    x,y - co-ordinates in parent's system

getVisibleScreenLoc

      public static Point getVisibleScreenLoc(Component comp,
                                              int x,
                                              int y,
                                              int w,
                                              int h)

  Returns the position that ensures that the component is visible on the screen.

  Parameters:
    x,y - component's location
    w,h - component's size

getFrame

      public static Frame getFrame(Component comp)

  Gets the component's parent frame.

getApplet

      public static Applet getApplet(Component comp)

  Follows the component's parents until a parent applet is found. Returns null if no applet is found.

getAppletContext

      public static AppletContext getAppletContext(Applet applet)

  Gets the component's applet's context. The applet context lets an applet control the applet's environment which is usually the browser or the applet viewer.

  Returns:
    null if the component is not in an applet or the applet is not in a browser.
  See Also:
    getAppletContext

inBrowser

      public static boolean inBrowser(Component comp)

  Returns true if the component is in an applet in a browser (ie its AppletContext is not null).

brighter

      public static Color brighter(Color color)

  Calculates the color even when it is saturated, for example, when it is black or white.

darker

      public static Color darker(Color color)

  Calculates the color even when it is saturated, for example, when it is black or white.

instanceOf

      public static boolean instanceOf(Object obj,
                                       String name)

  Returns true if one of the object's superclasses' names contains the string

isParent

      public static boolean isParent(Component parent,
                                     Component comp)

  Returns true if the container is equal to the component, or is its parent or grandparent.

getWidth

      public static int getWidth(Vector value,
                                 JCMultiColumnInterface comp)

  Gets the total width of all the vector's elements.

getWidth

      public static int getWidth(Object value,
                                 Component comp)

  Gets the value's width using the component's font.

getWidth

      public static int getWidth(Object value,
                                 Component comp,
                                 Font font)

  Gets the value's width using the specified font. If the value is a Vector, the sum of all its element's widths is returned.

getHeight

      public static int getHeight(Object value,
                                  Component comp)

  Gets the value's height using the component's font. If the value is a Vector, the largest of all its element's heights is returned.

getHeight

      public static int getHeight(Object value,
                                  Component comp,
                                  Font font)

  Gets the value's height using the specified font.

getNumLines

      public static int getNumLines(Object value)

  Gets the number of newlines in the value.

toHorizAlignment

      public static int toHorizAlignment(int align)

  Gets the horizontal component of an alignment.

  Returns:
    BWTUtil.LEFT, CENTER or RIGHT

draw

      public static synchronized void draw(Component comp,
                                           Graphics gc,
                                           Object value,
                                           int alignment,
                                           Rectangle draw_rect)

  Draws the value as a String, JCString or Image.

  Parameters:
    alignment - one of: BWTEnum.TOPLEFT, TOPCENTER, TOPRIGHT, MIDDLELEFT, MIDDLECENTER, MIDDLERIGHT, BOTTOMLEFT, BOTTOMCENTER and BOTTOMRIGHT
    draw_rect - rectangle within which to draw the value

trace

      public static void trace()

  DEBUG

drawDashedLine

      public static void drawDashedLine(Graphics gc,
                                        int x1,
                                        int y1,
                                        int x2,
                                        int y2)

  Draws a dashed line.

drawDashedRect

      public static void drawDashedRect(Graphics gc,
                                        int x,
                                        int y,
                                        int w,
                                        int h)

  Draws a dashed rectangle.

wallPaper

      public static void wallPaper(Component comp,
                                   Graphics gc,
                                   Image image)

  Draws the image repeatedly across the component, from left to right and top to bottom.

getOS

      public static int getOS()

  Returns an int corresponding to the "os.name" System property: BWTEnum.OS_UNIX or OS_OTHER

getBrowser

      public static int getBrowser()

  Returns an int corresponding to the "browser" System property:

       BWTEnum.BROWSER_APPLETVIEWER    AppletViewer
       BWTEnum.BROWSER_EXPLORER        MS Internet Explorer
       BWTEnum.BROWSER_INTERPRETER     Running as a mainline
       BWTEnum.BROWSER_NETSCAPE        Netscape Navigator
       BWTEnum.BROWSER_OTHER           Other

getJavaVersion

      public static int getJavaVersion()

  Returns an int corresponding to the "java.version" System property:

       JDK 1.0.2   102
       JDK 1.1.0   110

    All Packages  Class Hierarchy  This Package  Previous  Next  Index