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.
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.
org.eclipse.swt.events.PaintEvent , GC snippets, SWT Examples: GraphicsExample, PaintExample, Sample code and further information
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final int | |
| pack-priv static final int | |
| private double[] | cairoTransformationMatrix
The current Cairo matrix, which positions widgets in the shell. |
| private Rectangle | clipping
Original clipping set on this GC |
| private double[] | currentTransform
Tracks the last transformation with which |
| pack-priv GCData | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv Drawable | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| public long | handle
the handle to the OS device context (Warning: This field is platform dependent) Important Note This field is not part of the SWT public API. |
| pack-priv static final int | |
| pack-priv static final float[] | |
| pack-priv static final float[] | |
| pack-priv static final float[] | |
| pack-priv static final float[] | |
| pack-priv static final float[] | |
| pack-priv static final float[] | |
| pack-priv static final float[] | |
| pack-priv static final float[] | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv static final int |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static void | |
| pack-priv void | cairoClipRegion(long
the cairo context to apply the region to cairo)Convenience method that applies a region to the Control using cairo_clip. |
| pack-priv void | |
| pack-priv int | Returns: If only one style is specified, it is return unmodified. If both styles are specified, returns LEFT_TO_RIGHTthe SWT style bit string style)Ensure that the style specified is either LEFT_TO_RIGHT or RIGHT_TO_LEFT. |
| pack-priv void | |
| pack-priv long | |
| public void | |
| public void | copyArea(int
the x coordinate in the receiver of the area to be copied srcX, int the y coordinate in the receiver of the area to be copied srcY, int the width of the area to copy width, int the height of the area to copy height, int the x coordinate in the receiver of the area to copy to destX, int the y coordinate in the receiver of the area to copy to destY)Copies a rectangular area of the receiver at the source position onto the receiver at the destination position. |
| public void | copyArea(int
the x coordinate in the receiver of the area to be copied srcX, int the y coordinate in the receiver of the area to be copied srcY, int the width of the area to copy width, int the height of the area to copy height, int the x coordinate in the receiver of the area to copy to destX, int the y coordinate in the receiver of the area to copy to destY, boolean if paint)true paint events will be generated for old and obscured areasCopies a rectangular area of the receiver at the source position onto the receiver at the destination position. |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | |
| public void | drawArc(int
the x coordinate of the upper-left corner of the arc to be drawn x, int the y coordinate of the upper-left corner of the arc to be drawn y, int the width of the arc to be drawn width, int the height of the arc to be drawn height, int the beginning angle startAngle, int the angular extent of the arc, relative to the start angle arcAngle)Draws the outline of a circular or elliptical arc within the specified rectangular area. |
| pack-priv void | |
| public void | drawFocus(int
the x coordinate of the rectangle x, int the y coordinate of the rectangle y, int the width of the rectangle width, int the height of the rectangle 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. |
| pack-priv void | |
| public void | |
| public void | drawImage(Image
the source image image, int the x coordinate in the source image to copy from srcX, int the y coordinate in the source image to copy from srcY, int the width in points to copy from the source srcWidth, int the height in points to copy from the source srcHeight, int the x coordinate in the destination to copy to destX, int the y coordinate in the destination to copy to destY, int the width in points of the destination rectangle destWidth, int the height in points of the destination rectangle destHeight)Copies a rectangular area from the source image into a (potentially different sized) rectangular area in the receiver. |
| pack-priv void | |
| pack-priv void | |
| public void | drawLine(int
the first point's x coordinate x1, int the first point's y coordinate y1, int the second point's x coordinate x2, int the second point's y coordinate y2)Draws a line, using the foreground color, between the points
( |
| pack-priv void | |
| public void | drawOval(int
the x coordinate of the upper left corner of the oval to be drawn x, int the y coordinate of the upper left corner of the oval to be drawn y, int the width of the oval to be drawn width, int the height of the oval to be drawn height)Draws the outline of an oval, using the foreground color, within the specified rectangular area. |
| pack-priv void | |
| public void | |
| public void | drawPoint(int
the point's x coordinate x, int the point's y coordinate y)Draws an SWT logical point, using the foreground color, at the specified
point ( |
| pack-priv void | |
| public void | drawPolygon(int[]
an array of alternating x and y values which are the vertices of the polygon pointArray)Draws the closed polygon which is defined by the specified array of integer coordinates, using the receiver's foreground color. |
| pack-priv void | |
| public void | drawPolyline(int[]
an array of alternating x and y values which are the corners of the polyline pointArray)Draws the polyline which is defined by the specified array of integer coordinates, using the receiver's foreground color. |
| pack-priv void | |
| pack-priv void | |
| public void | drawRectangle(int
the x coordinate of the rectangle to be drawn x, int the y coordinate of the rectangle to be drawn y, int the width of the rectangle to be drawn width, int the height of the rectangle to be drawn height)Draws the outline of the rectangle specified by the arguments, using the receiver's foreground color. |
| public void | drawRectangle(Rectangle
the rectangle to draw rect)Draws the outline of the specified rectangle, using the receiver's foreground color. |
| pack-priv void | |
| pack-priv void | |
| public void | drawRoundRectangle(int
the x coordinate of the rectangle to be drawn x, int the y coordinate of the rectangle to be drawn y, int the width of the rectangle to be drawn width, int the height of the rectangle to be drawn height, int the width of the arc arcWidth, int the height of the arc arcHeight)Draws the outline of the round-cornered rectangle specified by the arguments, using the receiver's foreground color. |
| pack-priv void | |
| public void | drawString(String
the string to be drawn string, int the x coordinate of the top left corner of the rectangular area where the string is to be drawn x, int the y coordinate of the top left corner of the rectangular area where the string is to be drawn y)Draws the given string, using the receiver's current font and foreground color. |
| public void | drawString(String
the string to be drawn string, int the x coordinate of the top left corner of the rectangular area where the string is to be drawn x, int the y coordinate of the top left corner of the rectangular area where the string is to be drawn y, boolean if isTransparent)true the background will be transparent, otherwise it will be opaqueDraws the given string, using the receiver's current font and foreground color. |
| pack-priv void | |
| pack-priv void | |
| public void | drawText(String
the string to be drawn string, int the x coordinate of the top left corner of the rectangular area where the text is to be drawn x, int the y coordinate of the top left corner of the rectangular area where the text is to be drawn y)Draws the given string, using the receiver's current font and foreground color. |
| public void | drawText(String
the string to be drawn string, int the x coordinate of the top left corner of the rectangular area where the text is to be drawn x, int the y coordinate of the top left corner of the rectangular area where the text is to be drawn y, boolean if isTransparent)true the background will be transparent, otherwise it will be opaqueDraws the given string, using the receiver's current font and foreground color. |
| public void | drawText(String
the string to be drawn string, int the x coordinate of the top left corner of the rectangular area where the text is to be drawn x, int the y coordinate of the top left corner of the rectangular area where the text is to be drawn y, int the flags specifying how to process the text flags)Draws the given string, using the receiver's current font and foreground color. |
| pack-priv void | |
| pack-priv void | |
| pack-priv void | |
| public boolean | Returns: true if the object is the same as this object and false otherwisethe object to compare with this object object)Overrides java. |
| public void | fillArc(int
the x coordinate of the upper-left corner of the arc to be filled x, int the y coordinate of the upper-left corner of the arc to be filled y, int the width of the arc to be filled width, int the height of the arc to be filled height, int the beginning angle startAngle, int the angular extent of the arc, relative to the start angle arcAngle)Fills the interior of a circular or elliptical arc within the specified rectangular area, with the receiver's background color. |
| pack-priv void | |
| public void | fillGradientRectangle(int
the x coordinate of the rectangle to be filled x, int the y coordinate of the rectangle to be filled y, int the width of the rectangle to be filled, may be negative
(inverts direction of gradient if horizontal) width, int the height of the rectangle to be filled, may be negative
(inverts direction of gradient if vertical) height, boolean if true sweeps from top to bottom, else
sweeps from left to right 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. |
| pack-priv void | |
| public void | fillOval(int
the x coordinate of the upper left corner of the oval to be filled x, int the y coordinate of the upper left corner of the oval to be filled y, int the width of the oval to be filled width, int the height of the oval to be filled height)Fills the interior of an oval, within the specified rectangular area, with the receiver's background color. |
| pack-priv void | |
| public void | |
| public void | fillPolygon(int[]
an array of alternating x and y values which are the vertices of the polygon pointArray)Fills the interior of the closed polygon which is defined by the specified array of integer coordinates, using the receiver's background color. |
| pack-priv void | |
| public void | fillRectangle(int
the x coordinate of the rectangle to be filled x, int the y coordinate of the rectangle to be filled y, int the width of the rectangle to be filled width, int the height of the rectangle to be filled height)Fills the interior of the rectangle specified by the arguments, using the receiver's background color. |
| public void | fillRectangle(Rectangle
the rectangle to be filled rect)Fills the interior of the specified rectangle, using the receiver's background color. |
| pack-priv void | |
| pack-priv void | |
| public void | fillRoundRectangle(int
the x coordinate of the rectangle to be filled x, int the y coordinate of the rectangle to be filled y, int the width of the rectangle to be filled width, int the height of the rectangle to be filled height, int the width of the arc arcWidth, int the height of the arc arcHeight)Fills the interior of the round-cornered rectangle specified by the arguments, using the receiver's background color. |
| pack-priv void | |
| pack-priv int | |
| public boolean | Returns: the advanced valueReturns |
| public int | Returns: the distance in the x direction to move past the character before painting the nextthe character to measure ch)Returns the advance width of the specified character in the font which is currently selected into the receiver. |
| public int | |
| public int | Returns: the anti-aliasing settingReturns the receiver's anti-aliasing setting value, which will be
one of |
| public Color | |
| public Pattern | |
| public int | Returns: the width of the characterthe character to measure ch)Returns the width of the specified character in the font selected into the receiver. |
| public Rectangle | Returns: the bounding rectangle of the clipping regionReturns the bounding rectangle of the receiver's clipping region. |
| public void | getClipping(Region
the region to fill with the clipping region region)Sets the region managed by the argument to the current clipping region of the receiver. |
| pack-priv Rectangle | |
| public int | Returns: the receiver's fill ruleReturns the receiver's fill rule, which will be one of
|
| public Font | Returns: the receiver's fontReturns the font currently being used by the receiver to draw and measure text. |
| public FontMetrics | Returns: font metrics for the receiver's fontReturns a FontMetrics which contains information about the font currently being used by the receiver to draw and measure text. |
| public Color | Returns: the color used for drawing foreground thingsReturns the receiver's foreground color. |
| public Pattern | |
| public GCData | |
| public int | Returns: the receiver's interpolation settingReturns the receiver's interpolation setting, which will be one of
|
| public LineAttributes | Returns: the line attributes used for drawing linesReturns the receiver's line attributes. |
| pack-priv LineAttributes | |
| public int | Returns: the cap style used for drawing linesReturns the receiver's line cap style, which will be one
of the constants |
| public int[] | Returns: the line dash style used for drawing linesReturns the receiver's line dash style. |
| public int | Returns: the join style used for drawing linesReturns the receiver's line join style, which will be one
of the constants |
| public int | Returns: the style used for drawing linesReturns the receiver's line style, which will be one
of the constants |
| public int | Returns: the receiver's line widthReturns the width that will be used when drawing lines
for all of the figure drawing operations (that is,
|
| pack-priv int | |
| pack-priv void | |
| public int | |
| public int | Returns: the anti-aliasing settingReturns the receiver's text drawing anti-aliasing setting value,
which will be one of |
| public void | getTransform(Transform
the destination to copy the transform into transform)Sets the parameter to the transform that is currently being used by the receiver. |
| private static Rectangle | |
| public boolean | Returns: true true if the receiver is in XOR mode, and false otherwiseReturns |
| public static GC | |
| public static GC | |
| public int | Returns: the receiver's hashOverrides java. |
| private static boolean | |
| pack-priv double[] | |
| pack-priv void | |
| pack-priv void | |
| public boolean | Returns: true if the GC has a clipping region, and false otherwiseReturns |
| public boolean | Returns: true when the GC is disposed and false otherwiseImplements abstract org. true if the GC has been disposed,
and false otherwise.
|
| pack-priv boolean | |
| private void | limitClipping(long gcClipping)
Intersects given clipping with original clipping of this context, so that resulting clip does not allow to paint outside of the GC bounds. |
| private void | |
| public void | setAdvanced(boolean
the new advanced graphics state advanced)Sets the receiver to always use the operating system's advanced graphics
subsystem for all graphics operations if the argument is |
| public void | setAlpha(int
the alpha value alpha)Sets the receiver's alpha value which must be between 0 (transparent) and 255 (opaque). |
| public void | setAntialias(int
the anti-aliasing setting antialias)Sets the receiver's anti-aliasing value to the parameter,
which must be one of |
| public void | |
| public void | |
| pack-priv void | |
| pack-priv static void | |
| pack-priv static void | |
| pack-priv static void | |
| pack-priv static void | |
| pack-priv void | |
| public void | setClipping(int
the x coordinate of the clipping rectangle x, int the y coordinate of the clipping rectangle y, int the width of the clipping rectangle width, int the height of the clipping rectangle height)Sets the area of the receiver which can be changed by drawing operations to the rectangular area specified by the arguments. |
| public void | setClipping(Path
the clipping path. path)Sets the area of the receiver which can be changed by drawing operations to the path specified by the argument. |
| public void | setClipping(Rectangle
the clipping rectangle or rect)nullSets the area of the receiver which can be changed by drawing operations to the rectangular area specified by the argument. |
| public void | setClipping(Region
the clipping region or region)nullSets the area of the receiver which can be changed by drawing operations to the region specified by the argument. |
| pack-priv void | |
| pack-priv void | |
| public void | setFillRule(int
the new fill rule rule)Sets the receiver's fill rule to the parameter, which must be one of
|
| public void | |
| public void | |
| public void | |
| public void | setInterpolation(int
the new interpolation setting interpolation)Sets the receiver's interpolation setting to the parameter, which
must be one of |
| public void | |
| pack-priv void | |
| public void | setLineCap(int
the cap style to be used for drawing lines cap)Sets the receiver's line cap style to the argument, which must be one
of the constants |
| public void | setLineDash(int[]
the dash style to be used for drawing lines dashes)Sets the receiver's line dash style to the argument. |
| public void | setLineJoin(int
the join style to be used for drawing lines join)Sets the receiver's line join style to the argument, which must be one
of the constants |
| public void | setLineStyle(int
the style to be used for drawing lines lineStyle)Sets the receiver's line style to the argument, which must be one
of the constants |
| public void | setLineWidth(int
the width of a line lineWidth)Sets the width that will be used when drawing lines
for all of the figure drawing operations (that is,
|
| pack-priv void | |
| pack-priv void | |
| public void | setTextAntialias(int
the anti-aliasing setting antialias)Sets the receiver's text anti-aliasing value to the parameter,
which must be one of |
| public void | setTransform(Transform
the transform to set transform)Sets the transform that is currently being used by the receiver. |
| public void | setXORMode(boolean
if xor)true, then xor mode is used, otherwise source copy mode is usedIf the argument is |
| public Point | Returns: a point containing the extent of the stringthe string to measure string)Returns the extent of the given string. |
| pack-priv Point | |
| public Point | Returns: a point containing the extent of the stringthe string to measure string)Returns the extent of the given string. |
| public Point | Returns: a point containing the extent of the stringthe string to measure string, int the flags specifying how to process the text flags)Returns the extent of the given string. |
| pack-priv Point | |
| pack-priv Point | |
| public String | Returns: a string representation of the receiverOverrides java. |
| private static int[] | Returns: transformed x,y coordinates.Transforms x,y coordinate pairs with given matrix |
| private static int[] | Returns: transformed rectangle corner coordinates, with x,y order of points.Transforms rectangle with given matrix |