ewe.fx
Class Graphics

java.lang.Object
  extended byewe.fx.Graphics
All Implemented Interfaces:
CellConstants, ControlConstants, UIConstants
Direct Known Subclasses:
mGraphics, RotatedGraphics

public class Graphics
extends Object
implements UIConstants

Graphics draws on a surface.

Surfaces are objects that implement the ISurface interface. Window, Image and PrinterJob are examples of surfaces.

Note the following important points about using Graphics objects:

Always call free() on a Graphics when you are finished drawing on it. Graphics objects use limited system resources and although they are automatically free()'ed when they are garbage collected, the system may run out of graphics resources before this happens. Do not use a Graphics after freeing it.

Call flush() when you absolutely want all previous drawing operations to be written to the surface. Although this is not necessary for most Graphics objects, certain implementations (e.g. RotatedGraphics) may cache all operations in memory before sending them to the destination surface. So if you want to hang on to a Graphics to be used again later, call flush() in between using it to ensure that the operations show up on the screen. Calling free() will automatically flush() the graphics, so if you use free() there is no need to use flush().

Use Control.getGraphics() to get a Graphics to draw on a Control If getGraphics() returns null, it means that no part of the Control is visible and you should not attempt to draw on it.

Note that some Graphics operations require that data be able to be read from the destination surface. This includes drawing images with transparent regions, or using OR/AND/XOR operations. This is always possible on an Image surface, but may not always be possible from a Window surface. It should be considered never possible on a PrinterJob surface.

The static variable canCopy indicates whether copying is possible from a Window surface, or you can call the canCopyFrom() method on an individual Graphics object to determine if it is possible to do these operations on that Graphics object.

However to make things simpler and fully portable it is best to use BufferedGraphics to draw on a Control if the Control is going to display images with transparent areas, or if special draw ops are to be used. A BufferedGraphics will create a temporary Graphics object IF the actual Graphics returned by Control.getGraphics() cannot perform these types of operations.


Field Summary
 Color background
           
static boolean canAlphaBlend
           
static boolean canCopy
           
static boolean canMove
           
 Color color
           
static int DRAW_ALPHA
          This is used for drawing images.
static int DRAW_AND
          The constant for a draw operation that AND's the source with the destination.
static int DRAW_OR
          The constant for a draw operation that OR's the source with the destination.
static int DRAW_OVER
          The constant for a draw operation that draws the source over the destination.
static int DRAW_XOR
          The constant for a draw operation that XOR's the source with the destination.
static Color LighterGray
           
static int SPECIAL_TICK
           
static int SPECIAL_X
           
 
Fields inherited from interface ewe.ui.UIConstants
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
 
Fields inherited from interface ewe.ui.CellConstants
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
 
Fields inherited from interface ewe.ui.ControlConstants
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
 
Constructor Summary
Graphics(ISurface surface)
          Constructs a graphics object which can be used to draw on the given surface.
Graphics(ISurface surface, boolean forCopying)
           
