Eclipse Rich Ajax Platform
Release 1.3

org.eclipse.swt.graphics
Class GC

java.lang.Object
  extended byorg.eclipse.swt.graphics.Resource
      extended byorg.eclipse.swt.graphics.GC

public class GC
extends Resource

Class GC is provided to ease single-sourcing SWT and RWT code. Its text measurement methods directly delegate to the respective Graphics methods.

Styles:
LEFT_TO_RIGHT

Application code must explicitly invoke the GC.dispose() method to release the operating system resources managed by each instance when those instances are no longer required.


Constructor Summary
GC(Drawable drawable)
          Constructs a new instance of this class which has been configured to draw on the specified drawable.
GC(Drawable drawable, int style)
          Constructs a new instance of this class which has been configured to draw on the specified drawable.
 
Method Summary
 void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          Draws the outline of a circular or elliptical arc within the specified rectangular area.
 void drawFocus(int x, int y, int width, int height)
          Draws a rectangle, based on the specified arguments, which has the appearance of the platform's focus rectangle if the platform supports such a notion, and otherwise draws a simple rectangle in the receiver's foreground color.
 void drawImage(Image image, int x, int y)
          Draws the given image in the receiver at the specified coordinates.
 void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight)
          Copies a rectangular area from the source image into a (potentially different sized) rectangular area in the receiver.
 void drawLine(int x1, int y1, int x2, int y2)
          Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).
 void drawOval(int x, int y, int width, int height)
          Draws the outline of an oval, using the foreground color, within the specified rectangular area.
 void drawPoint(int x, int y)
          Draws a pixel, using the foreground color, at the specified point (x, y).
 void drawPolygon(int[] pointArray)
          Draws the closed polygon which is defined by the specified array of integer coordinates, using the receiver's foreground color.
 void drawPolyline(int[] pointArray)
          Draws the polyline which is defined by the specified array of integer coordinates, using the receiver's foreground color.
 void drawRectangle(int x, int y, int width, int height)
          Draws the outline of the rectangle specified by the arguments, using the receiver's foreground color.
 void drawRectangle(Rectangle rect)
          Draws the outline of the specified rectangle, using the receiver's foreground color.
 void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight)
          Draws the outline of the round-cornered rectangle specified by the arguments, using the receiver's foreground color.
 void drawString(String string, int x, int y)
          Draws the given string, using the receiver's current font and foreground color.
 void drawString(String string, int x, int y, boolean isTransparent)
          Draws the given string, using the receiver's current font and foreground color.
 void drawText(String string, int x, int y)
          Draws the given string, using the receiver's current font and foreground color.
 void drawText(String string, int x, int y, boolean isTransparent)
          Draws the given string, using the receiver's current font and foreground color.
 void drawText(String string, int x, int y, int flags)
          Draws the given string, using the receiver's current font and foreground color.
 void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
          Fills the interior of a circular or elliptical arc within the specified rectangular area, with the receiver's background color.
 void fillGradientRectangle(int x, int y, int width, int height, boolean vertical)
          Fills the interior of the specified rectangle with a gradient sweeping from left to right or top to bottom progressing from the receiver's foreground color to its background color.
 void fillOval(int x, int y, int width, int height)
          Fills the interior of an oval, within the specified rectangular area, with the receiver's background color.
 void fillPolygon(int[] pointArray)
          Fills the interior of the closed polygon which is defined by the specified array of integer coordinates, using the receiver's background color.
 void fillRectangle(int x, int y, int width, int height)
          Fills the interior of the rectangle specified by the arguments, using the receiver's background color.
 void fillRectangle(Rectangle rect)
          Fills the interior of the specified rectangle, using the receiver's background color.
 void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight)
          Fills the interior of the round-cornered rectangle specified by the arguments, using the receiver's background color.
 boolean getAdvanced()
          Returns true if receiver is using the operating system's advanced graphics subsystem.
 int getAlpha()
          Returns the receiver's alpha value.
 Color getBackground()
          Returns the background color.
 int getCharWidth(char ch)
          Returns the width of the specified character in the font selected into the receiver.
 Rectangle getClipping()
          Returns the bounding rectangle of the receiver's clipping region.
 Font getFont()
          Returns the font currently being used by the receiver to draw and measure text.
 FontMetrics getFontMetrics()
          Returns a FontMetrics which contains information about the font currently being used by the receiver to draw and measure text.
 Color getForeground()
          Returns the receiver's foreground color.
 LineAttributes getLineAttributes()
          Returns the receiver's line attributes.
 int getLineCap()
          Returns the receiver's line cap style, which will be one of the constants SWT.CAP_FLAT, SWT.CAP_ROUND, or SWT.CAP_SQUARE.
 int getLineJoin()
          Returns the receiver's line join style, which will be one of the constants SWT.JOIN_MITER, SWT.JOIN_ROUND, or SWT.JOIN_BEVEL.
 int getLineWidth()
          Returns the width that will be used when drawing lines for all of the figure drawing operations (that is, drawLine, drawRectangle, drawPolyline, and so forth.
 int getStyle()
          Returns the receiver's style information.
 void setAdvanced(boolean advanced)
          Sets the receiver to always use the operating system's advanced graphics subsystem for all graphics operations if the argument is true.
 void setAlpha(int alpha)
          Sets the receiver's alpha value which must be between 0 (transparent) and 255 (opaque).
 void setBackground(Color color)
          Sets the background color.
 void setFont(Font font)
          Sets the font which will be used by the receiver to draw and measure text to the argument.
 void setForeground(Color color)
          Sets the foreground color.
 void setLineAttributes(LineAttributes attributes)
          Sets the receiver's line attributes.
 void setLineCap(int lineCap)
          Sets the receiver's line cap style to the argument, which must be one of the constants SWT.CAP_FLAT, SWT.CAP_ROUND, or SWT.CAP_SQUARE.
 void setLineJoin(int lineJoin)
          Sets the receiver's line join style to the argument, which must be one of the constants SWT.JOIN_MITER, SWT.JOIN_ROUND, or SWT.JOIN_BEVEL.
 void setLineWidth(int lineWidth)
          Sets the width that will be used when drawing lines for all of the figure drawing operations (that is, drawLine, drawRectangle, drawPolyline, and so forth.
 Point stringExtent(String string)
          Returns the extent of the given string.
 Point textExtent(String string)
          Returns the extent of the given string.
 
Methods inherited from class org.eclipse.swt.graphics.Resource
dispose, getDevice, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GC

public GC(Drawable drawable)
Constructs a new instance of this class which has been configured to draw on the specified drawable. Sets the foreground color, background color and font in the GC to match those in the drawable.

You must dispose the graphics context when it is no longer required.

Parameters:
drawable - the drawable to draw on
Throws:
IllegalArgumentException -
SWTError -

GC

public GC(Drawable drawable,
          int style)
Constructs a new instance of this class which has been configured to draw on the specified drawable. Sets the foreground color, background color and font in the GC to match those in the drawable.

You must dispose the graphics context when it is no longer required.

Parameters:
drawable - the drawable to draw on
style - the style of GC to construct
Throws:
IllegalArgumentException -
SWTError -
Method Detail

setFont

public void setFont(Font font)
Sets the font which will be used by the receiver to draw and measure text to the argument. If the argument is null, then a default font appropriate for the platform will be used instead.

Parameters:
font - the new font for the receiver, or null to indicate a default font
Throws:
IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the font has been disposed
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getFont

public Font getFont()
Returns the font currently being used by the receiver to draw and measure text.

Returns:
the receiver's font
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getCharWidth

public int getCharWidth(char ch)
Returns the width of the specified character in the font selected into the receiver.

The width is defined as the space taken up by the actual character, not including the leading and tailing whitespace or overhang.

Parameters:
ch - the character to measure
Returns:
the width of the character
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

stringExtent

public Point stringExtent(String string)
Returns the extent of the given string. No tab expansion or carriage return processing will be performed.

The extent of a string is the width and height of the rectangular area it would cover if drawn in a particular font (in this case, the current font in the receiver).

Parameters:
string - the string to measure
Returns:
a point containing the extent of the string
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

textExtent

public Point textExtent(String string)
Returns the extent of the given string. Tab expansion and carriage return processing are performed.

The extent of a string is the width and height of the rectangular area it would cover if drawn in a particular font (in this case, the current font in the receiver).

Parameters:
string - the string to measure
Returns:
a point containing the extent of the string
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getFontMetrics

public FontMetrics getFontMetrics()
Returns a FontMetrics which contains information about the font currently being used by the receiver to draw and measure text.

Returns:
font metrics for the receiver's font
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

setBackground

public void setBackground(Color color)
Sets the background color. The background color is used for fill operations and as the background color when text is drawn.

Parameters:
color - the new background color for the receiver
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the color is null
  • ERROR_INVALID_ARGUMENT - if the color has been disposed
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getBackground

public Color getBackground()
Returns the background color.

Returns:
the receiver's background color
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

setForeground

public void setForeground(Color color)
Sets the foreground color. The foreground color is used for drawing operations including when text is drawn.

Parameters:
color - the new foreground color for the receiver
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the color is null
  • ERROR_INVALID_ARGUMENT - if the color has been disposed
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getForeground

public Color getForeground()
Returns the receiver's foreground color.

Returns:
the color used for drawing foreground things
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getClipping

public Rectangle getClipping()
Returns the bounding rectangle of the receiver's clipping region. If no clipping region is set, the return value will be a rectangle which covers the entire bounds of the object the receiver is drawing on.

Returns:
the bounding rectangle of the clipping region
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

setAlpha

public void setAlpha(int alpha)
Sets the receiver's alpha value which must be between 0 (transparent) and 255 (opaque).

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.

Parameters:
alpha - the alpha value
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available

getAlpha

public int getAlpha()
Returns the receiver's alpha value. The alpha value is between 0 (transparent) and 255 (opaque).

Returns:
the alpha value
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

setLineWidth

public void setLineWidth(int lineWidth)
Sets the width that will be used when drawing lines for all of the figure drawing operations (that is, drawLine, drawRectangle, drawPolyline, and so forth.

Parameters:
lineWidth - the width of a line
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getLineWidth

public int getLineWidth()
Returns the width that will be used when drawing lines for all of the figure drawing operations (that is, drawLine, drawRectangle, drawPolyline, and so forth.

Returns:
the receiver's line width
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

setLineCap

public void setLineCap(int lineCap)
Sets the receiver's line cap style to the argument, which must be one of the constants SWT.CAP_FLAT, SWT.CAP_ROUND, or SWT.CAP_SQUARE.

Parameters:
lineCap - the cap style to be used for drawing lines
Throws:
IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the style is not valid
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getLineCap

public int getLineCap()
Returns the receiver's line cap style, which will be one of the constants SWT.CAP_FLAT, SWT.CAP_ROUND, or SWT.CAP_SQUARE.

Returns:
the cap style used for drawing lines
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

setLineJoin

public void setLineJoin(int lineJoin)
Sets the receiver's line join style to the argument, which must be one of the constants SWT.JOIN_MITER, SWT.JOIN_ROUND, or SWT.JOIN_BEVEL.

Parameters:
lineJoin - the join style to be used for drawing lines
Throws:
IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the style is not valid
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getLineJoin

public int getLineJoin()
Returns the receiver's line join style, which will be one of the constants SWT.JOIN_MITER, SWT.JOIN_ROUND, or SWT.JOIN_BEVEL.

Returns:
the join style used for drawing lines
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

setLineAttributes

public void setLineAttributes(LineAttributes attributes)
Sets the receiver's line attributes.

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.

Parameters:
attributes - the line attributes
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the attributes is null
  • ERROR_INVALID_ARGUMENT - if any of the line attributes is not valid
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
See Also:
LineAttributes

getLineAttributes

public LineAttributes getLineAttributes()
Returns the receiver's line attributes.

Returns:
the line attributes used for drawing lines
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

setAdvanced

public void setAdvanced(boolean advanced)
Sets the receiver to always use the operating system's advanced graphics subsystem for all graphics operations if the argument is true. If the argument is false, the advanced graphics subsystem is no longer used, advanced graphics state is cleared and the normal graphics subsystem is used from now on.

Normally, the advanced graphics subsystem is invoked automatically when any one of the alpha, antialias, patterns, interpolation, paths, clipping or transformation operations in the receiver is requested. When the receiver is switched into advanced mode, the advanced graphics subsystem performs both advanced and normal graphics operations. Because the two subsystems are different, their output may differ. Switching to advanced graphics before any graphics operations are performed ensures that the output is consistent.

Advanced graphics may not be installed for the operating system. In this case, this operation does nothing. Some operating system have only one graphics subsystem, so switching from normal to advanced graphics does nothing. However, switching from advanced to normal graphics will always clear the advanced graphics state, even for operating systems that have only one graphics subsystem.

Parameters:
advanced - the new advanced graphics state
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
Since:
1.4
See Also:
setAlpha(int), #setAntialias, #setBackgroundPattern, #setClipping(Path), #setForegroundPattern, setLineAttributes(org.eclipse.swt.graphics.LineAttributes), #setInterpolation, #setTextAntialias, #setTransform, getAdvanced()

getAdvanced

public boolean getAdvanced()
Returns true if receiver is using the operating system's advanced graphics subsystem. Otherwise, false is returned to indicate that normal graphics are in use.

Advanced graphics may not be installed for the operating system. In this case, false is always returned. Some operating system have only one graphics subsystem. If this subsystem supports advanced graphics, then true is always returned. If any graphics operation such as alpha, antialias, patterns, interpolation, paths, clipping or transformation has caused the receiver to switch from regular to advanced graphics mode, true is returned. If the receiver has been explicitly switched to advanced mode and this mode is supported, true is returned.

Returns:
the advanced value
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
Since:
1.4
See Also:
setAdvanced(boolean)

drawLine

public void drawLine(int x1,
                     int y1,
                     int x2,
                     int y2)
Draws a line, using the foreground color, between the points (x1, y1) and (x2, y2).

Parameters:
x1 - the first point's x coordinate
y1 - the first point's y coordinate
x2 - the second point's x coordinate
y2 - the second point's y coordinate
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

drawRectangle

public void drawRectangle(Rectangle rect)
Draws the outline of the specified rectangle, using the receiver's foreground color. The left and right edges of the rectangle are at rect.x and rect.x + rect.width. The top and bottom edges are at rect.y and rect.y + rect.height.

Parameters:
rect - the rectangle to draw
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the rectangle is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

drawRectangle

public void drawRectangle(int x,
                          int y,
                          int width,
                          int height)
Draws the outline of the rectangle specified by the arguments, using the receiver's foreground color. The left and right edges of the rectangle are at x and x + width. The top and bottom edges are at y and y + height.

Parameters:
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
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

drawFocus

public void drawFocus(int x,
                      int y,
                      int width,
                      int height)
Draws a rectangle, based on the specified arguments, which has the appearance of the platform's focus rectangle if the platform supports such a notion, and otherwise draws a simple rectangle in the receiver's foreground color.

Parameters:
x - the x coordinate of the rectangle
y - the y coordinate of the rectangle
width - the width of the rectangle
height - the height of the rectangle
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also:
drawRectangle(int, int, int, int)

fillRectangle

public void fillRectangle(Rectangle rect)
Fills the interior of the specified rectangle, using the receiver's background color.

Parameters:
rect - the rectangle to be filled
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the rectangle is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also:
drawRectangle(int, int, int, int)

fillRectangle

public void fillRectangle(int x,
                          int y,
                          int width,
                          int height)
Fills the interior of the rectangle specified by the arguments, using the receiver's background color.

Parameters:
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
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also:
drawRectangle(int, int, int, int)

fillGradientRectangle

public void fillGradientRectangle(int x,
                                  int y,
                                  int width,
                                  int height,
                                  boolean vertical)
Fills the interior of the specified rectangle with a gradient sweeping from left to right or top to bottom progressing from the receiver's foreground color to its background color.

Parameters:
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, may be negative (inverts direction of gradient if horizontal)
height - the height of the rectangle to be filled, may be negative (inverts direction of gradient if vertical)
vertical - if true sweeps from top to bottom, else sweeps from left to right
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also:
drawRectangle(int, int, int, int)

drawRoundRectangle

public void drawRoundRectangle(int x,
                               int y,
                               int width,
                               int height,
                               int arcWidth,
                               int arcHeight)
Draws the outline of the round-cornered rectangle specified by the arguments, using the receiver's foreground color. The left and right edges of the rectangle are at x and x + width. The top and bottom edges are at y and y + height. The roundness of the corners is specified by the arcWidth and arcHeight arguments, which are respectively the width and height of the ellipse used to draw the corners.

Parameters:
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 width of the arc
arcHeight - the height of the arc
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

fillRoundRectangle

public void fillRoundRectangle(int x,
                               int y,
                               int width,
                               int height,
                               int arcWidth,
                               int arcHeight)
Fills the interior of the round-cornered rectangle specified by the arguments, using the receiver's background color.

Parameters:
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 width of the arc
arcHeight - the height of the arc
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also:
drawRoundRectangle(int, int, int, int, int, int)

drawOval

public void drawOval(int x,
                     int y,
                     int width,
                     int height)
Draws the outline of an oval, using the foreground color, within the specified rectangular area.

The result is a circle or ellipse that fits within the rectangle specified by the x, y, width, and height arguments.

The oval covers an area that is width + 1 pixels wide and height + 1 pixels tall.

Parameters:
x - the x coordinate of the upper left corner of the oval to be drawn
y - the y coordinate of the upper left corner of the oval to be drawn
width - the width of the oval to be drawn
height - the height of the oval to be drawn
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

fillOval

public void fillOval(int x,
                     int y,
                     int width,
                     int height)
Fills the interior of an oval, within the specified rectangular area, with the receiver's background color.

Parameters:
x - the x coordinate of the upper left corner of the oval to be filled
y - the y coordinate of the upper left corner of the oval to be filled
width - the width of the oval to be filled
height - the height of the oval to be filled
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also:
drawOval(int, int, int, int)

drawArc

public void drawArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Draws the outline of a circular or elliptical arc within the specified rectangular area.

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.

The resulting arc covers an area width + 1 pixels wide by height + 1 pixels tall.

Parameters:
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
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

fillArc

public void fillArc(int x,
                    int y,
                    int width,
                    int height,
                    int startAngle,
                    int arcAngle)
Fills the interior of a circular or elliptical arc within the specified rectangular area, with the receiver's background color.

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.

The resulting arc covers an area width + 1 pixels wide by height + 1 pixels tall.

Parameters:
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
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also:
drawArc(int, int, int, int, int, int)

drawPolygon

public void drawPolygon(int[] pointArray)
Draws the closed polygon which is defined by the specified array of integer coordinates, using the receiver's foreground color. The array contains alternating x and y values which are considered to represent points which are the vertices of the polygon. Lines are drawn between each consecutive pair, and between the first pair and last pair in the array.

Parameters:
pointArray - an array of alternating x and y values which are the vertices of the polygon
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT if pointArray is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

fillPolygon

public void fillPolygon(int[] pointArray)
Fills the interior of the closed polygon which is defined by the specified array of integer coordinates, using the receiver's background color. The array contains alternating x and y values which are considered to represent points which are the vertices of the polygon. Lines are drawn between each consecutive pair, and between the first pair and last pair in the array.

Parameters:
pointArray - an array of alternating x and y values which are the vertices of the polygon
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT if pointArray is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also:
drawPolygon(int[])

drawPolyline

public void drawPolyline(int[] pointArray)
Draws the polyline which is defined by the specified array of integer coordinates, using the receiver's foreground color. The array contains alternating x and y values which are considered to represent points which are the corners of the polyline. Lines are drawn between each consecutive pair, but not between the first pair and last pair in the array.

Parameters:
pointArray - an array of alternating x and y values which are the corners of the polyline
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the point array is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

drawPoint

public void drawPoint(int x,
                      int y)
Draws a pixel, using the foreground color, at the specified point (x, y).

Note that the receiver's line attributes do not affect this operation.

Parameters:
x - the point's x coordinate
y - the point's y coordinate
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

drawImage

public void drawImage(Image image,
                      int x,
                      int y)
Draws the given image in the receiver at the specified coordinates.

Parameters:
image - the image to draw
x - the x coordinate of where to draw
y - the y coordinate of where to draw
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the image is null
  • ERROR_INVALID_ARGUMENT - if the image has been disposed
  • ERROR_INVALID_ARGUMENT - if the given coordinates are outside the bounds of the image
  • SWTException -
    • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
    SWTError -
    • ERROR_NO_HANDLES - if no handles are available to perform the operation

drawImage

public void drawImage(Image image,
                      int srcX,
                      int srcY,
                      int srcWidth,
                      int srcHeight,
                      int destX,
                      int destY,
                      int destWidth,
                      int destHeight)
Copies a rectangular area from the source image into a (potentially different sized) rectangular area in the receiver. If the source and destination areas are of differing sizes, then the source area will be stretched or shrunk to fit the destination area as it is copied. The copy fails if any part of the source rectangle lies outside the bounds of the source image, or if any of the width or height arguments are negative.

Parameters:
image - the source image
srcX - the x coordinate in the source image to copy from
srcY - the y coordinate in the source image to copy from
srcWidth - the width in pixels to copy from the source
srcHeight - the height in pixels to copy from the source
destX - the x coordinate in the destination to copy to
destY - the y coordinate in the destination to copy to
destWidth - the width in pixels of the destination rectangle
destHeight - the height in pixels of the destination rectangle
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the image is null
  • ERROR_INVALID_ARGUMENT - if the image has been disposed
  • ERROR_INVALID_ARGUMENT - if any of the width or height arguments are negative.
  • ERROR_INVALID_ARGUMENT - if the source rectangle is not contained within the bounds of the source image
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
SWTError -
  • ERROR_NO_HANDLES - if no handles are available to perform the operation

drawString

public void drawString(String string,
                       int x,
                       int y)
Draws the given string, using the receiver's current font and foreground color. No tab expansion or carriage return processing will be performed. The background of the rectangular area where the string is being drawn will be filled with the receiver's background color.

Parameters:
string - the string to be drawn
x - the x coordinate of the top left corner of the rectangular area where the string is to be drawn
y - the y coordinate of the top left corner of the rectangular area where the string is to be drawn
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

drawString

public void drawString(String string,
                       int x,
                       int y,
                       boolean isTransparent)
Draws the given string, using the receiver's current font and foreground color. No tab expansion or carriage return processing will be performed. If isTransparent is true, then the background of the rectangular area where the string is being drawn will not be modified, otherwise it will be filled with the receiver's background color.

Parameters:
string - the string to be drawn
x - the x coordinate of the top left corner of the rectangular area where the string is to be drawn
y - the y coordinate of the top left corner of the rectangular area where the string is to be drawn
isTransparent - if true the background will be transparent, otherwise it will be opaque
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

drawText

public void drawText(String string,
                     int x,
                     int y)
Draws the given string, using the receiver's current font and foreground color. Tab expansion and carriage return processing are performed. The background of the rectangular area where the text is being drawn will be filled with the receiver's background color.

Parameters:
string - the string to be drawn
x - the x coordinate of the top left corner of the rectangular area where the text is to be drawn
y - the y coordinate of the top left corner of the rectangular area where the text is to be drawn
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

drawText

public void drawText(String string,
                     int x,
                     int y,
                     boolean isTransparent)
Draws the given string, using the receiver's current font and foreground color. Tab expansion and carriage return processing are performed. If isTransparent is true, then the background of the rectangular area where the text is being drawn will not be modified, otherwise it will be filled with the receiver's background color.

Parameters:
string - the string to be drawn
x - the x coordinate of the top left corner of the rectangular area where the text is to be drawn
y - the y coordinate of the top left corner of the rectangular area where the text is to be drawn
isTransparent - if true the background will be transparent, otherwise it will be opaque
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

drawText

public void drawText(String string,
                     int x,
                     int y,
                     int flags)
Draws the given string, using the receiver's current font and foreground color. Tab expansion, line delimiter and mnemonic processing are performed according to the specified flags. If flags includes DRAW_TRANSPARENT, then the background of the rectangular area where the text is being drawn will not be modified, otherwise it will be filled with the receiver's background color.

The parameter flags may be a combination of:

DRAW_DELIMITER
draw multiple lines
DRAW_TAB
expand tabs
DRAW_MNEMONIC
underline the mnemonic character
DRAW_TRANSPARENT
transparent background

Parameters:
string - the string to be drawn
x - the x coordinate of the top left corner of the rectangular area where the text is to be drawn
y - the y coordinate of the top left corner of the rectangular area where the text is to be drawn
flags - the flags specifying how to process the text
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the string is null
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getStyle

public int getStyle()
Returns the receiver's style information.

Note that the value which is returned by this method may not match the value which was provided to the constructor when the receiver was created. This can occur when the underlying operating system does not support a particular combination of requested styles.

Returns:
the style bits
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

Eclipse Rich Ajax Platform
Release 1.3

Copyright (c) Innoopract Informationssysteme GmbH and others 2002, 2011. All rights reserved.