: Download: FAQ: Licensing: Support: Contact ME
LwVCL Home
Introduction
Overview
Screen Shots
On-line Demos
Requirements
Further Plans
Docs
Tutorial
How-to (PDF)
API
FAQ
Download
Latest version

Home > J2SE > API

Overview  Package   Class  Tree  Deprecated  Index  Help 

org.zaval.lw
Class LwToolkit

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

public class LwToolkit
extends java.lang.Object

This class provides set of useful static methods for the lightweight library. The other purpose of the class to provide set of methods that is responsible for LwVCL bootstrap. The methods read LwVCL properties files, loads LwVCL resources and prepares all necessary data to start work with the library.


Field Summary
static int ACTION_KEY
          The action key type.
static int BOTTOM
          Specifies the bottom vertical alignment type.
static int CANCEL_KEY
          The cancel key type.
static int CENTER
          Specifies the center horizontal or vertical alignment type.
static java.awt.Color darkBlue
          The dark blue color definition.
static java.awt.FontMetrics FONT_METRICS
          The default font metrics definition.
static int HORIZONTAL
          The horizontal alignment constant.
static int LEFT
          Specifies the left horizontal alignment type.
static int NONE
          The none vertical and none horizontal alignment constant.
static int PASSFOCUS_KEY
          The pass focus key type.
static int RIGHT
          Specifies the right horizontal alignment type.
static int TOP
          Specifies the top vertical alignment type.
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 the 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 the 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 the origin for the specified area of the component.
static LwDesktop createDesktop()
          Creates the desktop instance.
static java.lang.Object createObj(java.lang.String className, java.lang.String argsStr, java.util.Hashtable objs)
          Creates an instance of the specified class using appropriate constructor for the given input arguments list.
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) points.
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) points.
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 basing on 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 the absolute location for the given relative location of the component.
static java.awt.Point getAbsLocation(LwComponent c)
          Returns the absolute location of the component.
static LwCursorManager getCursorManager()
          Gets the current cursor manager.
static LwDesktop getDesktop(LwComponent c)
          Gets the desktop container for the specified component.
static LwComponent getDirectChild(LwComponent parent, LwComponent child)
          Returns the immediate child component for the parent and the given 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()
          Gets the current event manager.
static LwFocusManager getFocusManager()
          Gets the current focus manager.
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 the graphics context for the specified lightweight component.
static java.awt.Graphics getGraphics(LwComponent c, int x, int y, int w, int h)
          Gets the 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 the maximal preferred size among visible children of the specified container.
static LwPaintManager getPaintManager()
          Gets the current paint manager.
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 the 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 the relative location for the specified target location relatively the light weight component.
static java.lang.String getResourcesBase()
          Gets the base directory to look up LwVCL resources (properties, images etc).
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 java.lang.Object getStaticObj(java.lang.String key, boolean b)
          Gets the static object or its clone by the specified key.
static LwTooltipMan getTooltipManager()
          Gets the current tooltip manager.
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 instance.
static LwWizard getWizard()
          Gets the wizard that is used to customize the lightweight components.
static int getXLoc(int aow, int alignX, int aw)
          Calculates and returns location of the given object with the specified width that is adjusted inside the given area with the specified width and horizontal alignment.
static int getYLoc(int aoh, int alignY, int ah)
          Calculates and returns location of the given object with the specified height that is adjusted inside the given area with the specified height and vertical alignment.
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 ancestor for the component.
static boolean isVCLStarted()
          Tests if the library resources have been loaded and the library has been initialized.
static boolean loadObjs(java.lang.String name)
          Loads objects from the specified properties file into internal static objects table.
static boolean loadObjs(java.lang.String name, java.util.Hashtable res)
          Loads objects from the specified properties file into the given hashtable.
static java.lang.Object putStaticObj(java.lang.String key, java.lang.Object obj)
          Puts the static object with the specified key.
static void startVCL(java.lang.String sbase)
          Starts LwVCL.
static void stopVCL()
          Stops LwVCL.
 
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.

LEFT

public static final int LEFT
Specifies the left horizontal alignment type.

RIGHT

public static final int RIGHT
Specifies the right horizontal alignment type.

TOP

public static final int TOP
Specifies the top vertical alignment type.

BOTTOM

public static final int BOTTOM
Specifies the bottom vertical alignment type.

CENTER

public static final int CENTER
Specifies the center horizontal or vertical alignment type.

darkBlue

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

FONT_METRICS

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

ACTION_KEY

public static final int ACTION_KEY
The action key type.

CANCEL_KEY

public static final int CANCEL_KEY
The cancel key type.

PASSFOCUS_KEY

public static final int PASSFOCUS_KEY
The pass focus key type.
Constructor Detail

LwToolkit

public LwToolkit()
Method Detail

createDesktop

public static LwDesktop createDesktop()
Creates the 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 resources base directory. 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 base directory. If the path starts with '/' it is used as is.
Parameters:
name - the specified path.
Returns:
the image object or null if the image cannot be fetched.

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) points.
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) points.
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 basing on 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,
                                         java.util.Hashtable objs)
                                  throws java.lang.Exception