Graphics(Object nativeGraphics)
           
 
Method Summary
 void anchor(Rect subArea, Rect largeArea, int anchor)
          Modify subArea so that it is anchored appropriately in largeArea.
 boolean canCopyFrom()
          This returns true if you can do a bitBlt() using this Graphics object as a source.
 void changeBrush(Color c, int style)
           
 void changePen(Color c, int style, int thickness)
           
 void clearClip()
          Clears the current clipping rectangle.
 boolean copyRect(Graphics source, int x, int y, int width, int height, int destX, int destY)
           
 boolean copyRect(Graphics source, Rect sourceArea, Rect destArea, Mask mask)
          Copy and scale an area from another Graphics object to this one, using the optional Mask.
 void copyRect(ISurface 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.
static Graphics createNew(ISurface is)
           
 void draw3DDiamond(Rect rect, boolean pressed, Color back)
           
 void draw3DDiamond(Rect rect, boolean pressed, Color back, boolean amFlat)
           
 void draw3DRect(Rect r, int style, boolean flat, Color fill, Color outlineColor)
           
 void draw3DRect(Rect r, int style, boolean flat, Color fill, Color outlineColor, int labelWidth)
           
 void drawArc(int x, int y, int width, int height, float startAngle, float angle)
          Draws the outline of a circular or elliptical arc covering the specified rectangle.
 void drawArrow(Rect r, int which)
           
 void drawChar(char which, int x, int y, int options)
           
 void drawClosedArc(int x, int y, int width, int height, float startAngle, float angle)
          Draws the outline of a circular or elliptical arc covering the specified rectangle, and includes lines that connect the end and start point of the arc to each other (ie the connecting chord).
 void drawCursor(int x, int y, int width, int height)
          Draws a cursor by XORing the given rectangular area on the surface.
 void drawDiamond(Rect r, int which)
           
 void drawDots(int x1, int y1, int x2, int y2)
          Draws a dotted line at the given coordinates.
 void drawEdge(Rect r, int edge, int flags, int labelWidth)
           
 void drawEllipse(int x, int y, int width, int height)
           
 void drawFormattedText(char[] s, int start, int length, int x, int y, FormattedTextSpecs fts)
           
 void drawFormattedText(String s, int x, int y, FormattedTextSpecs fts)
           
 void drawFormattedText(String s, int start, int length, int x, int y, FormattedTextSpecs fts)
           
 void drawHorizontalTriangle(Rect bounds, boolean left)
           
 void drawImage(IImage image, int imageDrawOptions, Rect dest, int anchor)
           
 void drawImage(Image image, Image mask, Color transparent, int x, int y, int width, int height)
           
 void drawImage(Image image, Image mask, Color transparent, Rect sourceImageArea, Rect destArea, int scaleOptions)
          This will draw and scale a portion of an image into the destination area.
 void drawImage(Image image, int x, int y)
          Draws an image without transparencies at the given x and y coordinates.
 void drawImage(Image image, int sx, int sy, int swidth, int sheight, int dx, int dy, int dwidth, int dheight)
           
 void drawLine(int x1, int y1, int x2, int y2)
          Draws a line at the given coordinates.
 void drawLineRGB(int x1, int y1, int x2, int y2, int rgb)
          This is a fast way of drawing a solid line of thickness 1 of a particular color.
 void drawLines(int[] x, int[] y, int count)
           
 void drawPie(int x, int y, int width, int height, float startAngle, float angle)
          Draws the outline of a circular or elliptical arc covering the specified rectangle, and includes lines that connect the end and start point of the arc to the center of the ellipse.
 void drawPolygon(int[] x, int[] y, int count)
          Draws the outline of a polygon with the given coordinates.
 void drawRect(int x, int y, int width, int height)
          Draws a rectangle at the given coordinates.
 void drawRect(int x, int y, int width, int height, int thickness)
           
 void drawRoundRect(int x, int y, int width, int height, int radius)
          Draw a rectangle with rounded corners.
 void drawSpecial(int what, Rect where, Color c)
           
protected  void drawTail(Rect r, int which)
           
 void drawText(char[] chars, int start, int count, int x, int y)
          Draws text at the given coordinates.
 void drawText(FontMetrics fm, String[] lines, Rect where, int alignment, int anchor)
           
 void drawText(FontMetrics fm, String[] lines, Rect where, int alignment, int anchor, int startLine, int endLine)
           
 void drawText(FontMetrics fm, String[] lines, Rect where, int alignment, int anchor, int startLine, int endLine, FormattedTextSpecs fts)
           
 void drawText(String s, int x, int y)
          Draws text at the given coordinates.
protected  void drawTextIn(FontMetrics fm, String[] lines, Rect where, int alignment, int start, int end, FormattedTextSpecs fts)
           
 void drawVerticalTriangle(Rect bounds, boolean up)
           
 void fillClosedArc(int x, int y, int width, int height, float startAngle, float angle)
          Draws the outline of a circular or elliptical arc covering the specified rectangle, and includes lines that connect the end and start point of the arc to each other (ie the connecting chord).
 void fillEllipse(int x, int y, int width, int height)
           
 void fillPie(int x, int y, int width, int height, float startAngle, float angle)
          Draws and fills the outline of a circular or elliptical arc covering the specified rectangle, and includes lines that connect the end and start point of the arc to the center of the ellipse.
 void fillPolygon(int[] x, int[] y, int count)
          Draws a filled polygon with the given coordinates.
 void fillRect(int x, int y, int width, int height)
          Fills a rectangular area with the current color.
 void fillRectRGB(int x1, int y1, int x2, int y2, int rgb)
          This is a fast way of setting pixel to a particular color.
 void fillRoundRect(int x, int y, int width, int height, int radius)
          Fill a rectangle with rounded corners.
 void flush()
          On some systems it may be necessary to call this method to have operations made to the Graphics actually be displayed on the screen.
 void free()
          Frees any system resources (native device contexts) associated with the graphics object.
protected static Object[] getArcPoints(int xc, int yc, int rx, int rw, float startAngle, float endAngle, int flags)
           
 Color getBackground()
           
 Brush getBrush()
           
 Rect getClip(Rect r)
          Sets the x, y, width and height coordinates in the rectangle passed to the current clip coordinates.
 Color getColor()
           
static Graphics getEmptyGraphics()
           
 FontMetrics getFontMetrics(Font font)
          Get a FontMetrics for the font on the ISurface for this Graphics.
static Image getImage(int w, int h)
           
 Pen getPen()
           
static void getSize(FontMetrics fm, String[] lines, int start, int end, Dimension dest)
           
static void getSize(FontMetrics fm, String[] lines, int start, int end, Dimension dest, FormattedTextSpecs fts)
           
static void getSize(FontMetrics fm, String line, Dimension d)
           
static void getSize(FontMetrics fm, String line, Dimension d, FormattedTextSpecs fts)
           
 int getSurfaceType()
          Find out the surface type for the Graphics - which will be one of the XXX_SURFACE values.
 double[] getTransform(double[] dest)
           
 boolean isEmpty()
           
 boolean isValid()
           
static int mapColor(int value)
          This is used to map an RGB color from user space into device space.
 void moveRect(int x, int y, int width, int height, int dstX, int dstY)
          This copies a rectangular area in a Graphics to a different location within itself in the most effecient way.
protected  void nativeSetBrush(Brush b)
           
protected  void nativeSetPen(Pen p)
           
 Rect reduceClip(int x, int y, int width, int height, Rect oldClip)
          This alters the clipping region of the current graphics to be the intersection of the original clipping region and the newly specified region.
 Rect reduceClip(Rect newRect)
          This alters the clipping region of the current graphics to be the intersection of the original clipping region and the newly specified region.
 void reset()
           
 void restoreClip(Rect r)
          Use this with a Rect value returned from reduceClip()
 void setBackground(Color c)
           
 void setBackground(int r, int g, int b)
           
 Brush setBrush(Brush newBrush)
           
 void setClip(int x, int y, int width, int height)
          Sets a clipping rectangle.
 void setColor(Color c)
           
 void setColor(int r, int g, int b)
          Sets the current color for drawing operations.
 void setDrawOp(int drawOp)
          Sets the drawing operation.
 void setFont(Font font)
          Sets the current font for operations that draw text.
 Pen setPen(Pen newPen)
           
 void setPixelRGB(int x, int y, int rgb)
          This is a fast way of setting pixel to a particular color.
 void setTransform(double[] transforms)
           
 double[] transform(double[] transform, double[] oldTransform)
           
 void translate(int x, int y)
          Translates the origin of the current coordinate system by the given x and y values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Field Detail

color

public Color color

background

public Color background

canAlphaBlend

public static boolean canAlphaBlend

canCopy

public static boolean canCopy

canMove

public static boolean canMove

DRAW_OVER

public static final int DRAW_OVER
The constant for a draw operation that draws the source over the destination.

See Also:
Constant Field Values

DRAW_AND

public static final int DRAW_AND
The constant for a draw operation that AND's the source with the destination. Commonly used to create image masks.

See Also:
Constant Field Values

DRAW_OR

public static final int DRAW_OR
The constant for a draw operation that OR's the source with the destination. Commonly used with image masks.

See Also:
Constant Field Values

DRAW_XOR

public static final int DRAW_XOR
The constant for a draw operation that XOR's the source with the destination.

See Also:
Constant Field Values

DRAW_ALPHA

public static final int DRAW_ALPHA
This is used for drawing images. It explicitly tells the system to use the ALPHA channel when drawing images.

See Also:
Constant Field Values

LighterGray

public static Color LighterGray

SPECIAL_TICK

public static final int SPECIAL_TICK
See Also:
Constant Field Values

SPECIAL_X

public static final int SPECIAL_X
See Also:
Constant Field Values
Constructor Detail

Graphics

public Graphics(ISurface surface)
Constructs a graphics object which can be used to draw on the given surface. For the sake of the methods in this class, the given surface is known as the "current surface".

If you are trying to create a graphics object for drawing in a subclass of control, use the createGraphics() method in the Control class. It creates a graphics object and translated the origin to the origin of the control.


Graphics

public Graphics(ISurface surface,
                boolean forCopying)

Graphics

public Graphics(Object nativeGraphics)
Method Detail

mapColor

public static int mapColor(int value)
This is used to map an RGB color from user space into device space. This is needed because although you may set the value of an image pixel to be a particular value, when you read back from that image you may discover the value to be different. This is caused by the system re-mapping the color to within its own color map. This method does its best to tell you how a specific color will be mapped when written to an image.

Parameters:
value - The RGB color to check.
Returns:
The RGB color it will map to.

setBackground

public void setBackground(int r,
                          int g,
                          int b)

setBackground

public void setBackground(Color c)

getSurfaceType

public int getSurfaceType()
Find out the surface type for the Graphics - which will be one of the XXX_SURFACE values.


canCopyFrom

public boolean canCopyFrom()
This returns true if you can do a bitBlt() using this Graphics object as a source.


clearClip

public void clearClip()
Clears the current clipping rectangle. This allows drawing to occur anywhere on the current surface.


isValid

public boolean isValid()

moveRect

public void moveRect(int x,
                     int y,
                     int width,
                     int height,
                     int dstX,
                     int dstY)
This copies a rectangular area in a Graphics to a different location within itself in the most effecient way. It is guaranteed to work, even if the source and destination areas overlap. Note that it will not work if the canMove variable is false.

Parameters:
x -
y -
width -
height -
dstX -
dstY -

copyRect

public void copyRect(ISurface 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. The copy operation is performed by combining pixels according to the setting of the current drawing operation. The same surface can be used as a source and destination to implement quick scrolling.

Not all combinations of surfaces are supported on all platforms. PalmOS has problems copying from an Window surface to an Image and between two Image surfaces. Java doesn't allow copying from an Window surface to an Image.

Parameters:
surface - the surface to copy from
x - the source x coordinate
y - the source y coordinate
width - the width of the area on the source surface
height - the height of the area on the source surface
dstX - the destination x location on the current surface
dstY - the destination y location on the current surface
See Also:
setDrawOp(int)

copyRect

public boolean copyRect(Graphics source,
                        int x,
                        int y,
                        int width,
                        int height,
                        int destX,
                        int destY)

copyRect

public boolean copyRect(Graphics source,
                        Rect sourceArea,
                        Rect destArea,
                        Mask mask)
Copy and scale an area from another Graphics object to this one, using the optional Mask.


free

public void free()
Frees any system resources (native device contexts) associated with the graphics object. After calling this function, the graphics object can no longer be used to draw. Calling this method is not required since any system resources allocated will be freed when the object is garbage collected. However, if a program uses many graphics objects, free() should be called whenever one is no longer needed to prevent allocating too many system resources before garbage collection can occur.


drawText

public void drawText(char[] chars,
                     int start,
                     int count,
                     int x,
                     int y)
Draws text at the given coordinates. The x and y coordinates specify the upper left hand corner of the text's bounding box.

Parameters:
chars - the character array to display
start - the start position in array
count - the number of characters to display
x - the left coordinate of the text's bounding box
y - the top coordinate of the text's bounding box

drawChar

public void drawChar(char which,
                     int x,
                     int y,
                     int options)

drawFormattedText

public void drawFormattedText(String s,
                              int x,
                              int y,
                              FormattedTextSpecs fts)

drawFormattedText

public void drawFormattedText(String s,
                              int start,
                              int length,
                              int x,
                              int y,
                              FormattedTextSpecs fts)

drawFormattedText

public void drawFormattedText(char[] s,
                              int start,
                              int length,
                              int x,
                              int y,
                              FormattedTextSpecs fts)

drawImage

public void drawImage(Image image,
                      int x,
                      int y)
Draws an image without transparencies at the given x and y coordinates. To draw an Image that may have transparent regions, use Image.draw(Graphics g, int x, int y, int options);


drawImage

public void drawImage(Image image,
                      Image mask,
                      Color transparent,
                      int x,
                      int y,
                      int width,
                      int height)

drawImage

public void drawImage(Image image,
                      Image mask,
                      Color transparent,
                      Rect sourceImageArea,
                      Rect destArea,
                      int scaleOptions)
This will draw and scale a portion of an image into the destination area. There are currently no scale options defined.


drawCursor

public void drawCursor(int x,
                       int y,
                       int width,
                       int height)
Draws a cursor by XORing the given rectangular area on the surface. Since it is XORed, calling the method a second time with the same parameters will erase the cursor.


drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Draws a line at the given coordinates. The drawing includes both endpoints of the line.


drawRoundRect

public void drawRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int radius)
Draw a rectangle with rounded corners.

Parameters:
radius - the radius of the arcs that are at the corners.
Returns:

fillRoundRect

public void fillRoundRect(int x,
                          int y,
                          int width,
                          int height,
                          int radius)
Fill a rectangle with rounded corners.

Parameters:
radius - the radius of the arcs that are at the corners.
Returns:

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height)
Draws a rectangle at the given coordinates.


