|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.lwuit.Graphics
public final class Graphics
Abstracts the underlying platform graphics context thus allowing us to achieve portability between MIDP devices and CDC devices. This abstaction simplifies and unifies the Graphics implementations of various platforms.
A graphics instance should never be created by the developer and is always accessed using either a paint callback or a mutable image. There is no supported way to create this object directly.
Method Summary | |
---|---|
java.lang.Object |
beginNativeGraphicsAccess()
Starts accessing the native graphics in the underlying OS, when accessing the native graphics LWUIT shouldn't be used! |
void |
clipRect(int x,
int y,
int width,
int height)
Clips the given rectangle by intersecting with the current clipping region, this method can thus only shrink the clipping region and never increase it. |
void |
darkerColor(int factor)
Makes the current color slightly darker, this is useful for many visual effects |
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Draws a circular or elliptical arc based on the given angles and bounding box |
void |
drawChar(char character,
int x,
int y)
Draw the given char using the current font and color in the x,y coordinates. |
void |
drawChars(char[] data,
int offset,
int length,
int x,
int y)
Draw the given char array using the current font and color in the x,y coordinates. |
void |
drawImage(Image img,
int x,
int y)
Draws the image so its top left coordinate corresponds to x/y |
void |
drawImage(Image img,
int x,
int y,
int w,
int h)
Draws the image so its top left coordinate corresponds to x/y and scales it to width/height |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a line between the 2 X/Y coordinates |
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a closed polygon defined by arrays of x and y coordinates. |
void |
drawRect(int x,
int y,
int width,
int height)
Draws a rectangle in the given coordinates |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws a rounded corner rectangle in the given coordinates with the arcWidth/height matching the last two arguments respectively. |
void |
drawString(java.lang.String str,
int x,
int y)
Draw a string using the current font and color in the x,y coordinates. |
void |
drawString(java.lang.String str,
int x,
int y,
int textDecoration)
Draw a string using the current font and color in the x,y coordinates. |
void |
endNativeGraphicsAccess()
Invoke this to restore LWUIT's graphics settings into the native graphics |
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Fills a circular or elliptical arc based on the given angles and bounding box. |
void |
fillLinearGradient(int startColor,
int endColor,
int x,
int y,
int width,
int height,
boolean horizontal)
Draws a linear gradient in the given coordinates with the given colors, doesn't take alpha into consideration when drawing the gradient |
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Fills a closed polygon defined by arrays of x and y coordinates. |
void |
fillRadialGradient(int startColor,
int endColor,
int x,
int y,
int width,
int height)
Draws a radial gradient in the given coordinates with the given colors, doesn't take alpha into consideration when drawing the gradient. |
void |
fillRect(int x,
int y,
int width,
int height)
Fills the rectangle from the given position according to the width/height minus 1 pixel according to the convention in Java. |
void |
fillRect(int x,
int y,
int w,
int h,
byte alpha)
Fills a rectangle with an optionally translucent fill color |
void |
fillRectRadialGradient(int startColor,
int endColor,
int x,
int y,
int width,
int height,
float relativeX,
float relativeY,
float relativeSize)
Draws a radial gradient in the given coordinates with the given colors, doesn't take alpha into consideration when drawing the gradient. |
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Fills a rounded rectangle in the same way as drawRoundRect |
void |
fillTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3)
Draws a filled triangle with the given coordinates |
int |
getAlpha()
Returnes the alpha as a value between 0-255 (0 - 0xff) where 255 is completely opaque and 0 is completely transparent |
int[] |
getClip()
Returns the clip as an x,y,w,h array |
int |
getClipHeight()
Returns the clip height |
int |
getClipWidth()
Returns the clip width |
int |
getClipX()
Returns the x clipping position |
int |
getClipY()
Returns the y clipping position |
int |
getColor()
Returns the current color |
Font |
getFont()
Returns the font used with the drawString method calls |
int |
getTranslateX()
Returns the current x translate value |
int |
getTranslateY()
Returns the current y translate value |
boolean |
isAffineSupported()
Indicates whether the underlying implementation can draw using an affine transform hence methods such as rotate, scale and shear would work |
boolean |
isAlphaSupported()
Indicates whether invoking set/getAlpha would have an effect on all further rendering from this graphics object. |
boolean |
isAntiAliased()
Returns true if anti-aliasing for standard rendering operations is turned on. |
boolean |
isAntiAliasedText()
Indicates whether anti-aliasing for text is active, notice that text anti-aliasing is a separate attribute from standard anti-alisaing. |
boolean |
isAntiAliasedTextSupported()
Returns true if anti-aliasing for text is supported, notice that text anti-aliasing is a separate attribute from standard anti-alisaing. |
boolean |
isAntiAliasingSupported()
Returns true if anti-aliasing for standard rendering operations is supported, notice that text anti-aliasing is a separate attribute. |
void |
lighterColor(int factor)
Makes the current color slightly lighter, this is useful for many visual effects |
void |
resetAffine()
Resets the affine transform to the default value |
void |
rotate(float angle)
Rotates the coordinate system around a radian angle using the affine transform |
void |
scale(float x,
float y)
Scales the coordinate system using the affine transform |
void |
setAlpha(int a)
Sets alpha as a value between 0-255 (0 - 0xff) where 255 is completely opaque and 0 is completely transparent |
void |
setAntiAliased(boolean a)
Set whether anti-aliasing for standard rendering operations is turned on. |
void |
setAntiAliasedText(boolean a)
Set whether anti-aliasing for text is active, notice that text anti-aliasing is a separate attribute from standard anti-alisaing. |
void |
setClip(int[] clip)
Sets the clip from an array containing x, y, width, height value |
void |
setClip(int x,
int y,
int width,
int height)
Updates the clipping region to match the given region exactly |
void |
setColor(int RGB)
Sets the current rgb color while ignoring any potential alpha component within said color value. |
void |
setFont(Font font)
Sets the font to use with the drawString method calls |
void |
shear(float x,
float y)
Shear the graphics coordinate system using the affine transform |
void |
translate(int x,
int y)
Translates the X/Y location for drawing on the underlying surface. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void translate(int x, int y)
translate(-getTranslateX(), -getTranslateY())
x
- the x coordinatey
- the y coordinatepublic int getTranslateX()
public int getTranslateY()
public int getColor()
public void setColor(int RGB)
RGB
- the RGB value for the color.public Font getFont()
public void setFont(Font font)
font
- the font used with the drawString method callspublic int getClipX()
public int[] getClip()
public void setClip(int[] clip)
clip
- 4 element arraypublic int getClipY()
public int getClipWidth()
public int getClipHeight()
public void clipRect(int x, int y, int width, int height)
x
- the x coordinate of the rectangle to intersect the clip withy
- the y coordinate of the rectangle to intersect the clip withwidth
- the width of the rectangle to intersect the clip withheight
- the height of the rectangle to intersect the clip withpublic void setClip(int x, int y, int width, int height)
x
- the x coordinate of the new clip rectangle.y
- the y coordinate of the new clip rectangle.width
- the width of the new clip rectangle.height
- the height of the new clip rectangle.public void drawLine(int x1, int y1, int x2, int y2)
x1
- first x positiony1
- first y positionx2
- second x positiony2
- second y positionpublic void fillRect(int x, int y, int width, int height)
x
- the x coordinate of the rectangle to be filled.y
- the y coordinate of the rectangle to be filled.width
- the width of the rectangle to be filled.height
- the height of the rectangle to be filled.public void drawRect(int x, int y, int width, int height)
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
x
- the x coordinate of the rectangle to be drawn.y
- the y coordinate of the rectangle to be drawn.width
- the width of the rectangle to be drawn.height
- the height of the rectangle to be drawn.arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.public void lighterColor(int factor)
factor
- the degree of lightening a color per channel a number from 1 to 255public void darkerColor(int factor)
factor
- the degree of lightening a color per channel a number from 1 to 255public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
x
- the x coordinate of the rectangle to be filled.y
- the y coordinate of the rectangle to be filled.width
- the width of the rectangle to be filled.height
- the height of the rectangle to be filled.arcWidth
- the horizontal diameter of the arc at the four corners.arcHeight
- the vertical diameter of the arc at the four corners.drawRoundRect(int, int, int, int, int, int)
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
x
- the x coordinate of the upper-left corner of the arc to be filled.y
- the y coordinate of the upper-left corner of the arc to be filled.width
- the width of the arc to be filled.height
- the height of the arc to be filled.startAngle
- the beginning angle.arcAngle
- the angular extent of the arc, relative to the start angle.public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
x
- the x coordinate of the upper-left corner of the arc to be drawn.y
- the y coordinate of the upper-left corner of the arc to be drawn.width
- the width of the arc to be drawn.height
- the height of the arc to be drawn.startAngle
- the beginning angle.arcAngle
- the angular extent of the arc, relative to the start angle.public void drawString(java.lang.String str, int x, int y, int textDecoration)
str
- the string to be drawn.x
- the x coordinate.y
- the y coordinate.textDecoration
- Text decoration bitmask (See Style's TEXT_DECORATION_* constants)public void drawString(java.lang.String str, int x, int y)
str
- the string to be drawn.x
- the x coordinate.y
- the y coordinate.public void drawChar(char character, int x, int y)
character
- - the character to be drawnx
- the x coordinate of the baseline of the texty
- the y coordinate of the baseline of the textpublic void drawChars(char[] data, int offset, int length, int x, int y)
data
- the array of characters to be drawnoffset
- the start offset in the datalength
- the number of characters to be drawnx
- the x coordinate of the baseline of the texty
- the y coordinate of the baseline of the textpublic void drawImage(Image img, int x, int y)
img
- the specified image to be drawn. This method does
nothing if img is null.x
- the x coordinate.y
- the y coordinate.public void drawImage(Image img, int x, int y, int w, int h)
img
- the specified image to be drawn. This method does
nothing if img is null.x
- the x coordinate.y
- the y coordinate.w
- the width to occupyh
- the height to occupypublic void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3)
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 trianglepublic void fillRadialGradient(int startColor, int endColor, int x, int y, int width, int height)
startColor
- the starting RGB colorendColor
- the ending RGB colorx
- the x coordinatey
- the y coordinatewidth
- the width of the region to be filledheight
- the height of the region to be filledpublic void fillRectRadialGradient(int startColor, int endColor, int x, int y, int width, int height, float relativeX, float relativeY, float relativeSize)
startColor
- the starting RGB colorendColor
- the ending RGB colorx
- the x coordinatey
- the y coordinatewidth
- the width of the region to be filledheight
- the height of the region to be filledrelativeX
- indicates the relative position of the gradient within the drawing regionrelativeY
- indicates the relative position of the gradient within the drawing regionrelativeSize
- indicates the relative size of the gradient within the drawing regionpublic void fillLinearGradient(int startColor, int endColor, int x, int y, int width, int height, boolean horizontal)
startColor
- the starting RGB colorendColor
- the ending RGB colorx
- the x coordinatey
- the y coordinatewidth
- the width of the region to be filledheight
- the height of the region to be filledhorizontal
- indicating wheter it is a horizontal fill or verticalpublic void fillRect(int x, int y, int w, int h, byte alpha)
x
- the x coordinate of the rectangle to be filledy
- the y coordinate of the rectangle to be filledw
- the width of the rectangle to be filledh
- the height of the rectangle to be filledalpha
- the alpha values specify semitransparencypublic void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
xPoints
- - a an array of x coordinates.yPoints
- - a an array of y coordinates.nPoints
- - a the total number of points.public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
xPoints
- - a an array of x coordinates.yPoints
- - a an array of y coordinates.nPoints
- - a the total number of points.public boolean isAlphaSupported()
public void setAlpha(int a)
a
- the alpha valuepublic int getAlpha()
public boolean isAntiAliasingSupported()
public boolean isAntiAliasedTextSupported()
public boolean isAntiAliased()
public void setAntiAliased(boolean a)
a
- true if anti aliasing is activepublic void setAntiAliasedText(boolean a)
a
- true if text anti aliasing is supportedpublic boolean isAntiAliasedText()
public boolean isAffineSupported()
public void resetAffine()
public void scale(float x, float y)
x
- scale factor for xy
- scale factor for ypublic void rotate(float angle)
angle
- the rotation angle in radianspublic void shear(float x, float y)
x
- shear factor for xy
- shear factor for ypublic java.lang.Object beginNativeGraphicsAccess()
When finished with the native graphics it is essential to invoke endNativeGraphicsAccess
public void endNativeGraphicsAccess()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |