Class GC
GC is where all of the drawing capabilities that are
supported by SWT are located. Instances are used to draw on either an
Image, a Control, or directly on a Display.
- Styles:
- LEFT_TO_RIGHT, RIGHT_TO_LEFT
The SWT drawing coordinate system is the two-dimensional space with the origin (0,0) at the top left corner of the drawing area and with (x,y) values increasing to the right and downward respectively.
The result of drawing on an image that was created with an indexed palette using a color that is not in the palette is platform specific. Some platforms will match to the nearest color while other will draw the color itself. This happens because the allocated image might use a direct palette on platforms that do not support indexed palette.
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. This is particularly
important on Windows95 and Windows98 where the operating system has a limited
number of device contexts available.
Note: Only one of LEFT_TO_RIGHT and RIGHT_TO_LEFT may be specified.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionlongthe handle to the OS device context (Warning: This field is platform dependent) -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyArea(int srcX, int srcY, int width, int height, int destX, int destY) Copies a rectangular area of the receiver at the source position onto the receiver at the destination position.voidcopyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) Copies a rectangular area of the receiver at the source position onto the receiver at the destination position.voidCopies a rectangular area of the receiver at the specified position into the image, which must be of typeSWT.BITMAP.voiddispose()Disposes of the operating system resources associated with this resource.voiddrawArc(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.voiddrawFocus(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.voidDraws the given image in the receiver at the specified coordinates.voiddrawImage(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.voiddrawLine(int x1, int y1, int x2, int y2) Draws a line, using the foreground color, between the points (x1,y1) and (x2,y2).voiddrawOval(int x, int y, int width, int height) Draws the outline of an oval, using the foreground color, within the specified rectangular area.voidDraws the path described by the parameter.voiddrawPoint(int x, int y) Draws an SWT logical point, using the foreground color, at the specified point (x,y).voiddrawPolygon(int[] pointArray) Draws the closed polygon which is defined by the specified array of integer coordinates, using the receiver's foreground color.voiddrawPolyline(int[] pointArray) Draws the polyline which is defined by the specified array of integer coordinates, using the receiver's foreground color.voiddrawRectangle(int x, int y, int width, int height) Draws the outline of the rectangle specified by the arguments, using the receiver's foreground color.voiddrawRectangle(Rectangle rect) Draws the outline of the specified rectangle, using the receiver's foreground color.voiddrawRoundRectangle(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.voiddrawString(String string, int x, int y) Draws the given string, using the receiver's current font and foreground color.voiddrawString(String string, int x, int y, boolean isTransparent) Draws the given string, using the receiver's current font and foreground color.voidDraws the given string, using the receiver's current font and foreground color.voidDraws the given string, using the receiver's current font and foreground color.voidDraws the given string, using the receiver's current font and foreground color.booleanCompares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.voidfillArc(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.voidfillGradientRectangle(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.voidfillOval(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.voidFills the path described by the parameter.voidfillPolygon(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.voidfillRectangle(int x, int y, int width, int height) Fills the interior of the rectangle specified by the arguments, using the receiver's background color.voidfillRectangle(Rectangle rect) Fills the interior of the specified rectangle, using the receiver's background color.voidfillRoundRectangle(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.booleanReturnstrueif receiver is using the operating system's advanced graphics subsystem.intgetAdvanceWidth(char ch) Returns the advance width of the specified character in the font which is currently selected into the receiver.intgetAlpha()Returns the receiver's alpha value.intReturns the receiver's anti-aliasing setting value, which will be one ofSWT.DEFAULT,SWT.OFForSWT.ON.Returns the background color.Returns the background pattern.intgetCharWidth(char ch) Returns the width of the specified character in the font selected into the receiver.Returns the bounding rectangle of the receiver's clipping region.voidgetClipping(Region region) Sets the region managed by the argument to the current clipping region of the receiver.intReturns the receiver's fill rule, which will be one ofSWT.FILL_EVEN_ODDorSWT.FILL_WINDING.getFont()Returns the font currently being used by the receiver to draw and measure text.Returns a FontMetrics which contains information about the font currently being used by the receiver to draw and measure text.Returns the receiver's foreground color.Returns the foreground pattern.Returns the GCData.intReturns the receiver's interpolation setting, which will be one ofSWT.DEFAULT,SWT.NONE,SWT.LOWorSWT.HIGH.Returns the receiver's line attributes.intReturns the receiver's line cap style, which will be one of the constantsSWT.CAP_FLAT,SWT.CAP_ROUND, orSWT.CAP_SQUARE.int[]Returns the receiver's line dash style.intReturns the receiver's line join style, which will be one of the constantsSWT.JOIN_MITER,SWT.JOIN_ROUND, orSWT.JOIN_BEVEL.intReturns the receiver's line style, which will be one of the constantsSWT.LINE_SOLID,SWT.LINE_DASH,SWT.LINE_DOT,SWT.LINE_DASHDOTorSWT.LINE_DASHDOTDOT.intReturns the width that will be used when drawing lines for all of the figure drawing operations (that is,drawLine,drawRectangle,drawPolyline, and so forth.intgetStyle()Returns the receiver's style information.intReturns the receiver's text drawing anti-aliasing setting value, which will be one ofSWT.DEFAULT,SWT.OFForSWT.ON.voidgetTransform(Transform transform) Sets the parameter to the transform that is currently being used by the receiver.booleanReturnstrueif this GC is drawing in the mode where the resulting color in the destination is the exclusive or of the color values in the source and the destination, andfalseif it is drawing in the mode where the destination color is being replaced with the source color value.inthashCode()Returns an integer hash code for the receiver.booleanReturnstrueif the receiver has a clipping region set into it, andfalseotherwise.booleanReturnstrueif the GC has been disposed, andfalseotherwise.voidsetAdvanced(boolean advanced) Sets the receiver to always use the operating system's advanced graphics subsystem for all graphics operations if the argument istrue.voidsetAlpha(int alpha) Sets the receiver's alpha value which must be between 0 (transparent) and 255 (opaque).voidsetAntialias(int antialias) Sets the receiver's anti-aliasing value to the parameter, which must be one ofSWT.DEFAULT,SWT.OFForSWT.ON.voidsetBackground(Color color) Sets the background color.voidsetBackgroundPattern(Pattern pattern) Sets the background pattern.voidsetClipping(int x, int y, int width, int height) Sets the area of the receiver which can be changed by drawing operations to the rectangular area specified by the arguments.voidsetClipping(Path path) Sets the area of the receiver which can be changed by drawing operations to the path specified by the argument.voidsetClipping(Rectangle rect) Sets the area of the receiver which can be changed by drawing operations to the rectangular area specified by the argument.voidsetClipping(Region region) Sets the area of the receiver which can be changed by drawing operations to the region specified by the argument.voidsetFillRule(int rule) Sets the receiver's fill rule to the parameter, which must be one ofSWT.FILL_EVEN_ODDorSWT.FILL_WINDING.voidSets the font which will be used by the receiver to draw and measure text to the argument.voidsetForeground(Color color) Sets the foreground color.voidsetForegroundPattern(Pattern pattern) Sets the foreground pattern.voidsetInterpolation(int interpolation) Sets the receiver's interpolation setting to the parameter, which must be one ofSWT.DEFAULT,SWT.NONE,SWT.LOWorSWT.HIGH.voidsetLineAttributes(LineAttributes attributes) Sets the receiver's line attributes.voidsetLineCap(int cap) Sets the receiver's line cap style to the argument, which must be one of the constantsSWT.CAP_FLAT,SWT.CAP_ROUND, orSWT.CAP_SQUARE.voidsetLineDash(int[] dashes) Sets the receiver's line dash style to the argument.voidsetLineJoin(int join) Sets the receiver's line join style to the argument, which must be one of the constantsSWT.JOIN_MITER,SWT.JOIN_ROUND, orSWT.JOIN_BEVEL.voidsetLineStyle(int lineStyle) Sets the receiver's line style to the argument, which must be one of the constantsSWT.LINE_SOLID,SWT.LINE_DASH,SWT.LINE_DOT,SWT.LINE_DASHDOTorSWT.LINE_DASHDOTDOT.voidsetLineWidth(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.voidsetTextAntialias(int antialias) Sets the receiver's text anti-aliasing value to the parameter, which must be one ofSWT.DEFAULT,SWT.OFForSWT.ON.voidsetTransform(Transform transform) Sets the transform that is currently being used by the receiver.voidsetXORMode(boolean xor) If the argument istrue, puts the receiver in a drawing mode where the resulting color in the destination is the exclusive or of the color values in the source and the destination, and if the argument isfalse, puts the receiver in a drawing mode where the destination color is replaced with the source color value.stringExtent(String string) Returns the extent of the given string.textExtent(String string) Returns the extent of the given string.textExtent(String string, int flags) Returns the extent of the given string.toString()Returns a string containing a concise, human-readable description of the receiver.static GCInvokes platform specific functionality to wrap a graphics context.static GCInvokes platform specific functionality to allocate a new graphics context.Methods inherited from class org.eclipse.swt.graphics.Resource
getDevice, setNonDisposeHandler
-
Field Details
-
handle
public long handlethe handle to the OS device context (Warning: This field is platform dependent)IMPORTANT: This field is not part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code.
- Restriction:
- This field is not intended to be referenced by clients.
-
-
Constructor Details
-
GC
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-- ERROR_NULL_ARGUMENT - if the drawable is null
- ERROR_NULL_ARGUMENT - if there is no current device
- ERROR_INVALID_ARGUMENT - if the drawable is an image that is not a bitmap or an icon - if the drawable is an image or printer that is already selected into another graphics context
SWTError-- ERROR_NO_HANDLES if a handle could not be obtained for GC creation
- ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable
- See Also:
-
GC
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 onstyle- the style of GC to construct- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the drawable is null
- ERROR_NULL_ARGUMENT - if there is no current device
- ERROR_INVALID_ARGUMENT - if the drawable is an image that is not a bitmap or an icon - if the drawable is an image or printer that is already selected into another graphics context
SWTError-- ERROR_NO_HANDLES if a handle could not be obtained for GC creation
- ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable
- Since:
- 2.1.2
- See Also:
-
-
Method Details
-
copyArea
Copies a rectangular area of the receiver at the specified position into the image, which must be of typeSWT.BITMAP.- Parameters:
image- the image to copy intox- the x coordinate in the receiver of the area to be copiedy- the y coordinate in the receiver of the area to be copied- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the image is null
- ERROR_INVALID_ARGUMENT - if the image is not a bitmap or has been disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
copyArea
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) Copies a rectangular area of the receiver at the source position onto the receiver at the destination position.- Parameters:
srcX- the x coordinate in the receiver of the area to be copiedsrcY- the y coordinate in the receiver of the area to be copiedwidth- the width of the area to copyheight- the height of the area to copydestX- the x coordinate in the receiver of the area to copy todestY- the y coordinate in the receiver of the area to copy to- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
copyArea
public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) Copies a rectangular area of the receiver at the source position onto the receiver at the destination position.- Parameters:
srcX- the x coordinate in the receiver of the area to be copiedsrcY- the y coordinate in the receiver of the area to be copiedwidth- the width of the area to copyheight- the height of the area to copydestX- the x coordinate in the receiver of the area to copy todestY- the y coordinate in the receiver of the area to copy topaint- iftruepaint events will be generated for old and obscured areas- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
-
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
startAngleand extends forarcAngledegrees, 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 thewidthandheightarguments.The resulting arc covers an area
width + 1points wide byheight + 1points tall.- Parameters:
x- the x coordinate of the upper-left corner of the arc to be drawny- the y coordinate of the upper-left corner of the arc to be drawnwidth- the width of the arc to be drawnheight- the height of the arc to be drawnstartAngle- the beginning anglearcAngle- the angular extent of the arc, relative to the start angle- 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 rectangley- the y coordinate of the rectanglewidth- the width of the rectangleheight- the height of the rectangle- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
drawImage
Draws the given image in the receiver at the specified coordinates.- Parameters:
image- the image to drawx- the x coordinate of where to drawy- 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 imagesrcX- the x coordinate in the source image to copy fromsrcY- the y coordinate in the source image to copy fromsrcWidth- the width in points to copy from the sourcesrcHeight- the height in points to copy from the sourcedestX- the x coordinate in the destination to copy todestY- the y coordinate in the destination to copy todestWidth- the width in points of the destination rectangledestHeight- the height in points 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
-
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 coordinatey1- the first point's y coordinatex2- the second point's x coordinatey2- the second point's y coordinate- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
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, andheightarguments.The oval covers an area that is
width + 1points wide andheight + 1points tall.- Parameters:
x- the x coordinate of the upper left corner of the oval to be drawny- the y coordinate of the upper left corner of the oval to be drawnwidth- the width of the oval to be drawnheight- the height of the oval to be drawn- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
drawPath
Draws the path described by the parameter.This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
- Parameters:
path- the path to draw- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parameter is null
- ERROR_INVALID_ARGUMENT - if the parameter has been disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
- Since:
- 3.1
- See Also:
-
drawPoint
public void drawPoint(int x, int y) Draws an SWT logical point, 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 coordinatey- the point's y coordinate- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.0
-
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
-
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
-
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 atxandx + width. The top and bottom edges are atyandy + height.- Parameters:
x- the x coordinate of the rectangle to be drawny- the y coordinate of the rectangle to be drawnwidth- the width of the rectangle to be drawnheight- the height of the rectangle to be drawn- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
drawRectangle
Draws the outline of the specified rectangle, using the receiver's foreground color. The left and right edges of the rectangle are atrect.xandrect.x + rect.width. The top and bottom edges are atrect.yandrect.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
-
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 atxandx + width. The top and bottom edges are atyandy + height. The roundness of the corners is specified by thearcWidthandarcHeightarguments, 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 drawny- the y coordinate of the rectangle to be drawnwidth- the width of the rectangle to be drawnheight- the height of the rectangle to be drawnarcWidth- the width of the arcarcHeight- the height of the arc- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
drawString
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.
On Windows,drawString(java.lang.String, int, int)anddrawText(java.lang.String, int, int)are slightly different, seedrawString(String, int, int, boolean)for explanation.- Parameters:
string- the string to be drawnx- the x coordinate of the top left corner of the rectangular area where the string is to be drawny- 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
Draws the given string, using the receiver's current font and foreground color. No tab expansion or carriage return processing will be performed. IfisTransparentistrue, 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.
On Windows,drawString(java.lang.String, int, int)anddrawText(java.lang.String, int, int)are slightly different:drawString(java.lang.String, int, int)is faster (depends on string size)
~7x for 1-char strings
~4x for 10-char strings
~2x for 100-char stringsdrawString(java.lang.String, int, int)doesn't try to find a good fallback font when character doesn't have a glyph in currently selected font
- Parameters:
string- the string to be drawnx- the x coordinate of the top left corner of the rectangular area where the string is to be drawny- the y coordinate of the top left corner of the rectangular area where the string is to be drawnisTransparent- iftruethe 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
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.
On Windows,drawString(java.lang.String, int, int)anddrawText(java.lang.String, int, int)are slightly different, seedrawString(String, int, int, boolean)for explanation.- Parameters:
string- the string to be drawnx- the x coordinate of the top left corner of the rectangular area where the text is to be drawny- 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
Draws the given string, using the receiver's current font and foreground color. Tab expansion and carriage return processing are performed. IfisTransparentistrue, 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.
On Windows,drawString(java.lang.String, int, int)anddrawText(java.lang.String, int, int)are slightly different, seedrawString(String, int, int, boolean)for explanation.- Parameters:
string- the string to be drawnx- the x coordinate of the top left corner of the rectangular area where the text is to be drawny- the y coordinate of the top left corner of the rectangular area where the text is to be drawnisTransparent- iftruethe 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
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. IfflagsincludesDRAW_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.
On Windows,drawString(java.lang.String, int, int)anddrawText(java.lang.String, int, int)are slightly different, seedrawString(String, int, int, boolean)for explanation.The parameter
flagsmay 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 drawnx- the x coordinate of the top left corner of the rectangular area where the text is to be drawny- the y coordinate of the top left corner of the rectangular area where the text is to be drawnflags- 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
-
equals
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. -
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
startAngleand extends forarcAngledegrees, 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 thewidthandheightarguments.The resulting arc covers an area
width + 1points wide byheight + 1points tall.- Parameters:
x- the x coordinate of the upper-left corner of the arc to be filledy- the y coordinate of the upper-left corner of the arc to be filledwidth- the width of the arc to be filledheight- the height of the arc to be filledstartAngle- the beginning anglearcAngle- the angular extent of the arc, relative to the start angle- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
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 filledy- the y coordinate of the rectangle to be filledwidth- 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:
-
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 filledy- the y coordinate of the upper left corner of the oval to be filledwidth- the width of the oval to be filledheight- the height of the oval to be filled- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
fillPath
Fills the path described by the parameter.This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
- Parameters:
path- the path to fill- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parameter is null
- ERROR_INVALID_ARGUMENT - if the parameter has been disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
- Since:
- 3.1
- See Also:
-
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:
-
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 filledy- the y coordinate of the rectangle to be filledwidth- the width of the rectangle to be filledheight- the height of the rectangle to be filled- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
fillRectangle
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:
-
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 filledy- the y coordinate of the rectangle to be filledwidth- the width of the rectangle to be filledheight- the height of the rectangle to be filledarcWidth- the width of the arcarcHeight- the height of the arc- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
getAdvanceWidth
public int getAdvanceWidth(char ch) Returns the advance width of the specified character in the font which is currently selected into the receiver.The advance width is defined as the horizontal distance the cursor should move after printing the character in the selected font.
- Parameters:
ch- the character to measure- Returns:
- the distance in the x direction to move past the character before painting the next
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getAdvanced
public boolean getAdvanced()Returnstrueif receiver is using the operating system's advanced graphics subsystem. Otherwise,falseis returned to indicate that normal graphics are in use.Advanced graphics may not be installed for the operating system. In this case,
falseis always returned. Some operating system have only one graphics subsystem. If this subsystem supports advanced graphics, thentrueis 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,trueis returned. If the receiver has been explicitly switched to advanced mode and this mode is supported,trueis returned.- Returns:
- the advanced value
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
- See Also:
-
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
- Since:
- 3.1
-
getAntialias
public int getAntialias()Returns the receiver's anti-aliasing setting value, which will be one ofSWT.DEFAULT,SWT.OFForSWT.ON. Note that this controls anti-aliasing for all non-text drawing operations.- Returns:
- the anti-aliasing setting
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
- See Also:
-
getBackground
Returns the background color.- Returns:
- the receiver's background color
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getBackgroundPattern
Returns the background pattern. The default value isnull.- Returns:
- the receiver's background pattern
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
- See Also:
-
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
-
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
-
getClipping
Sets the region managed by the argument to the current clipping region of the receiver.- Parameters:
region- the region to fill with the clipping region- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the region is null
- ERROR_INVALID_ARGUMENT - if the region is disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
getFillRule
public int getFillRule()Returns the receiver's fill rule, which will be one ofSWT.FILL_EVEN_ODDorSWT.FILL_WINDING.- Returns:
- the receiver's fill rule
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
-
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
-
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
-
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
-
getForegroundPattern
Returns the foreground pattern. The default value isnull.- Returns:
- the receiver's foreground pattern
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
- See Also:
-
getGCData
Returns the GCData.IMPORTANT: This method is not part of the public API for
GC. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.- Returns:
- the receiver's GCData
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.2
- See Also:
- Restriction:
- This method is not intended to be referenced by clients.
-
getInterpolation
public int getInterpolation()Returns the receiver's interpolation setting, which will be one ofSWT.DEFAULT,SWT.NONE,SWT.LOWorSWT.HIGH.- Returns:
- the receiver's interpolation setting
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
-
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
- Since:
- 3.3
-
getLineCap
public int getLineCap()Returns the receiver's line cap style, which will be one of the constantsSWT.CAP_FLAT,SWT.CAP_ROUND, orSWT.CAP_SQUARE.- Returns:
- the cap style used for drawing lines
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
-
getLineDash
public int[] getLineDash()Returns the receiver's line dash style. The default value isnull.- Returns:
- the line dash style used for drawing lines
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
-
getLineJoin
public int getLineJoin()Returns the receiver's line join style, which will be one of the constantsSWT.JOIN_MITER,SWT.JOIN_ROUND, orSWT.JOIN_BEVEL.- Returns:
- the join style used for drawing lines
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
-
getLineStyle
public int getLineStyle()Returns the receiver's line style, which will be one of the constantsSWT.LINE_SOLID,SWT.LINE_DASH,SWT.LINE_DOT,SWT.LINE_DASHDOTorSWT.LINE_DASHDOTDOT.- Returns:
- the style used for drawing lines
- 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
-
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
- Since:
- 2.1.2
-
getTextAntialias
public int getTextAntialias()Returns the receiver's text drawing anti-aliasing setting value, which will be one ofSWT.DEFAULT,SWT.OFForSWT.ON. Note that this controls anti-aliasing only for text drawing operations.- Returns:
- the anti-aliasing setting
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
- See Also:
-
getTransform
Sets the parameter to the transform that is currently being used by the receiver.- Parameters:
transform- the destination to copy the transform into- Throws:
IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parameter is null
- ERROR_INVALID_ARGUMENT - if the parameter has been disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
- See Also:
-
getXORMode
public boolean getXORMode()Returnstrueif this GC is drawing in the mode where the resulting color in the destination is the exclusive or of the color values in the source and the destination, andfalseif it is drawing in the mode where the destination color is being replaced with the source color value.- Returns:
truetrue if the receiver is in XOR mode, and false otherwise- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
hashCode
public int hashCode()Returns an integer hash code for the receiver. Any two objects that returntruewhen passed toequalsmust return the same value for this method.- Overrides:
hashCodein classObject- Returns:
- the receiver's hash
- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- See Also:
-
isClipped
public boolean isClipped()Returnstrueif the receiver has a clipping region set into it, andfalseotherwise. If this method returns false, the receiver will draw on all available space in the destination. If it returns true, it will draw only in the area that is covered by the region that can be accessed withgetClipping(region).- Returns:
trueif the GC has a clipping region, andfalseotherwise- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
isDisposed
public boolean isDisposed()Returnstrueif the GC has been disposed, andfalseotherwise.This method gets the dispose state for the GC. When a GC has been disposed, it is an error to invoke any other method (except
dispose()) using the GC.- Specified by:
isDisposedin classResource- Returns:
truewhen the GC is disposed andfalseotherwise
-
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 istrue. If the argument isfalse, 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:
- 3.1
- See Also:
-
setAntialias
public void setAntialias(int antialias) Sets the receiver's anti-aliasing value to the parameter, which must be one ofSWT.DEFAULT,SWT.OFForSWT.ON. Note that this controls anti-aliasing for all non-text drawing operations.This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
- Parameters:
antialias- the anti-aliasing setting- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the parameter is not one of
SWT.DEFAULT,SWT.OFForSWT.ON
- ERROR_INVALID_ARGUMENT - if the parameter is not one of
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
- Since:
- 3.1
- See Also:
-
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
- Since:
- 3.1
- See Also:
-
setBackground
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
-
setBackgroundPattern
Sets the background pattern. The default value isnull.This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
- Parameters:
pattern- the new background pattern- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the parameter has been disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
- Since:
- 3.1
- See Also:
-
setClipping
public void setClipping(int x, int y, int width, int height) Sets the area of the receiver which can be changed by drawing operations to the rectangular area specified by the arguments.- Parameters:
x- the x coordinate of the clipping rectangley- the y coordinate of the clipping rectanglewidth- the width of the clipping rectangleheight- the height of the clipping rectangle- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setClipping
Sets the area of the receiver which can be changed by drawing operations to the path specified by the argument.This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
- Parameters:
path- the clipping path.- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the path has been disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
- Since:
- 3.1
- See Also:
-
setClipping
Sets the area of the receiver which can be changed by drawing operations to the rectangular area specified by the argument. Specifyingnullfor the rectangle reverts the receiver's clipping area to its original value.- Parameters:
rect- the clipping rectangle ornull- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setClipping
Sets the area of the receiver which can be changed by drawing operations to the region specified by the argument. Specifyingnullfor the region reverts the receiver's clipping area to its original value.- Parameters:
region- the clipping region ornull- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the region has been disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setFillRule
public void setFillRule(int rule) Sets the receiver's fill rule to the parameter, which must be one ofSWT.FILL_EVEN_ODDorSWT.FILL_WINDING.- Parameters:
rule- the new fill rule- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the rule is not one of
SWT.FILL_EVEN_ODDorSWT.FILL_WINDING
- ERROR_INVALID_ARGUMENT - if the rule is not one of
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
-
setFont
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
-
setForeground
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
-
setForegroundPattern
Sets the foreground pattern. The default value isnull.This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
- Parameters:
pattern- the new foreground pattern- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the parameter has been disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
- Since:
- 3.1
- See Also:
-
setInterpolation
public void setInterpolation(int interpolation) Sets the receiver's interpolation setting to the parameter, which must be one ofSWT.DEFAULT,SWT.NONE,SWT.LOWorSWT.HIGH.This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
- Parameters:
interpolation- the new interpolation setting- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the rule is not one of
SWT.DEFAULT,SWT.NONE,SWT.LOWorSWT.HIGH
- ERROR_INVALID_ARGUMENT - if the rule is not one of
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
- Since:
- 3.1
- See Also:
-
setLineAttributes
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
- Since:
- 3.3
- See Also:
-
setLineCap
public void setLineCap(int cap) Sets the receiver's line cap style to the argument, which must be one of the constantsSWT.CAP_FLAT,SWT.CAP_ROUND, orSWT.CAP_SQUARE.- Parameters:
cap- 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
- Since:
- 3.1
-
setLineDash
public void setLineDash(int[] dashes) Sets the receiver's line dash style to the argument. The default value isnull. If the argument is notnull, the receiver's line style is set toSWT.LINE_CUSTOM, otherwise it is set toSWT.LINE_SOLID.- Parameters:
dashes- the dash style to be used for drawing lines- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if any of the values in the array is less than or equal 0
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- Since:
- 3.1
-
setLineJoin
public void setLineJoin(int join) Sets the receiver's line join style to the argument, which must be one of the constantsSWT.JOIN_MITER,SWT.JOIN_ROUND, orSWT.JOIN_BEVEL.- Parameters:
join- 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
- Since:
- 3.1
-
setLineStyle
public void setLineStyle(int lineStyle) Sets the receiver's line style to the argument, which must be one of the constantsSWT.LINE_SOLID,SWT.LINE_DASH,SWT.LINE_DOT,SWT.LINE_DASHDOTorSWT.LINE_DASHDOTDOT.- Parameters:
lineStyle- the 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
-
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.Note that line width of zero is used as a hint to indicate that the fastest possible line drawing algorithms should be used. This means that the output may be different from line width one and specially at high DPI it's not recommended to mix line width zero with other line widths.
- Parameters:
lineWidth- the width of a line- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setXORMode
public void setXORMode(boolean xor) If the argument istrue, puts the receiver in a drawing mode where the resulting color in the destination is the exclusive or of the color values in the source and the destination, and if the argument isfalse, puts the receiver in a drawing mode where the destination color is replaced with the source color value.- Parameters:
xor- iftrue, then xor mode is used, otherwise source copy mode is used- Throws:
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
-
setTextAntialias
public void setTextAntialias(int antialias) Sets the receiver's text anti-aliasing value to the parameter, which must be one ofSWT.DEFAULT,SWT.OFForSWT.ON. Note that this controls anti-aliasing only for all text drawing operations.This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
- Parameters:
antialias- the anti-aliasing setting- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the parameter is not one of
SWT.DEFAULT,SWT.OFForSWT.ON
- ERROR_INVALID_ARGUMENT - if the parameter is not one of
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
- Since:
- 3.1
- See Also:
-
setTransform
Sets the transform that is currently being used by the receiver. If the argument isnull, the current transform is set to the identity transform.This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
- Parameters:
transform- the transform to set- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if the parameter has been disposed
SWTException-- ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
- ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
- Since:
- 3.1
- See Also:
-
stringExtent
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
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
-
textExtent
Returns the extent of the given string. Tab expansion, line delimiter and mnemonic processing are performed according to the specified flags, which can be a combination of:- DRAW_DELIMITER
- draw multiple lines
- DRAW_TAB
- expand tabs
- DRAW_MNEMONIC
- underline the mnemonic character
- DRAW_TRANSPARENT
- transparent background
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 measureflags- the flags specifying how to process the text- 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
-
toString
Returns a string containing a concise, human-readable description of the receiver. -
win32_new
Invokes platform specific functionality to allocate a new graphics context.IMPORTANT: This method is not part of the public API for
GC. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.- Parameters:
drawable- the Drawable for the receiver.data- the data for the receiver.- Returns:
- a new
GC - Restriction:
- This method is not intended to be referenced by clients.
-
win32_new
Invokes platform specific functionality to wrap a graphics context.IMPORTANT: This method is not part of the public API for
GC. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.- Parameters:
hDC- the Windows HDC.data- the data for the receiver.- Returns:
- a new
GC - Restriction:
- This method is not intended to be referenced by clients.
-
dispose
public void dispose()Description copied from class:ResourceDisposes of the operating system resources associated with this resource. Applications must dispose of all resources which they allocate. This method does nothing if the resource is already disposed.
-