drawDots

public void drawDots(int x1,
                     int y1,
                     int x2,
                     int y2)
Draws a dotted line at the given coordinates. Dotted lines must be either horizontal or vertical, they can't be drawn at arbitrary angles.


drawPolygon

public void drawPolygon(int[] x,
                        int[] y,
                        int count)
Draws the outline of a polygon with the given coordinates. The polygon is automatically closed, you should not duplicate the start point to close the polygon.

Parameters:
x - x vertex coordinates
y - y vertex coordinates
count - number of vertices

drawLines

public void drawLines(int[] x,
                      int[] y,
                      int count)

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    float startAngle,
                    float angle)
Draws the outline of a circular or elliptical arc covering the specified rectangle. The resulting arc begins at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation. The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the width and height arguments.


drawClosedArc

public void drawClosedArc(int x,
                          int y,
                          int width,
                          int height,
                          float startAngle,
                          float angle)
Draws the outline of a circular or elliptical arc covering the specified rectangle, and includes lines that connect the end and start point of the arc to each other (ie the connecting chord). The resulting arc begins at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation. The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the width and height arguments.


fillClosedArc

public void fillClosedArc(int x,
                          int y,
                          int width,
                          int height,
                          float startAngle,
                          float angle)
Draws the outline of a circular or elliptical arc covering the specified rectangle, and includes lines that connect the end and start point of the arc to each other (ie the connecting chord). The resulting arc begins at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation. The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the width and height arguments.


