|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.util.DrawUtil
public final class DrawUtil
Provides functions for drawing shadows, polygons, gradients, etc.
Copyright (c) Enough Software 2005 - 2008
The implementation for filling a polygon on devices without Nokia-UI-API and without the BlackBerry API is based upon JMicroPolygon: http://sourceforge.net/projects/jmicropolygon, which is licensed under the Apache Software License
history
Nov 23, 2005 - rob creation
| Nested Class Summary | |
|---|---|
static class |
DrawUtil.FadeUtil
This class is used for fadeEffects (FadeTextEffect and FadinAlienGlowEffect). |
| Field Summary | |
|---|---|
static byte[][] |
FILTER_GAUSSIAN_2
|
static byte[][] |
FILTER_GAUSSIAN_3
|
| Constructor Summary | |
|---|---|
DrawUtil()
|
|
| Method Summary | |
|---|---|
static void |
applyFilter(byte[][] filterMatrix,
int brightness,
int[] argbData,
int width,
int height)
Performs a convolution of an image with a given matrix. |
static void |
drawLine(int color,
int x1,
int y1,
int x2,
int y2,
javax.microedition.lcdui.Graphics g)
Draws a translucent line on MIDP 2.0+ and Nokia-UI-API devices. |
static void |
drawPolygon(int[] xPoints,
int[] yPoints,
int color,
javax.microedition.lcdui.Graphics g)
Draws a polygon. |
static void |
drawRgb(int[] rgb,
int x,
int y,
int width,
int height,
boolean processAlpha,
javax.microedition.lcdui.Graphics g)
Draws an (A)RGB array and fits it into the clipping area. |
static void |
drawRgb(int[] rgb,
int x,
int y,
int width,
int height,
boolean processAlpha,
int clipX,
int clipY,
int clipWidth,
int clipHeight,
javax.microedition.lcdui.Graphics g)
Draws an (A)RGB array and fits it into the clipping area. |
static void |
drawTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
javax.microedition.lcdui.Graphics g)
Draws the specified triangle. |
static void |
dropShadow(int[] argbData,
int width,
int height,
int xOffset,
int yOffset,
int size,
int innerColor,
int outerColor)
Paints a dropshadow behind a given ARGB-Array, whereas you are able to specify the shadows inner and outer color. |
static void |
fillPolygon(int[] xPoints,
int[] yPoints,
int color,
javax.microedition.lcdui.Graphics g)
Draws a filled out polygon. |
static void |
fillRect(int x,
int y,
int width,
int height,
int color,
javax.microedition.lcdui.Graphics g)
Draws a (translucent) filled out rectangle. |
static void |
fillTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
javax.microedition.lcdui.Graphics g)
Fills the specified triangle. |
static int |
getCenter(int n1,
int n2,
int n3)
Retrieves the center position of all numbers |
static int |
getComplementaryColor(int color)
Retrieves the complementary color to the specified one. |
static int[] |
getGradient(int startColor,
int endColor,
int steps)
Creates a gradient of colors. |
static void |
getGradient(int startColor,
int endColor,
int[] gradient)
Creates a gradient of colors. |
static int |
getGradientColor(int startColor,
int endColor,
int permille)
Retrieves the gradient color between the given start and end colors. |
static int |
getGradientColor(int startColor,
int endColor,
int step,
int numberOfSteps)
Retrieves the gradient color between the given start and end colors. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static byte[][] FILTER_GAUSSIAN_2
public static byte[][] FILTER_GAUSSIAN_3
| Constructor Detail |
|---|
public DrawUtil()
| Method Detail |
|---|
public static final void fillRect(int x,
int y,
int width,
int height,
int color,
javax.microedition.lcdui.Graphics g)
x - the horizontal start positiony - the vertical start positionwidth - the width of the rectangleheight - the heigh of the rectangletcolor - the argb color of the rectangle, when there is no alpha value (color & 0xff000000 == 0), the traditional g.fillRect() method is calledg - the graphics contextTranslucentSimpleBackground
public static void drawPolygon(int[] xPoints,
int[] yPoints,
int color,
javax.microedition.lcdui.Graphics g)
xPoints - the x coordinates of the polygonyPoints - the y coordinates of the polygoncolor - the color of the polygong - the graphics context
public static final void fillPolygon(int[] xPoints,
int[] yPoints,
int color,
javax.microedition.lcdui.Graphics g)
xPoints - the x coordinates of the polygonyPoints - the y coordinates of the polygoncolor - the color of the polygong - the graphics context
public static void fillTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
javax.microedition.lcdui.Graphics g)
x1 - the x coordinate of the first vertex of the triangley1 - the y coordinate of the first vertex of the trianglex2 - the x coordinate of the second vertex of the triangley2 - the y coordinate of the second vertex of the trianglex3 - the x coordinate of the third vertex of the triangley3 - the y coordinate of the third vertex of the triangleg - the graphics context
public static int getCenter(int n1,
int n2,
int n3)
n1 - first numbern2 - second numbern3 - third number
public static void drawTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
javax.microedition.lcdui.Graphics g)
x1 - the x coordinate of the first vertex of the triangley1 - the y coordinate of the first vertex of the trianglex2 - the x coordinate of the second vertex of the triangley2 - the y coordinate of the second vertex of the trianglex3 - the x coordinate of the third vertex of the triangley3 - the y coordinate of the third vertex of the triangleg - the graphics context
public static final int[] getGradient(int startColor,
int endColor,
int steps)
startColor - the first colorendColor - the last colorsteps - the number of colors in the gradient,
when 2 is given, the first one will be the startColor and the second one will the endColor.
getGradient(int, int, int[]),
getGradientColor(int, int, int)
public static final void getGradient(int startColor,
int endColor,
int[] gradient)
startColor - the first colorendColor - the last colorgradient - the array in which the gradient colors are stored.getGradientColor(int, int, int, int)
public static final int getGradientColor(int startColor,
int endColor,
int permille)
startColor - the start colorendColor - the end colorpermille - the permille between 0 and 1000 - 0 will return the startColor, 1000 the endColor,
500 a gradient color directly in the middlet between start and endcolor.
public static final int getGradientColor(int startColor,
int endColor,
int step,
int numberOfSteps)
startColor - the start colorendColor - the end colorstep - the step/position within the gradientnumberOfSteps - the maxium step (=100%)
getGradientColor(int, int, int)public static int getComplementaryColor(int color)
color - the original argb color
public static final void dropShadow(int[] argbData,
int width,
int height,
int xOffset,
int yOffset,
int size,
int innerColor,
int outerColor)
Paints a dropshadow behind a given ARGB-Array, whereas you are able to specify the shadows inner and outer color.
Note that the dropshadow just works for fully opaque pixels and that it needs a transparent margin to draw the shadow.
Choosing the same inner and outer color and varying the transparency is recommended. Dropshadow just works for fully opaque pixels.
argbData - the images ARGB-Arraywidth - the width of the ARGB-Arrayheight - the width of the ARGB-ArrayxOffset - use this for finetuning the shadow's horizontal position. Negative values move the shadow to the left.yOffset - use this for finetuning the shadow's vertical position. Negative values move the shadow to the top.size - use this for finetuning the shadows radius.innerColor - the inner color of the shadow, which should be less opaque than the text.outerColor - the outer color of the shadow, which should be less than opaque the inner color.
public static final void applyFilter(byte[][] filterMatrix,
int brightness,
int[] argbData,
int width,
int height)
filterMatrix - a matrix, which should have odd rows an colums (not neccessarily a square). The matrix is used for a 2-dimensional convolution. Negative values are possible.brightness - you can vary the brightness of the image measured in percent. Note that the algorithm tries to keep the original brightness as far as is possible.argbData - the image (RGB+transparency)width - of the given Imageheight - of the given Image
Be aware that the computation time depends on the size of the matrix.
public static void drawLine(int color,
int x1,
int y1,
int x2,
int y2,
javax.microedition.lcdui.Graphics g)
color - the ARGB colorx1 - horizontal start positiony1 - vertical start positionx2 - horizontal end positiony2 - vertical end positiong - the graphics context
public static void drawRgb(int[] rgb,
int x,
int y,
int width,
int height,
boolean processAlpha,
javax.microedition.lcdui.Graphics g)
rgb - the (A)RGB arrayx - the horizontal start positiony - the vertical start positionwidth - the width of the RGB arrayheight - the heigt of the RGB arrayprocessAlpha - true when the alpha values should be used so that pixels are blended with the backgroundg - the graphics context
public static void drawRgb(int[] rgb,
int x,
int y,
int width,
int height,
boolean processAlpha,
int clipX,
int clipY,
int clipWidth,
int clipHeight,
javax.microedition.lcdui.Graphics g)
rgb - the (A)RGB arrayx - the horizontal start positiony - the vertical start positionwidth - the width of the RGB arrayheight - the heigt of the RGB arrayprocessAlpha - true when the alpha values should be used so that pixels are blended with the backgroundclipX - the horizontal start of the clipping areaclipY - the vertical start of the clipping areaclipWidth - the width of the clipping areaclipHeight - the height of the clipping areag - the graphics context
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||