org.zaval.lw
Class LwToolkit

java.lang.Object
  |
  +--org.zaval.lw.LwToolkit

public abstract class LwToolkit
extends java.lang.Object

This class provides set of useful static methods for the lightweight library.


Field Summary
static int ACTION_KEY
           
static java.awt.Color BACK_COLOR
          The default background color definition.
static java.awt.Font BFONT
          The default bold font definition.
static int CANCEL_KEY
           
static java.awt.Color darkBlue
          The dark blue color definition.
static java.awt.Color FG_COLOR
          The default foreground color definition.
static java.awt.Font FONT
          The default font definition.
static java.awt.FontMetrics FONT_METRICS
          The default font metrics definition.
static int HORIZONTAL
          The horizontal alignment constant.
static int NONE
          The none vertical and none horizontal alignment constant.
static int PASSFOCUS_KEY
           
static java.awt.Dimension PS_SIZE
          The default preferred size definition.
static java.awt.Font SFONT
          The default small font definition.
static int VERTICAL
          The vertical alignment constant.
 
Constructor Summary
LwToolkit()
           
 
Method Summary
static java.awt.Point calcOrigin(int x, int y, int w, int h, int px, int py, LwComponent target)
          Calculates and gets origin for the specified area of the component relatively the specified previous origin.
static java.awt.Point calcOrigin(int x, int y, int w, int h, int px, int py, LwComponent target, java.awt.Insets i)
          Calculates and gets origin for the specified area of the component relatively the specified previous origin.
static java.awt.Point calcOrigin(int x, int y, int w, int h, LwComponent target)
          Calculates and gets origin for the specified area of the component.
static LwDesktop createDesktop()
          Creates a desktop instance.
static java.lang.Object createObj(java.lang.String className, java.lang.String argsStr)
           
static void drawDotHLine(java.awt.Graphics gr, int x1, int x2, int y1)
          Draws the horizontal dotted line between the (x1,y1) and (x2,y1) coordinates.
static void drawDotRect(java.awt.Graphics gr, int x, int y, int w, int h)
          Draws the dotted outline of the specified rectangle using the current color.
static void drawDotVLine(java.awt.Graphics gr, int y1, int y2, int x1)
          Draws the vertical dotted line between the (x1,y1) and (x1,y2) coordinates.
static void drawMarker(java.awt.Graphics g, int x, int y, int w, int h, java.awt.Color bg, java.awt.Color fc)
          Draws marker for the specified rectangular area, the given background and foreground colors.
static void drawXORLine(LwComponent target, int x1, int y1, int x2, int y2)
          Draws line using XOR mode.
static void drawXORRect(LwComponent target, int x, int y, int w, int h)
          Draws rectangle using XOR mode.
static void fillXORRect(LwComponent target, int x, int y, int w, int h)
          Fills the rectangle using XOR mode.
static java.awt.Point getAbsLocation(int x, int y, LwComponent c)
          Returns an absolute location for the given relative location of the component.
static java.awt.Point getAbsLocation(LwComponent c)
          Returns an absolute location of the component.
static LwCursorManager getCursorManager()
           
static LwDesktop getDesktop(LwComponent c)
          Gets a desktop container for the specified component.
static LwComponent getDirectChild(LwComponent parent, LwComponent child)
          Returns the immediate child component for the parent and child.
static int getDirectCompAt(int x, int y, LwContainer p)
          Returns the immediate child component at the specified location of the parent component.
static LwEventManager getEventManager()
           
static LwFocusManager getFocusManager()
           
static java.lang.String[] getFontList()
          Gets the list of available fonts names.
static java.awt.FontMetrics getFontMetrics(java.awt.Font f)
          Gets the font metrics for the specified font.
static java.awt.Graphics getGraphics(LwComponent c)
          Gets a graphics context for the specified lightweight component.
static java.awt.Graphics getGraphics(LwComponent c, int x, int y, int w, int h)
          Gets a graphics context for the specified area of the lightweight component.
static java.awt.Image getImage(java.lang.String name)
          Reads an image by the specified path.
static int getKeyType(int keyCode, int mask)
          Gets the key type for the specified key code and key mask.
static java.awt.Dimension getMaxPreferredSize(LayoutContainer target)
          Calculates and gets a maximal preferred size among visible children of the specified container.
static LwPaintManager getPaintManager()
           