drawPie

public void drawPie(int x,
                    int y,
                    int width,
                    int height,
                    float startAngle,
                    float angle)
Draws the outline of a circular or elliptical arc covering the specified rectangle, and includes lines that connect the end and start point of the arc to the center of the ellipse. The resulting arc begins at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation. The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the width and height arguments.


fillPie

public void fillPie(int x,
                    int y,
                    int width,
                    int height,
                    float startAngle,
                    float angle)
Draws and fills the outline of a circular or elliptical arc covering the specified rectangle, and includes lines that connect the end and start point of the arc to the center of the ellipse. The resulting arc begins at startAngle and extends for arcAngle degrees, using the current color. Angles are interpreted such that 0 degrees is at the 3 o'clock position. A positive value indicates a counter-clockwise rotation while a negative value indicates a clockwise rotation. The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the width and height arguments.


getArcPoints

protected static Object[] getArcPoints(int xc,
                                       int yc,
                                       int rx,
                                       int rw,
                                       float startAngle,
                                       float endAngle,
                                       int flags)

fillPolygon

public void fillPolygon(int[] x,
                        int[] y,
                        int count)
Draws a filled polygon with the given coordinates. The polygon is automatically closed, you should not duplicate the start point to close the polygon. The polygon is filled according to Jordan's rule - a point is inside if a horizontal line to the point intersects the polygon an odd number of times. This function is not implemented for the PalmOS VM. Under PalmOS only the outline of the polygon is drawn.

