LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.view.win.swing
Class LySwingUtils

java.lang.Object
  extended by leon.view.win.swing.LySwingUtils

public class LySwingUtils
extends java.lang.Object

Utility class for Swing viewers.


Field Summary
static java.lang.String __VERSION
           
 
Constructor Summary
LySwingUtils()
           
 
Method Summary
static void drawDotLine(java.awt.Graphics g, int x1, int y1, int x2, int y2)
          Draws a dotline in the given graphics context using the given coordinates.
static void drawFocus(java.awt.Graphics g, int x1, int y1, int width, int height)
          Draws a focus rectangle in the given graphics context using the given coordinates.
static void drawTube(java.awt.Graphics g, int x1, int y1, int x2, int y2, int width, java.awt.Color color)
          Draws a tube-style line in the given graphics context from the point (x1,y1) to (x2,y2) using the specified color with the specified width.
static void fillBackground(java.awt.Graphics gc, int width, int height, java.awt.Image bgImage)
          Draws a background using a texture image.
static void fillShadowRect(java.awt.Graphics gc, int x, int y, int width, int height)
          Draws a filled rectangle with a shadow aspect.
static java.awt.Color getDarkerColor(java.awt.Color color, int value)
          Returns a new color that is value% darker.
static int getFontCharWidth(java.awt.Component comp, java.awt.Font font)
          Returns the average width of a character for a given font.
static java.awt.Color getLighterColor(java.awt.Color color, int value)
          Returns a new color that is value% lighter.
static int getOddNumber(int n)
          Returns the odd number directly superior to the specified number.
static java.awt.Point[] getPolygon(int x1, int y1, int x2, int y2, int width)
          Returns the polygon where (x1,y1) and (x2,y2) are centers of two opposite sides of the specified width.
static void snapshot(java.awt.Component comp, java.lang.String file)
          Takes a snapshot of the given component.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values
Constructor Detail

LySwingUtils

public LySwingUtils()
Method Detail

getDarkerColor

public static java.awt.Color getDarkerColor(java.awt.Color color,
                                            int value)
Returns a new color that is value% darker.

Parameters:
color - the current color
value - the darkness percentage
Returns:
the new darker color

getLighterColor

public static java.awt.Color getLighterColor(java.awt.Color color,
                                             int value)
Returns a new color that is value% lighter.

Parameters:
color - the current color
value - the lightness percentage
Returns:
the new lighter color

drawTube

public static void drawTube(java.awt.Graphics g,
                            int x1,
                            int y1,
                            int x2,
                            int y2,
                            int width,
                            java.awt.Color color)
Draws a tube-style line in the given graphics context from the point (x1,y1) to (x2,y2) using the specified color with the specified width.

Parameters:
g - the graphics context
x1 - the x coordinate of the starting point
y1 - the y coordinate of the starting point
x2 - the x coordinate of the ending point
y2 - the y coordinate of the ending point
width - the width of the line
color - color of the drawn tube

getPolygon

public static java.awt.Point[] getPolygon(int x1,
                                          int y1,
                                          int x2,
                                          int y2,
                                          int width)
Returns the polygon where (x1,y1) and (x2,y2) are centers of two opposite sides of the specified width.

Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
width - the width of the polygon
Returns:
the list of points of the new polygon

drawFocus

public static void drawFocus(java.awt.Graphics g,
                             int x1,
                             int y1,
                             int width,
                             int height)
Draws a focus rectangle in the given graphics context using the given coordinates.

Parameters:
g - the graphics context
x1 - the x coordinate of the left border of the point
y1 - the y coordinate of the right border of the point
width - the width of the rectangle
height - the height of the rectangle

drawDotLine

public static void drawDotLine(java.awt.Graphics g,
                               int x1,
                               int y1,
                               int x2,
                               int y2)
Draws a dotline in the given graphics context using the given coordinates.

Parameters:
g - the graphics context
x1 - the x coordinate of the starting point
y1 - the y coordinate of the starting point
x2 - the x coordinate of the ending point
y2 - the y coordinate of the ending point

getOddNumber

public static int getOddNumber(int n)
Returns the odd number directly superior to the specified number.

Parameters:
n - the number
Returns:
the first superior odd number

fillShadowRect

public static void fillShadowRect(java.awt.Graphics gc,
                                  int x,
                                  int y,
                                  int width,
                                  int height)
Draws a filled rectangle with a shadow aspect.

Parameters:
gc - the Graphic Context
x - position on the X axis
y - position on the Y axis
width - Width
height - Height

fillBackground

public static void fillBackground(java.awt.Graphics gc,
                                  int width,
                                  int height,
                                  java.awt.Image bgImage)
Draws a background using a texture image.

Parameters:
gc - the Graphic Context
width - width of the visible part of the graphics
height - height of the visible part of the graphics
bgImage - the image to be used to draw the background

snapshot

public static void snapshot(java.awt.Component comp,
                            java.lang.String file)
Takes a snapshot of the given component.

Parameters:
comp - the component
file - the destination file

getFontCharWidth

public static int getFontCharWidth(java.awt.Component comp,
                                   java.awt.Font font)
Returns the average width of a character for a given font.

Parameters:
comp - the component used to compute width
font - the font
Returns:
the average width of a character for the given font

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com