static java.util.Properties getProperties(java.lang.String name)
          Reads a properties file by the specified path and returns it as java.util.Properties instance.
static java.awt.Point getRelLocation(int x, int y, LwComponent c)
          Returns a relative location for the specified absolute location relatively the light weight component.
static java.awt.Point getRelLocation(int x, int y, LwComponent target, LwComponent c)
          Returns a relative location for the specified target location relatively the light weight component.
static java.lang.String getResourcesBase()
           
static java.awt.Dimension getScreenSize()
          Gets the size of the screen.
static java.lang.Object getStaticObj(java.lang.String key)
          Gets the static object by the specified key.
static LwTooltipMan getTooltipManager()
           
static java.lang.String getVersion()
          Gets the library version.
static LwView getView(java.lang.String key)
          Gets a static object by the specified key as LwView class.
static boolean isActionMask(int mask)
          Don't touch the method it will be redesigned in the further version.
static boolean isAncestorOf(LwComponent p, LwComponent c)
          Checks if the component is contained in the component hierarchy of this container.
static void loadObjs(java.lang.String key, java.util.Properties props)
          Loads objects by the specified key of the specified properties set into static objects table.
static void startVCL(java.lang.String base)
           
static void stopVCL()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final int HORIZONTAL
The horizontal alignment constant.

VERTICAL

public static final int VERTICAL
The vertical alignment constant.

NONE

public static final int NONE
The none vertical and none horizontal alignment constant.

darkBlue

public static final java.awt.Color darkBlue
The dark blue color definition.

FONT

public static final java.awt.Font FONT
The default font definition.

SFONT

public static final java.awt.Font SFONT
The default small font definition.

BFONT

public static final java.awt.Font BFONT
The default bold font definition.

FONT_METRICS

public static final java.awt.FontMetrics FONT_METRICS
The default font metrics definition.

FG_COLOR

public static final java.awt.Color FG_COLOR
The default foreground color definition.

BACK_COLOR

public static final java.awt.Color BACK_COLOR
The default background color definition.

PS_SIZE

public static final java.awt.Dimension PS_SIZE
The default preferred size definition.

ACTION_KEY

public static final int ACTION_KEY

CANCEL_KEY

public static final int CANCEL_KEY

PASSFOCUS_KEY

public static final int PASSFOCUS_KEY
Constructor Detail

LwToolkit

public LwToolkit()
Method Detail

createDesktop

public static final LwDesktop createDesktop()
Creates a desktop instance.
Returns:
a desktop instance.

getProperties

public static java.util.Properties getProperties(java.lang.String name)
Reads a properties file by the specified path and returns it as java.util.Properties instance. The specified path points to the properties file relatively LwToolkit.class package. If the path starts with '/' it is used as is.
Parameters:
name - the specified path.

getImage

public static java.awt.Image getImage(java.lang.String name)
Reads an image by the specified path. The path is relative class package. If the path starts with '/' it is used as is.
Parameters:
name - the specified path.

getFontMetrics

public static java.awt.FontMetrics getFontMetrics(java.awt.Font f)
Gets the font metrics for the specified font.
Parameters:
f - the specified font.
Returns:
a font metrics for the specified font.

drawDotHLine

public static void drawDotHLine(java.awt.Graphics gr,
                                int x1,
                                int x2,
                                int y1)
Draws the horizontal dotted line between the (x1,y1) and (x2,y1) coordinates.
Parameters:
gr - the specified context to be used for drawing.
x1 - the x coordinate of the start of the line.
x2 - the x coordinate of the end of the line.
y1 - the y coordinate of the start and end of the line.

drawDotVLine

public static void drawDotVLine(java.awt.Graphics gr,
                                int y1,
                                int y2,
                                int x1)
Draws the vertical dotted line between the (x1,y1) and (x1,y2) coordinates.
Parameters:
gr - the specified context to be used for drawing.
y1 - the y coordinate of the start of the line.
y2 - the y coordinate of the end of the line.
x1 - the x coordinate of the start and end of the line.

drawDotRect

public static void drawDotRect(java.awt.Graphics gr,
                               int x,
                               int y,
                               int w,
                               int h)
Draws the dotted outline of the specified rectangle using the current color. The resulting rectangle will cover an area (w + 1) pixels wide by (h + 1) pixels tall.
Parameters:
gr - the specified context to be used for drawing.
x - the x coordinate of the rectangle to be drawn (left top corner).
y - the y coordinate of the rectangle to be drawn (left top corner).
w - the width of the rectangle to be drawn.
h - the height of the rectangle to be drawn.