Parameters:
x - x vertex coordinates
y - y vertex coordinates
count - number of vertices

drawText

public void drawText(String s,
                     int x,
                     int y)
Draws text at the given coordinates. The x and y coordinates specify the upper left hand corner of the text.


fillRect

public void fillRect(int x,
                     int y,
                     int width,
                     int height)
Fills a rectangular area with the current color.


setClip

public void setClip(int x,
                    int y,
                    int width,
                    int height)
Sets a clipping rectangle. Anything drawn outside of the rectangular area specified will be clipped. Setting a clip overrides any previous clip.


getClip

public Rect getClip(Rect r)
Sets the x, y, width and height coordinates in the rectangle passed to the current clip coordinates. To reduce the use of temporary objects during drawing, this method does not allocate its own rectangle object. If there is no current clip, null will be returned and the rectangle passed will remain unchanged. Upon success, the rectangle passed to the method will be returned.


reduceClip

public Rect reduceClip(int x,
                       int y,
                       int width,
                       int height,
                       Rect oldClip)
This alters the clipping region of the current graphics to be the intersection of the original clipping region and the newly specified region. It returns a Rect which you can then use to call restoreClip() to return the clipping region to its original value. This works even if there was no original clipping region since null will be returned in that case.


reduceClip

public Rect reduceClip(Rect newRect)
This alters the clipping region of the current graphics to be the intersection of the original clipping region and the newly specified region. It returns a Rect which you can then use to call restoreClip() to return the clipping region to its original value. This works even if there was no original clipping region.


