public final class Graphics
extends java.lang.Object
Surfaces are objects that implement the GfxSurface interface. MainWindow and Image are both examples of surfaces.
Here is an example that uses Graphics to draw a line:
public class MyProgram extends MainWindow { public void onPaint(Graphics g) { g.foreColor = 0x0000FF; g.drawLine(0, 0, 10, 10); g.backColor = Color.MAGENTA; g.fillCircle(50,50,20); ...
Color
,
GfxSurface
Modifier and Type | Field and Description |
---|---|
int |
alpha
Alpha value used on operations, shifted by 24 bits left.
|
static byte |
ARROW_DOWN
used in the drawArrow method
|
static byte |
ARROW_LEFT
used in the drawArrow method
|
static byte |
ARROW_RIGHT
used in the drawArrow method
|
static byte |
ARROW_UP
used in the drawArrow method
|
int |
backColor
The background color, in 0xRRGGBB format.
|
int |
foreColor
The foreground color, in 0xRRGGBB format.
|
protected int |
height |
protected int[] |
ints |
boolean |
isVerticalText
States that the next calls to drawText will draw it vertically.
|
static int[] |
mainWindowPixels
Contains the pixels of the MainWindow.
|
static boolean |
needsUpdate
Defines if the screen has been changed.
|
static byte |
R3D_CHECK
used in the draw3dRect method
|
static byte |
R3D_EDIT
used in the draw3dRect method
|
static byte |
R3D_FILL
used in the draw3dRect method
|
static byte |
R3D_LOWERED
used in the draw3dRect method
|
static byte |
R3D_RAISED
used in the draw3dRect method
|
static byte |
R3D_SHADED
used in the draw3dRect method.
|
protected GfxSurface |
surface
The surface where this Graphics will draw on.
|
boolean |
useAA
Deprecated.
This is not used in OpenGL platforms
|
protected int |
width |
protected int[] |
xPoints |
protected int[] |
yPoints |
Constructor and Description |
---|
Graphics(GfxSurface surface)
Constructs a graphics object which can be used to draw on the given surface.
|
Modifier and Type | Method and Description |
---|---|
void |
clearClip()
Clears the current clipping rectangle.
|
boolean |
clip(Rect r)
Clips the specified rectangle to the clipping bounds.
|
static void |
compute3dColors(boolean enabled,
int backColor,
int foreColor,
int[] fourColors)
Prior to use draw3dRect, you must compute the colors.
|
void |
copyImageRect(Image src,
int x,
int y,
int width,
int height,
boolean doClip)
Copies a part of the given source image to here at the given position with the given draw operation and back
color.
|
void |
copyRect(GfxSurface surface,
int x,
int y,
int width,
int height,
int dstX,
int dstY)
Copies a rectangular area from a surface to the given coordinates on the current surface.
|
void |
dither(int x,
int y,
int w,
int h)
Apply a 16-bit Floyd-Steinberg dithering on the give region of the surface.
|
void |
dither(int x,
int y,
int w,
int h,
int ignoreColor)
Deprecated.
TotalCross 2 no longer uses parameter ignoreColor.
|
void |
draw3dRect(int x,
int y,
int width,
int height,
byte type,
boolean yMirror,
boolean simple,
int[] fourColors)
Draws a 3d rect, respecting the current user interface style.
|
void |
drawArc(int xc,
int yc,
int r,
double startAngle,
double endAngle)
Draws an arc, using the current foreground color as the outline color.
|
void |
drawArrow(int x,
int y,
int h,
byte type,
boolean pressed,
int foreColor)
Draws an arrow using the current foreground color.
|
void |
drawCircle(int xc,
int yc,
int r)
Draws a circle, using the current foreground color as the outline color.
|
void |
drawCylindricShade(int startColor,
int endColor,
int x,
int y,
int w,
int h)
Draws a cylindric shaded rectangle.
|
void |
drawDots(int Ax,
int Ay,
int Bx,
int By)
Draws a dotted line in any direction.
|
void |
drawDottedRect(int x,
int y,
int w,
int h)
Draws a dotted rectangle.
|
void |
drawEllipse(int xc,
int yc,
int rx,
int ry)
Draws an Ellipse, using the current foreground color as the outline color.
|
void |
drawEllipticalArc(int xc,
int yc,
int rx,
int ry,
double startAngle,
double endAngle)
Draws an elliptical arc, using the current foreground color as the outline color.
|
void |
drawEllipticalPie(int xc,
int yc,
int rx,
int ry,
double startAngle,
double endAngle)
Draws an elliptical pie slice, using the current foreground color as the outline color.
|
void |
drawImage(Image src,
int x,
int y)
Draws an image at the given absolute x and y coordinates.
|
void |
drawImage(Image image,
int x,
int y,
boolean doClip)
Draws the image in the given position with the given draw operation and back color.
|
void |
drawLine(int Ax,
int Ay,
int Bx,
int By)
Draws a line at any direction, using the current foreground color as the line color.
|
void |
drawLines(int... p)
Draws a set of connected lines from the given x,y coordinates array.
|
void |
drawPie(int xc,
int yc,
int r,
double startAngle,
double endAngle)
Draws a pie slice, using the current foreground color as the outline color.
|
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a polygon, using the current foreground color as the outline color.
|
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a sequence of connected lines, using the current foreground color as the outline color.
|
void |
drawRect(int x,
int y,
int w,
int h)
Draws a rectangle, using the current foreground color as the outline color.
|
void |
drawRoundGradient(int startX,
int startY,
int endX,
int endY,
int topLeftRadius,
int topRightRadius,
int bottomLeftRadius,
int bottomRightRadius,
int startColor,
int endColor,
boolean vertical)
Draws a rectangle with a gradient fill and optional rounded corners
|
void |
drawRoundRect(int x,
int y,
int width,
int height,
int r)
Draws a rectangle with rounded corners, using the current foreground color as the outline color.
|
void |
drawText(char[] chars,
int chrStart,
int chrCount,
int x,
int y)
Draws a text with the current font and the current foregrount color.
|
void |
drawText(char[] chars,
int chrStart,
int chrCount,
int x,
int y,
boolean shadow,
int shadowColor) |
void |
drawText(java.lang.StringBuffer sb,
int chrStart,
int chrCount,
int x,
int y,
boolean shadow,
int shadowColor) |
void |
drawText(java.lang.StringBuffer sb,
int chrStart,
int chrCount,
int x,
int y,
int justifyWidth,
boolean shadow,
int shadowColor) |
void |
drawText(java.lang.String text,
int x,
int y)
Draws a text with the current font and the current foregrount color.
|
void |
drawText(java.lang.String text,
int x,
int y,
boolean shadow,
int shadowColor) |
void |
drawText(java.lang.String text,
int x,
int y,
int justifyWidth)
Draws a text with the current font and the current foregrount color, justifying it to the given width.
|
void |
drawText(java.lang.String text,
int x,
int y,
int justifyWidth,
boolean shadow,
int shadowColor) |
void |
drawThickLine(int x1,
int y1,
int x2,
int y2,
int t)
Draws a thick line.
|
void |
drawVerticalText(java.lang.String text,
int x,
int y)
Draws a VERTICAL text with the current font and the current foregrount color.
|
void |
drawVistaRect(int x,
int y,
int width,
int height,
int topColor,
int rightColor,
int bottomColor,
int leftColor)
Draws a shaded rectangle.
|
void |
drawWindowBorder(int xx,
int yy,
int ww,
int hh,
int titleH,
int footerH,
int borderColor,
int titleColor,
int bodyColor,
int footerColor,
int thickness,
boolean drawSeparators) |
void |
expandClipLimits(int dx1,
int dy1,
int dx2,
int dy2)
Expands the clipping limits.
|
static void |
fadeScreen(int fadeValue)
Fades all window pixels with the given value.
|
void |
fillCircle(int xc,
int yc,
int r)
Fills a circle, using the current background color as the fill color.
|
void |
fillCircleGradient(int xc,
int yc,
int r)
Fills a circle, using a gradient from the foreground color to the background color.
|
void |
fillEllipse(int xc,
int yc,
int rx,
int ry)
Fills an Ellipse, using the current background color as the fill color.
|
void |
fillEllipseGradient(int xc,
int yc,
int rx,
int ry)
Fills a gradient Ellipse, using a gradient from the foreground color to the background color.
|
void |
fillEllipticalPie(int xc,
int yc,
int rx,
int ry,
double startAngle,
double endAngle)
Fills an elliptical pie slice, using the current background color as the fill color and the current foreground
color as the outline color.
|
void |
fillEllipticalPieGradient(int xc,
int yc,
int rx,
int ry,
double startAngle,
double endAngle)
Fills an elliptical pie slice, using a gradient from the foreground color to the background color.
|
void |
fillPie(int xc,
int yc,
int r,
double startAngle,
double endAngle)
Fills a pie slice, using the current background color as the fill color and the current foreground color as the
outline color.
|
void |
fillPieGradient(int xc,
int yc,
int r,
double startAngle,
double endAngle)
Fills a pie slice, using a gradient from the foreground color to the background color.
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Fills a polygon, using the current background color as the fill color.
|
void |
fillPolygonGradient(int[] xPoints,
int[] yPoints,
int nPoints)
Fills a vertical gradient polygon, mixing from the foreground color to the background color.
|
void |
fillRect(int x,
int y,
int w,
int h)
Fills a rectangle, using the current background color as the fill color.
|
void |
fillRoundRect(int xx,
int yy,
int width,
int height,
int r)
Fills a rectangle with rounded corners, using the current background color as the fill color.
|
void |
fillShadedRect(int x,
int y,
int width,
int height,
boolean invert,
boolean rotate,
int c1,
int c2,
int factor)
Fills a shaded rectangle.
|
void |
fillVistaRect(int x,
int y,
int width,
int height,
int back,
boolean invert,
boolean rotate)
Fills a shaded rectangle.
|
void |
getAnglePoint(int xc,
int yc,
int rx,
int ry,
int angle,
Coord out)
Gets the coordinates where the specified point lies.
|
Rect |
getClip(Rect r)
Gets the current clipping rectangle.
|
int |
getClipHeight()
Returns the clip's height
|
int |
getClipWidth()
Returns the clip's width
|
static int[] |
getPalette()
Returns the palette used when the screen has 8 bpp.
|
int |
getPixel(int x,
int y)
Gets the pixel color at given position in the 0x00RRGGBB format.
|
int |
getRGB(int[] data,
int offset,
int x,
int y,
int w,
int h)
Gets raw RGB data from a rectangular region of the surface this graphic s drawing to and stores it in the provided
array.
|
Coord |
getTranslation()
Returns the current translation from the origin for this Graphics object.
|
boolean |
isControlSurface()
Returns true if the source surface is from a Control (if false, its an Image).
|
void |
refresh(int sx,
int sy,
int sw,
int sh,
int tx,
int ty,
Font f)
Refreshes the clipping bounds, translation and font for this Graphics.
|
void |
setClip(int x,
int y,
int w,
int h)
Sets the clipping rectangle, translated to the current translated origin.
|
void |
setClip(Rect r)
Sets the clipping rectangle, translated to the current translated origin.
|
void |
setFont(Font font)
Sets the current font for operations that draw text.
|
void |
setPixel(int x,
int y)
Sets the pixel at the specified position, using the current foreground color as the pixel color.
|
void |
setPixels(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a sequence of points, using the current foreground color.
|
int |
setRGB(int[] data,
int offset,
int x,
int y,
int w,
int h)
Sets raw RGB data of a rectangular region of the surface this graphic s drawing to copying it from the provided
array.
|
java.lang.String |
toString() |
void |
translate(int dx,
int dy)
Translates the origin of the of the current coordinate system by the given dx and dy.
|
public int foreColor
public int backColor
@Deprecated public boolean useAA
protected int width
protected int height
public int alpha
public boolean isVerticalText
drawVerticalText(String, int, int)
protected GfxSurface surface
protected int[] xPoints
protected int[] yPoints
protected int[] ints
public static boolean needsUpdate
public static int[] mainWindowPixels
public static final byte R3D_EDIT
public static final byte R3D_LOWERED
public static final byte R3D_RAISED
public static final byte R3D_CHECK
public static final byte R3D_SHADED
public static final byte R3D_FILL
public static final byte ARROW_UP
public static final byte ARROW_DOWN
public static final byte ARROW_LEFT
public static final byte ARROW_RIGHT
public Graphics(GfxSurface surface)
Only totalcross.ui.Control and totalcross.ui.image.Image classes can have a graphics. Trying to create it with another class will result in a runtime exception.
If you are trying to create a graphics object for drawing in a subclass of control, use the getGraphics() method in the Control class.
Control.getGraphics()
public boolean isControlSurface()
public static void fadeScreen(int fadeValue)
for (int i = 0; i < 256; i++) { Graphics.fadeScreen(1); updateScreen(); }And now how to fade it back:
for (int i = 256; --i >= 0;) { enableUpdateScreen = false; for (int j = 0, n = zStack.size(); j < n; j++) { // repaints every window, from the nearest with the MainWindow size to last parent ((Window) zStack.items[j]).repaintNow(); } enableUpdateScreen = true; Graphics.fadeScreen(i); updateScreen(); }You may want to add a delay in the fade out, since its much faster than the fade in.
Window.fadeOtherWindows
,
Window.fadeValue
public void refresh(int sx, int sy, int sw, int sh, int tx, int ty, Font f)
public void expandClipLimits(int dx1, int dy1, int dx2, int dy2)
public static int[] getPalette()
public void drawEllipse(int xc, int yc, int rx, int ry)
xc
- x coordinate of the center of the ellipseyc
- y coordinate of the center of the ellipserx
- radix x of the ellipsery
- radix y of the ellipsepublic void fillEllipse(int xc, int yc, int rx, int ry)
xc
- x coordinate of the center of the ellipseyc
- y coordinate of the center of the ellipserx
- radix x of the ellipsery
- radix y of the ellipsepublic void fillEllipseGradient(int xc, int yc, int rx, int ry)
xc
- x coordinate of the center of the ellipseyc
- y coordinate of the center of the ellipserx
- radix x of the ellipsery
- radix y of the ellipsepublic void drawArc(int xc, int yc, int r, double startAngle, double endAngle)
xc
- x coordinate of the center of the circle that contains the arc.yc
- y coordinate of the center of the circle that contains the arc.r
- radix of the circle that contains the arcstartAngle
- starting angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.endAngle
- ending angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.public void drawPie(int xc, int yc, int r, double startAngle, double endAngle)
xc
- x coordinate of the center of the circle that contains the arc.yc
- y coordinate of the center of the circle that contains the arc.r
- radix of the circle that contains the piestartAngle
- starting angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.endAngle
- ending angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.public void fillPie(int xc, int yc, int r, double startAngle, double endAngle)
xc
- x coordinate of the center of the circle that contains the arc.yc
- y coordinate of the center of the circle that contains the arc.r
- radix of the circle that contains the piestartAngle
- starting angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.endAngle
- ending angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.public void fillPieGradient(int xc, int yc, int r, double startAngle, double endAngle)
xc
- x coordinate of the center of the circle that contains the arc.yc
- y coordinate of the center of the circle that contains the arc.r
- radix of the circle that contains the piestartAngle
- starting angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.endAngle
- ending angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.public void drawEllipticalArc(int xc, int yc, int rx, int ry, double startAngle, double endAngle)
xc
- x coordinate of the center of the circle that contains the arc.yc
- y coordinate of the center of the circle that contains the arc.rx
- x radix of the circle that contains the piery
- y radix of the circle that contains the piestartAngle
- starting angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.endAngle
- ending angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.public void drawEllipticalPie(int xc, int yc, int rx, int ry, double startAngle, double endAngle)
xc
- x coordinate of the center of the circle that contains the arc.yc
- y coordinate of the center of the circle that contains the arc.rx
- x radix of the circle that contains the piery
- y radix of the circle that contains the piestartAngle
- starting angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.endAngle
- ending angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.public void fillEllipticalPie(int xc, int yc, int rx, int ry, double startAngle, double endAngle)
xc
- x coordinate of the center of the circle that contains the arc.yc
- y coordinate of the center of the circle that contains the arc.rx
- x radix of the circle that contains the piery
- y radix of the circle that contains the piestartAngle
- starting angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.endAngle
- ending angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.public void fillEllipticalPieGradient(int xc, int yc, int rx, int ry, double startAngle, double endAngle)
xc
- x coordinate of the center of the circle that contains the arc.yc
- y coordinate of the center of the circle that contains the arc.rx
- x radix of the circle that contains the piery
- y radix of the circle that contains the piestartAngle
- starting angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.endAngle
- ending angle of the arc. It must be between 0 and 360 (degrees). 0º is at 3 o'clock.public void drawCircle(int xc, int yc, int r)
xc
- x coordinate of the center of the circleyc
- y coordinate of the center of the circler
- radix of the circlepublic void fillCircle(int xc, int yc, int r)
xc
- x coordinate of the center of the circleyc
- y coordinate of the center of the circler
- radix of the circlepublic void fillCircleGradient(int xc, int yc, int r)
xc
- x coordinate of the center of the circleyc
- y coordinate of the center of the circler
- radix of the circlepublic int getPixel(int x, int y)
pixel & 0xFFFFFF
.x
- x coordinate of the pixely
- y coordinate of the pixelpublic void setPixel(int x, int y)
x
- x coordinate of the pixely
- y coordinate of the pixelpublic void drawLine(int Ax, int Ay, int Bx, int By)
Ax
- x coordinate of the start of the line.Ay
- y coordinate of the start of the line.Bx
- x coordinate of the end of the line.By
- y coordinate of the end of the line.public void drawDots(int Ax, int Ay, int Bx, int By)
Ax
- x coordinate of the start of the line.Ay
- y coordinate of the start of the line.Bx
- x coordinate of the end of the line.By
- y coordinate of the end of the line.public void drawRect(int x, int y, int w, int h)
x
- left coordinate of the rectangley
- top coordinate of the rectanglew
- width of the rectangle. the rectangle is drawn from x to x+w-1.h
- height of the rectangle. the rectangle is drawn from y to y+h-1.public void fillRect(int x, int y, int w, int h)
x
- left coordinate of the rectangley
- top coordinate of the rectanglew
- width of the rectangle. the rectangle is filled from x to x+w-1.h
- height of the rectangle. the rectangle is filled from y to y+h-1.public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
xPoints
- the array with the x coordinate pointsyPoints
- the array with the y coordinate pointsnPoints
- the total number of point to be drawnpublic void fillPolygonGradient(int[] xPoints, int[] yPoints, int nPoints)
xPoints
- the array with the x coordinate pointsyPoints
- the array with the y coordinate pointsnPoints
- the total number of point to be drawnpublic void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
xPoints
- the array with the x coordinate pointsyPoints
- the array with the y coordinate pointsnPoints
- the total number of point to be drawnpublic void drawDottedRect(int x, int y, int w, int h)
x
- left coordinate of the rectangley
- top coordinate of the rectanglew
- width of the rectangle. the rectangle is drawn from x to x+w-1.h
- height of the rectangle. the rectangle is drawn from y to y+h-1.public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
xPoints
- the array with the x coordinate pointsyPoints
- the array with the y coordinate pointsnPoints
- the total number of point to be drawnpublic void setPixels(int[] xPoints, int[] yPoints, int nPoints)
xPoints
- the array with the x coordinate pointsyPoints
- the array with the y coordinate pointsnPoints
- the total number of point to be drawnpublic void drawText(char[] chars, int chrStart, int chrCount, int x, int y, boolean shadow, int shadowColor)
public void drawText(java.lang.StringBuffer sb, int chrStart, int chrCount, int x, int y, boolean shadow, int shadowColor)
public void drawText(java.lang.StringBuffer sb, int chrStart, int chrCount, int x, int y, int justifyWidth, boolean shadow, int shadowColor)
public void drawText(java.lang.String text, int x, int y, boolean shadow, int shadowColor)
public void drawText(java.lang.String text, int x, int y, int justifyWidth, boolean shadow, int shadowColor)
public void drawText(char[] chars, int chrStart, int chrCount, int x, int y)
chars
- the character array to displaychrStart
- the start position in arraychrCount
- the number of characters to displayx
- the left coordinate of the text's bounding boxy
- the top coordinate of the text's bounding boxpublic void drawText(java.lang.String text, int x, int y)
text
- the text to be drawnx
- x coordinate of the texty
- y coordinate of the textpublic void drawVerticalText(java.lang.String text, int x, int y)
g.isVerticalText = true; g.drawText(text, x, y); g.isVerticalText = false;
text
- the text to be drawnx
- x coordinate of the texty
- y coordinate of the textpublic void drawText(java.lang.String text, int x, int y, int justifyWidth)
font.fm.height - font.fm.ascent
as the justifyWidth.text
- the text to be drawnx
- x coordinate of the texty
- y coordinate of the textjustifyWidth
- The width to justify the text to.isVerticalText
,
drawVerticalText(String, int, int)
public void drawRoundRect(int x, int y, int width, int height, int r)
x
- left coordinate of the rectangley
- top coordinate of the rectanglewidth
- width of the rectangle. the rectangle is drawn from x to x+w-1.height
- height of the rectangle. the rectangle is drawn from y to y+h-1.r
- radix of the circle at the corners. If its greater than width/2 or greater than height/2, it will be
adjusted to the minimum of both values.public void fillRoundRect(int xx, int yy, int width, int height, int r)
xx
- left coordinate of the rectangleyy
- top coordinate of the rectanglewidth
- width of the rectangle. the rectangle is filled from x to x+w-1.height
- height of the rectangle. the rectangle is filled from y to y+h-1.r
- radix of the circle at the corners. If its greater than width/2 or greater than height/2, it will be
adjusted to the minimum of both values.public void setClip(int x, int y, int w, int h)
x
- left coordinate of the rectangley
- top coordinate of the rectanglew
- width of the rectangle. the rectangle is filled from x to x+w-1.h
- height of the rectangle. the rectangle is filled from y to y+h-1.public void setClip(Rect r)
r
- the rectangle with the clipping coordinatespublic Rect getClip(Rect r)
r
- a Rect object where the clip coordinates will be stored and returned.public int getClipWidth()
public int getClipHeight()
public boolean clip(Rect r)
r
- The coordinates of the rectangle that are to be adjusted to match the clipping bounds.public void clearClip()
public void translate(int dx, int dy)
dx
- the delta x of the x coordinate translation. the new x origin coordinate will be x + dxdy
- the delta y of the y coordinate translation. the new y origin coordinate will be y + dypublic void copyRect(GfxSurface surface, int x, int y, int width, int height, int dstX, int dstY)
surface
- the surface to copy fromx
- the source x coordinatey
- the source y coordinatewidth
- the width of the area on the source surfaceheight
- the height of the area on the source surfacedstX
- the destination x location on the current surfacedstY
- the destination y location on the current surfacepublic void setFont(Font font)
public Coord getTranslation()
public void drawRoundGradient(int startX, int startY, int endX, int endY, int topLeftRadius, int topRightRadius, int bottomLeftRadius, int bottomRightRadius, int startColor, int endColor, boolean vertical)
startX
- x coordinate of the top-left pixelstartY
- y coordinate of the top-left pixelendX
- x coordinate of the bottom-right pixelendY
- y coordinate of the bottom-right pixeltopLeftRadius
- Radius (in pixels) of the top-left corner. A value of zero means that this corner will not be
roundedtopRightRadius
- Radius (in pixels) of the top-right corner. A value of zero means that this corner will not
be roundedbottomLeftRadius
- Radius (in pixels) of the bottom-left corner. A value of zero means that this corner will
not be roundedbottomRightRadius
- Radius (in pixels) of the bottom-right corner. A value of zero means that this corner
will not be roundedstartColor
- The color value for the top of the rectangleendColor
- The color value for the bottom of the rectanglevertical
- True to be a vertical gradient, false to be a horizontal onepublic void drawImage(Image image, int x, int y, boolean doClip)
Deprecated use: backColor forces the transparentColor of the Image, and is ignored when drawOp is DRAW_PAINT.
Preferred use: when backColor
is -1, the transparentColor is the one which has been defined for this
Image, using Image.transparentColor
. Note that for a GIF Image, the transparent pixel is
automatically set from the image's information.
The parameter doClip must be used with caution. If false, it will not do any clipping checks (what may improve drawings in 8%). Set it to true only when you're sure that the image will not pass the current surface bounds. Otherwise, be prepared to even hard-reset your device!
public void copyImageRect(Image src, int x, int y, int width, int height, boolean doClip)
Deprecated use: backColor forces the transparentColor of the Image, and is ignored when drawOp is DRAW_PAINT.
Preferred use: when backColor
is -1, the transparentColor is the one which has been defined for this
Image, using Image.transparentColor
. Note that for a GIF Image, the transparent pixel is
automatically set from the image's information.
The parameter doClip must be used with caution. If false, it will not do any clipping checks (what may improve drawings in 8%). Set it to true only when you're sure that the image will not pass the current surface bounds. Otherwise, be prepared to even hard-reset your device!
public void drawImage(Image src, int x, int y)
public static void compute3dColors(boolean enabled, int backColor, int foreColor, int[] fourColors)
public void drawVistaRect(int x, int y, int width, int height, int topColor, int rightColor, int bottomColor, int leftColor)
public void fillVistaRect(int x, int y, int width, int height, int back, boolean invert, boolean rotate)
public void fillShadedRect(int x, int y, int width, int height, boolean invert, boolean rotate, int c1, int c2, int factor)
public void draw3dRect(int x, int y, int width, int height, byte type, boolean yMirror, boolean simple, int[] fourColors)
x
- the x positiony
- the y positionwidth
- the width of the rectangleheight
- the height of the rectangletype
- one of the R3D constantsyMirror
- no longer usedsimple
- if true, a simple rectangle will be drawnfourColors
- the four colors used if ui style is WinCER3D_EDIT
,
R3D_LOWERED
,
R3D_RAISED
,
R3D_CHECK
,
R3D_SHADED
public java.lang.String toString()
toString
in class java.lang.Object
public void drawArrow(int x, int y, int h, byte type, boolean pressed, int foreColor)
x
- the x position from where the draw will starty
- the y position from where the draw will starth
- is the height (or width, if left/right arrows) in pixels. 1st line has 1 pixel, 2nd line has 3, 3rd line
has 5, etc. Must be >= 2 or no arrow is drawn.type
- one of the ARROW_ constants.pressed
- if true, x and y are shifted by one pixelforeColor
- the foreground color to be used. This Graphic's fore color is changed after this method is
called.
Example:
public void onPaint(Graphics g) { g.drawArrow(30,30,8, Graphics.ARROW_LEFT, false, Color.BLACK ); ...
ARROW_DOWN
,
ARROW_LEFT
,
ARROW_RIGHT
,
ARROW_UP
public void getAnglePoint(int xc, int yc, int rx, int ry, int angle, Coord out)
xc
- x coordinate of the center of the circleyc
- y coordinate of the center of the circlerx
- x radix of the circle that contains the point. Maximum rx value is 8000; above this, the result is
unpredictable.ry
- y radix of the circle that contains the point. Maximum ry value is 8000; above this, the result is
unpredictable.angle
- angle of the point. It should be between 0 and 360 (degrees). 0º is at 3 o'clock.out
- the Coord with the x,y pointspublic int getRGB(int[] data, int offset, int x, int y, int w, int h)
data
- Array where the RGB data will be stored.offset
- Offset into the data array to start writing to.x
- Left edge of the region to copy from.y
- Top edge of the region to copy from.w
- Width of the region to copy from.h
- Height of the region to copy from.java.lang.ArrayIndexOutOfBoundsException
- If the data array is not big enough to hold the RGB values.public int setRGB(int[] data, int offset, int x, int y, int w, int h)
Important: the data is in RAW format, so this method only works if the data was retrieved using getRGB.
data
- Array where the RGB data is stored.offset
- Offset into the data array to start reading from.x
- Left edge of the region to copy to.y
- Top edge of the region to copy to.w
- Width of the region to copy to.h
- Height of the region to copy to.java.lang.ArrayIndexOutOfBoundsException
- If the data array has not enough RGB values.public void drawWindowBorder(int xx, int yy, int ww, int hh, int titleH, int footerH, int borderColor, int titleColor, int bodyColor, int footerColor, int thickness, boolean drawSeparators)
public void drawCylindricShade(int startColor, int endColor, int x, int y, int w, int h)
public void onPaint(Graphics g) { g.drawCylindricShade(0xB6D3E8, 0xF2F4F6, 0, 0, width, height); }
public void drawThickLine(int x1, int y1, int x2, int y2, int t)
public void drawLines(int... p)
@Deprecated public void dither(int x, int y, int w, int h, int ignoreColor)
public void dither(int x, int y, int w, int h)