getScreenSize

public static final java.awt.Dimension getScreenSize()
Gets the size of the screen.
Returns:
a size of the screen.

drawMarker

public static void drawMarker(java.awt.Graphics g,
                              int x,
                              int y,
                              int w,
                              int h,
                              java.awt.Color bg,
                              java.awt.Color fc)
Draws marker for the specified rectangular area, the given background and foreground colors.
Parameters:
g - the specified graphics context.
x - the x coordinate of the top-left corner of the rectangular area.
y - the y coordinate of the top-left corner of the rectangular area.
w - the width of the rectangular area.
h - the height of the rectangular area.
bg - the background color.
fc - the foreground color.

drawXORLine

public static void drawXORLine(LwComponent target,
                               int x1,
                               int y1,
                               int x2,
                               int y2)
Draws line using XOR mode.
Parameters:
target - the specified component.
x1 - the first x coordinate of the line.
y1 - the first y coordinate of the line.
x2 - the second x coordinate of the line.
y2 - the second y coordinate of the line.

drawXORRect

public static void drawXORRect(LwComponent target,
                               int x,
                               int y,
                               int w,
                               int h)
Draws rectangle using XOR mode.
Parameters:
target - the specified component.
x - the top-left corner x coordinate of the rectangle.
y - the top-left corner y coordinate of the rectangle.
w - the rectangle width.
h - the rectangle height.

fillXORRect

public static void fillXORRect(LwComponent target,
                               int x,
                               int y,
                               int w,
                               int h)
Fills the rectangle using XOR mode.
Parameters:
target - the specified component.
x - the top-left corner x coordinate of the rectangle.
y - the top-left corner y coordinate of the rectangle.
w - the rectangle width.
h - the rectangle height.

isActionMask

public static boolean isActionMask(int mask)
Don't touch the method it will be redesigned in the further version.

getFontList

public static java.lang.String[] getFontList()
Gets the list of available fonts names.
Returns:
a list of available fonts names.

getKeyType

public static int getKeyType(int keyCode,
                             int mask)
Gets the key type for the specified key code and key mask. The method should return one of the following constant : ACTION_KEY, CANCEL_KEY, PASSFOCUS_KEY or -1 in all other cases.
Parameters:
keyCode - the specified key code.
mask - the specified key mask.
Returns:
a key type.

createObj

public static java.lang.Object createObj(java.lang.String className,
                                         java.lang.String argsStr)
                                  throws java.lang.Exception

loadObjs

public static void loadObjs(java.lang.String key,
                            java.util.Properties props)
                     throws java.lang.Exception
Loads objects by the specified key of the specified properties set into static objects table.
Parameters:
key - the specified key that defines set of objects that should be loaded.
props - the specified properties.

getStaticObj

public static java.lang.Object getStaticObj(java.lang.String key)
Gets the static object by the specified key.
Parameters:
key - the specified key.
Returns:
a static object.

getView

public static LwView getView(java.lang.String key)
Gets a static object by the specified key as LwView class.
Parameters:
key - the specified key.
Returns:
a static object.

getVersion

public static final java.lang.String getVersion()
Gets the library version.
Returns:
the library version.

getResourcesBase

public static final java.lang.String getResourcesBase()

getDesktop

public static LwDesktop getDesktop(LwComponent c)
Gets a desktop container for the specified component. Desktop container is top-level container where the specified component is resided.
Parameters:
c - the specified component.
Returns:
a desktop.

getDirectChild

public static LwComponent getDirectChild(LwComponent parent,
                                         LwComponent child)
Returns the immediate child component for the parent and child.
Parameters:
parent - the parent component.
child - the child component.
Returns:
an immediate child component.

getDirectCompAt

public static int getDirectCompAt(int x,
                                  int y,
                                  LwContainer p)
Returns the immediate child component at the specified location of the parent component.
Parameters:
x - the x coordinate relatively the parent component.
y - the y coordinate relatively the parent component.
p - the parent component.
Returns:
an immediate child component.

isAncestorOf

public static boolean isAncestorOf(LwComponent p,
                                   LwComponent c)
Checks if the component is contained in the component hierarchy of this container.
Parameters:
p - the specified parent component.
c - the specified child component.
Returns:
true if the component is contained in the parent component hierarchy; otherwise false.

getAbsLocation