restoreClip

public void restoreClip(Rect r)
Use this with a Rect value returned from reduceClip()


setColor

public void setColor(int r,
                     int g,
                     int b)
Sets the current color for drawing operations.

Parameters:
r - the red value (0..255)
g - the green value (0..255)
b - the blue value (0..255)

getColor

public Color getColor()

getBackground

public Color getBackground()

setDrawOp

public void setDrawOp(int drawOp)
Sets the drawing operation. The setting determines the raster operation to use when drawing lines, rectangles, text and images on the current surface. It also determines how pixels are combined when copying one surface to another. The setting of DRAW_OVER, where any drawing simply draws over the pixels on a surface, is the default.

Not all operations are supported on all platforms. When used with Java, DRAW_OVER is supported for all types of drawing and DRAW_XOR is supported for drawing lines, rectangles, text and images. However, DRAW_XOR is not supported when copying surface areas and the DRAW_AND and DRAW_OR operations aren't supported at all under Java.

PalmOS platforms supports all the drawing operations when drawing images and copying surface regions. However, only the DRAW_OVER operation is supported when drawing lines, rectangles and text. If you need to use the XOR drawing operation for drawing lines under PalmOS, you can draw the line into an image and then draw the image with an XOR drawing operation.

Win32 and Windows CE platforms support all the drawing operations except when drawing text. Only DRAW_OVER is supported when drawing text. If you need to draw XOR'ed text, you can draw the text into an image and then draw the image with an XOR draw operation.

When calculating the result of XOR, AND and OR drawing, the value of the color black is all 1's (fully set) in binary and white is all 0's (fully unset).

See Also:
DRAW_OVER, DRAW_AND, DRAW_OR, DRAW_XOR

setFont

public void setFont(Font font)
Sets the current font for operations that draw text.


translate

public void translate(int x,
                      int y)
Translates the origin of the current coordinate system by the given x and y values.


getPen

public Pen getPen()

setPen

public Pen setPen(Pen newPen)

nativeSetPen

protected void nativeSetPen(Pen p)

getBrush

public Brush getBrush()

setBrush

public Brush setBrush(Brush newBrush)

nativeSetBrush

protected void nativeSetBrush(Brush b)

drawEllipse

public void drawEllipse(int x,
                        int y,
                        int width,
                        int height)

fillEllipse

public void fillEllipse(int x,
                        int y,
                        int width,
                        int height)

getEmptyGraphics

public static Graphics getEmptyGraphics()

setColor

public void setColor(Color c)

drawRect

public void drawRect(int x,
                     int y,
                     int width,
                     int height,
                     int thickness)

changePen

public void changePen(Color c,
                      int style,
                      int thickness)

changeBrush

public void changeBrush(Color c,
                        int style)

draw3DRect

public void draw3DRect(Rect r,
                       int style,
                       boolean flat,
                       Color fill,
                       Color outlineColor)

draw3DRect