Creates an instance of the specified class using appropriate constructor for the given input arguments list. The list is set of arguments that are separated by the comma. The following arguments types can be used:
  • Integer. If the argument does not equal "true" or "false" and is not bound by quotes.
  • Boolean. If the argument equals "true" or "false" and is not bound by quotes.
  • String. If the argument is not bound by quote.
Parameters:
className - the specified class name.
argsStr - the specified input arguments list. The argument can be null. In this case the default constructor will be used to create the class instance.
Returns:
an instance of the class.

loadObjs

public static boolean loadObjs(java.lang.String name)
                        throws java.lang.Exception
Loads objects from the specified properties file into internal static objects table. The method uses Lwtoolkit.class.getResourceAsStream method to read the properties file.
Parameters:
name - the specified properties set name.
Returns:
true if the properties file has been found and read successfully; otherwise retuns false.

loadObjs

public static boolean loadObjs(java.lang.String name,
                               java.util.Hashtable res)
                        throws java.lang.Exception
Loads objects from the specified properties file into the given hashtable. The method uses Lwtoolkit.class.getResourceAsStream method to read the properties file.
Parameters:
name - the specified properties set name.
res - the objects hashtable where all created objects are stored.
Returns:
true if the properties file has been found and read successfully; otherwise retuns false.

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.

getStaticObj

public static java.lang.Object getStaticObj(java.lang.String key,
                                            boolean b)
Gets the static object or its clone by the specified key.
Parameters:
key - the specified key.
b - the flag indicates if the method should create clone of the static object instance or return it directly. Use true value to get clone of the static object.
Returns:
a static object.

putStaticObj

public static java.lang.Object putStaticObj(java.lang.String key,
                                            java.lang.Object obj)
Puts the static object with the specified key. The method cannot be used to redefine a manager.
Parameters:
key - the specified key.
obj - the specified static object. Use null as the static object to remove it.
Returns:
a previous static object stored with the specified key.

getView

public static LwView getView(java.lang.String key)
Gets a static object by the specified key as LwView class instance.
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()
Gets the base directory to look up LwVCL resources (properties, images etc).
Returns:
a base directory.

getDesktop

public static LwDesktop getDesktop(LwComponent c)
Gets the 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 the given 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 ancestor for the component.
Parameters:
p - the specified parent component.
c - the specified child component.
Returns:
true if the component is ancestor; otherwise false.

getAbsLocation

public static java.awt.Point getAbsLocation(int x,
                                            int y,
                                            LwComponent c)
Returns the absolute location for the given relative location of the component. The absolute location is calculated relatively a desktop 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 the absolute location of the component. The absolute location is calculated relatively a desktop 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 the 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 the 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 the 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 the 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 the 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 the 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 the 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 the 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()
Gets the current paint manager.
Returns:
a paint manager.

getFocusManager

public static final LwFocusManager getFocusManager()
Gets the current focus manager.
Returns:
a focus manager.

getEventManager

public static final LwEventManager getEventManager()
Gets the current event manager.
Returns:
an event manager.

getCursorManager

public static LwCursorManager getCursorManager()
Gets the current cursor manager.
Returns:
a cursor manager.

getTooltipManager

public static LwTooltipMan getTooltipManager()
Gets the current tooltip manager.
Returns:
a tooltip manager.

startVCL

public static void startVCL(java.lang.String sbase)
Starts LwVCL. The method performs all necessary operations to prepare data, resources, properties and so on to be ready for working with the library. The given base directory defines the root path relative to that the LwVCL resources are stored.
Parameters:
sbase - the base directory.

isVCLStarted

public static boolean isVCLStarted()
Tests if the library resources have been loaded and the library has been initialized.
Returns:
true if the library has been initialized.

stopVCL

public static void stopVCL()
Stops LwVCL. The method performs all necessary operations to destroy data and free system resources, since the LwVCL is stopped.

getXLoc

public static int getXLoc(int aow,
                          int alignX,
                          int aw)
Calculates and returns location of the given object with the specified width that is adjusted inside the given area with the specified width and horizontal alignment.
Parameters:
aow - the specified object width.
alignX - the specified horizontal alignment. Use LwToolkit.LEFT, LwToolkit.RIGHT, LwToolkit.CENTER or LwToolkit.NONE as the argument value.
aw - the specified align area width.
Returns:
a location. The method throws IllegalArgumentException if the horizontal alignment is undefined.

getYLoc

public static int getYLoc(int aoh,
                          int alignY,
                          int ah)
Calculates and returns location of the given object with the specified height that is adjusted inside the given area with the specified height and vertical alignment.
Parameters:
aoh - the specified object height.
alignY - the specified vertical alignment. Use LwToolkit.TOP, LwToolkit.BOTTOM, LwToolkit.CENTER or LwToolkit.NONE as the argument value.
ah - the specified align area height.
Returns:
a location. The method throws IllegalArgumentException if the horizontal alignment is undefined.

getWizard

public static LwWizard getWizard()
Gets the wizard that is used to customize the lightweight components.
Returns:
a wizard class instance.


: up