public static java.awt.Point getAbsLocation(int x,
                                            int y,
                                            LwComponent c)
Returns an absolute location for the given relative location of the component. The absolute location is calculated relatively a native component where the light weight component is resided.
Parameters:
x - the x coordinate relatively the component.
y - the y coordinate relatively the component.
c - the lightweight component.
Returns:
an absolute location.

getAbsLocation

public static java.awt.Point getAbsLocation(LwComponent c)
Returns an absolute location of the component. The absolute location is calculated relatively a native component where the light weight component is resided.
Parameters:
c - the lightweight component.
Returns:
an absolute location of the component.

getRelLocation

public static java.awt.Point getRelLocation(int x,
                                            int y,
                                            LwComponent c)
Returns a relative location for the specified absolute location relatively the light weight component.
Parameters:
x - the x coordinate relatively a native where the component is resided.
y - the y coordinate relatively a native where the component is resided.
c - the lightweight component.
Returns:
a relative location.

getRelLocation

public static java.awt.Point getRelLocation(int x,
                                            int y,
                                            LwComponent target,
                                            LwComponent c)
Returns a relative location for the specified target location relatively the light weight component.
Parameters:
x - the x coordinate relatively the target component where the component is resided.
y - the y coordinate relatively the target component where the component is resided.
target - the target lightweight component.
c - the lightweight component.
Returns:
a relative location.

getMaxPreferredSize

public static java.awt.Dimension getMaxPreferredSize(LayoutContainer target)
Calculates and gets a maximal preferred size among visible children of the specified container.
Parameters:
target - the container.
Returns:
a maximal preferred size.

calcOrigin

public static java.awt.Point calcOrigin(int x,
                                        int y,
                                        int w,
                                        int h,
                                        LwComponent target)
Calculates and gets origin for the specified area of the component. The origin is calculated as a location of the component view to have the specified area inside a visible part of the component.
Parameters:
x - the x coordinate of the component area.
y - the y coordinate of the component area.
w - the width of the component area.
h - the height of the component area.
target - the component.
Returns:
an origin of the component.

calcOrigin

public static java.awt.Point calcOrigin(int x,
                                        int y,
                                        int w,
                                        int h,
                                        int px,
                                        int py,
                                        LwComponent target)
Calculates and gets origin for the specified area of the component relatively the specified previous origin. The origin is calculated as a location of the component view to have the specified area inside a visible part of the component.
Parameters:
x - the x coordinate of the component area.
y - the y coordinate of the component area.
w - the width of the component area.
h - the height of the component area.
px - the x coordinate of the previous origin.
py - the y coordinate of the previous origin.
target - the component.
Returns:
an origin of the component.

calcOrigin

public static java.awt.Point calcOrigin(int x,
                                        int y,
                                        int w,
                                        int h,
                                        int px,
                                        int py,
                                        LwComponent target,
                                        java.awt.Insets i)
Calculates and gets origin for the specified area of the component relatively the specified previous origin. The origin is calculated as a location of the component view to have the specified area inside a visible part of the component.
Parameters:
x - the x coordinate of the component area.
y - the y coordinate of the component area.
w - the width of the component area.
h - the height of the component area.
px - the x coordinate of the previous origin.
py - the y coordinate of the previous origin.
target - the component.
i - the insets.
Returns:
Fan origin of the component.

getGraphics

public static java.awt.Graphics getGraphics(LwComponent c)
Gets a graphics context for the specified lightweight component.
Parameters:
c - the lightweight component.
Returns:
a graphics context.

getGraphics

public static java.awt.Graphics getGraphics(LwComponent c,
                                            int x,
                                            int y,
                                            int w,
                                            int h)
Gets a graphics context for the specified area of the lightweight component. The method calculates clip area as intersecation the area bounds and a visible part of the component.
Parameters:
c - the lightweight component.
x - the x coordinate of the component area.
y - the y coordinate of the component area.
w - the width of the component area.
h - the height of the component area.
Returns:
a graphics context.

getPaintManager

public static final LwPaintManager getPaintManager()

getFocusManager

public static final LwFocusManager getFocusManager()

getEventManager

public static final LwEventManager getEventManager()

getCursorManager

public static LwCursorManager getCursorManager()

getTooltipManager

public static LwTooltipMan getTooltipManager()

startVCL

public static void startVCL(java.lang.String base)

stopVCL

public static void stopVCL()


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org