public void draw3DRect(Rect r,
                       int style,
                       boolean flat,
                       Color fill,
                       Color outlineColor,
                       int labelWidth)

drawEdge

public void drawEdge(Rect r,
                     int edge,
                     int flags,
                     int labelWidth)

drawDiamond

public void drawDiamond(Rect r,
                        int which)

drawTail

protected void drawTail(Rect r,
                        int which)

drawArrow

public void drawArrow(Rect r,
                      int which)

reset

public void reset()

isEmpty

public boolean isEmpty()

createNew

public static Graphics createNew(ISurface is)

getImage

public static Image getImage(int w,
                             int h)

anchor

public void anchor(Rect subArea,
                   Rect largeArea,
                   int anchor)
Modify subArea so that it is anchored appropriately in largeArea. anchor should be North, South, etc.


drawImage

public void drawImage(IImage image,
                      int imageDrawOptions,
                      Rect dest,
                      int anchor)

drawText

public void drawText(FontMetrics fm,
                     String[] lines,
                     Rect where,
                     int alignment,
                     int anchor)

drawText

public void drawText(FontMetrics fm,
                     String[] lines,
                     Rect where,
                     int alignment,
                     int anchor,
                     int startLine,
                     int endLine)

getSize

public static void getSize(FontMetrics fm,
                           String line,
                           Dimension d)

getSize

public static void getSize(FontMetrics fm,
                           String line,
                           Dimension d,
                           FormattedTextSpecs fts)

getSize

public static void getSize(FontMetrics fm,
                           String[] lines,
                           int start,
                           int end,
                           Dimension dest,
                           FormattedTextSpecs fts)

getSize

public static void getSize(FontMetrics fm,
                           String[] lines,
                           int start,
                           int end,
                           Dimension dest)

drawText

public void drawText(FontMetrics fm,
                     String[] lines,
                     Rect where,
                     int alignment,
                     int anchor,
                     int startLine,
                     int endLine,
                     FormattedTextSpecs fts)

drawTextIn

protected void drawTextIn(FontMetrics fm,
                          String[] lines,
                          Rect where,
                          int alignment,
                          int start,
                          int end,
                          FormattedTextSpecs fts)

drawVerticalTriangle

public void drawVerticalTriangle(Rect bounds,
                                 boolean up)

drawHorizontalTriangle

public void drawHorizontalTriangle(Rect bounds,
                                   boolean left)

draw3DDiamond

public void draw3DDiamond(Rect rect,
                          boolean pressed,
                          Color back)

draw3DDiamond

public void draw3DDiamond(Rect rect,
                          boolean pressed,
                          Color back,
                          boolean amFlat)

drawSpecial

public void drawSpecial(int what,
                        Rect where,
                        Color c)

getFontMetrics

public FontMetrics getFontMetrics(Font font)
Get a FontMetrics for the font on the ISurface for this Graphics.


drawLineRGB

public void drawLineRGB(int x1,
                        int y1,
                        int x2,
                        int y2,
                        int rgb)
This is a fast way of drawing a solid line of thickness 1 of a particular color. This will set the pen/brush of the Graphics to an indeterminate state.

See Also:
setPixelRGB(), fillRectRGB()

setPixelRGB

public void setPixelRGB(int x,
                        int y,
                        int rgb)
This is a fast way of setting pixel to a particular color. This will set the pen/brush of the Graphics to an indeterminate state.

See Also:
drawLineRGB(), fillRectRGB()

fillRectRGB

public void fillRectRGB(int x1,
                        int y1,
                        int x2,
                        int y2,
                        int rgb)
This is a fast way of setting pixel to a particular color. This will set the pen/brush of the Graphics to an indeterminate state.

See Also:
drawLineRGB(), setPixelRGB()

flush

public void flush()
On some systems it may be necessary to call this method to have operations made to the Graphics actually be displayed on the screen. On most systems this will have no effect.


drawImage

public void drawImage(Image image,
                      int sx,
                      int sy,
                      int swidth,
                      int sheight,
                      int dx,
                      int dy,
                      int dwidth,
                      int dheight)

setTransform

public void setTransform(double[] transforms)

getTransform

public double[] getTransform(double[] dest)

transform

public double[] transform(double[] transform,
                          double[] oldTransform)