Class GraphicsUtils
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.swt.graphics.Image
createRotatedImage
(org.eclipse.swt.graphics.Image image, int style) Creates a rotated image (plus or minus 90 degrees) Styles: UP, DOWNstatic org.eclipse.swt.graphics.Image
createRotatedText
(String text, org.eclipse.swt.graphics.Font font, org.eclipse.swt.graphics.Color foreground, org.eclipse.swt.graphics.Color background, int style) Creates an image containing the specified text, rotated either plus or minus 90 degrees.static void
drawLineHorizontal
(org.eclipse.swt.graphics.GC gc, int x, int y, int width) Draws a horizontal line starting at (x, y) and having the given width.static void
drawLineHorizontal
(org.eclipse.swt.graphics.GC gc, int x, int y, int width, boolean drawLeftCorner, boolean drawRightCorner) The difference between this method anddrawLineHorizontal(GC, int, int, int)
is that the line could be extended to draw left and/or right corners (e.g.static void
drawLineHorizontalBorderBottom
(org.eclipse.swt.graphics.GC gc, int x, int y, int width) Draws a horizontal line starting at (x, y) and having the given width.static void
drawLineHorizontalBorderBottom
(org.eclipse.swt.graphics.GC gc, int x, int y, int width, boolean drawLeftCorner, boolean drawRightCorner) The difference between this method anddrawLineHorizontalBorderBottom(GC, int, int, int)
is that the line could be extended to draw left and/or right corners (e.g.static void
drawLineHorizontalBorderTop
(org.eclipse.swt.graphics.GC gc, int x, int y, int width) Draws a horizontal line starting at (x, y) and having the given width.static void
drawLineHorizontalBorderTop
(org.eclipse.swt.graphics.GC gc, int x, int y, int width, boolean drawLeftCorner, boolean drawRightCorner) The difference between this method anddrawLineHorizontalBorderTop(GC, int, int, int)
is that the line could be extended to draw left and/or right corners (e.g.static void
drawLineVertical
(org.eclipse.swt.graphics.GC gc, int x, int y, int height) Draws a vertical line starting at (x, y) and having the given height.static void
drawLineVertical
(org.eclipse.swt.graphics.GC gc, int x, int y, int height, boolean drawTopCorner, boolean drawBottomCorner) The difference between this method anddrawLineVertical(GC, int, int, int)
is that the line could be extended to draw top and/or bottom corners (e.g.static void
drawLineVerticalBorderLeft
(org.eclipse.swt.graphics.GC gc, int x, int y, int height) Draws a vertical line starting at (x, y) and having the given height.static void
drawLineVerticalBorderLeft
(org.eclipse.swt.graphics.GC gc, int x, int y, int height, boolean drawTopCorner, boolean drawBottomCorner) The difference between this method anddrawLineVerticalBorderLeft(GC, int, int, int)
is that the line could be extended to draw top and/or bottom corners (e.g.static void
drawLineVerticalBorderRight
(org.eclipse.swt.graphics.GC gc, int x, int y, int height) Draws a vertical line starting at (x, y) and having the given height.static void
drawLineVerticalBorderRight
(org.eclipse.swt.graphics.GC gc, int x, int y, int height, boolean drawTopCorner, boolean drawBottomCorner) The difference between this method anddrawLineVerticalBorderRight(GC, int, int, int)
is that the line could be extended to draw top and/or bottom corners (e.g.static void
drawRectangle
(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect) Draws a rectangle.static void
drawRectangle
(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect, BorderStyle borderStyle) Draws a rectangle with the given border style.static void
drawRectangleBorderExternal
(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect) Draws a rectangle.static void
drawRectangleBorderInternal
(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect) Draws a rectangle.static void
drawVerticalImage
(org.eclipse.swt.graphics.Image image, int x, int y, boolean paintBackground, org.eclipse.swt.graphics.GC gc, int style) Draws an image vertically (rotates plus or minus 90 degrees) Styles: UP, DOWNstatic void
drawVerticalImage
(org.eclipse.swt.graphics.Image image, int x, int y, org.eclipse.swt.graphics.GC gc, int style) Draws an image vertically (rotates plus or minus 90 degrees) Styles: UP, DOWNstatic void
drawVerticalText
(String string, int x, int y, boolean underline, boolean strikethrough, boolean paintBackground, org.eclipse.swt.graphics.GC gc, int style) Draws text vertically (rotates plus or minus 90 degrees).static void
drawVerticalText
(String string, int x, int y, org.eclipse.swt.graphics.GC gc, int style) Draws text vertically (rotates plus or minus 90 degrees).static void
fillRectangle
(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect) Draws a filled rectangle.static org.eclipse.swt.graphics.Rectangle
getResultingExternalBounds
(org.eclipse.swt.graphics.Rectangle rectangle, BorderStyle borderStyle) Returns the external bounds of the rectangle that would be obtained by paintingrectangle
withborderStyle
using one of theGraphicsUtils.drawRectangle...
methods.
-
Method Details
-
drawVerticalText
public static void drawVerticalText(String string, int x, int y, org.eclipse.swt.graphics.GC gc, int style) Draws text vertically (rotates plus or minus 90 degrees). Uses the current font, color, and background.- Styles:
- UP, DOWN
- Parameters:
string
- the text to drawx
- the x coordinate of the top left corner of the drawing rectangley
- the y coordinate of the top left corner of the drawing rectanglegc
- the GC on which to draw the textstyle
- the style (SWT.UP or SWT.DOWN)Note: Only one of the style UP or DOWN may be specified.
-
drawVerticalText
public static void drawVerticalText(String string, int x, int y, boolean underline, boolean strikethrough, boolean paintBackground, org.eclipse.swt.graphics.GC gc, int style) Draws text vertically (rotates plus or minus 90 degrees). Uses the current font, color, and background.- Styles:
- UP, DOWN
- Parameters:
string
- the text to drawx
- the x coordinate of the top left corner of the drawing rectangley
- the y coordinate of the top left corner of the drawing rectangleunderline
- set totrue
to render the text underlinedstrikethrough
- set totrue
to render the text strikethroughpaintBackground
- set tofalse
to render the background transparent. Needed for example to render the background with an image or gradient with another painter so the text drawn here should have no background.gc
- the GC on which to draw the textstyle
- the style (SWT.UP or SWT.DOWN)Note: Only one of the style UP or DOWN may be specified.
-
drawVerticalImage
public static void drawVerticalImage(org.eclipse.swt.graphics.Image image, int x, int y, org.eclipse.swt.graphics.GC gc, int style) Draws an image vertically (rotates plus or minus 90 degrees)- Styles:
- UP, DOWN
- Parameters:
image
- the image to drawx
- the x coordinate of the top left corner of the drawing rectangley
- the y coordinate of the top left corner of the drawing rectanglegc
- the GC on which to draw the imagestyle
- the style (SWT.UP or SWT.DOWN)Note: Only one of the style UP or DOWN may be specified.
-
drawVerticalImage
public static void drawVerticalImage(org.eclipse.swt.graphics.Image image, int x, int y, boolean paintBackground, org.eclipse.swt.graphics.GC gc, int style) Draws an image vertically (rotates plus or minus 90 degrees)- Styles:
- UP, DOWN
- Parameters:
image
- the image to drawx
- the x coordinate of the top left corner of the drawing rectangley
- the y coordinate of the top left corner of the drawing rectanglepaintBackground
- set tofalse
to render the background transparent. Needed for example to render the background with an image or gradient with another painter so the text drawn here should have no background.gc
- the GC on which to draw the imagestyle
- the style (SWT.UP or SWT.DOWN)Note: Only one of the style UP or DOWN may be specified.
-
createRotatedText
public static org.eclipse.swt.graphics.Image createRotatedText(String text, org.eclipse.swt.graphics.Font font, org.eclipse.swt.graphics.Color foreground, org.eclipse.swt.graphics.Color background, int style) Creates an image containing the specified text, rotated either plus or minus 90 degrees.- Styles:
- UP, DOWN
- Parameters:
text
- the text to rotatefont
- the font to useforeground
- the color for the textbackground
- the background colorstyle
- direction to rotate (up or down)- Returns:
- Image
Note: Only one of the style UP or DOWN may be specified.
-
createRotatedImage
public static org.eclipse.swt.graphics.Image createRotatedImage(org.eclipse.swt.graphics.Image image, int style) Creates a rotated image (plus or minus 90 degrees)- Styles:
- UP, DOWN
- Parameters:
image
- the image to rotatestyle
- direction to rotate (up or down)- Returns:
- Image
Note: Only one of the style UP or DOWN may be specified.
-
drawLineHorizontal
public static void drawLineHorizontal(org.eclipse.swt.graphics.GC gc, int x, int y, int width) Draws a horizontal line starting at (x, y) and having the given width.Unlike
GC.drawLine(int, int, int, int)
, this method guarantees that the line will always start at the given coordinates and will always have the given width.- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinatewidth
- the width of the line to draw- Since:
- 1.5
- See Also:
-
drawLineHorizontal
public static void drawLineHorizontal(org.eclipse.swt.graphics.GC gc, int x, int y, int width, boolean drawLeftCorner, boolean drawRightCorner) The difference between this method anddrawLineHorizontal(GC, int, int, int)
is that the line could be extended to draw left and/or right corners (e.g. the corners of a rectangle).- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinatewidth
- the width of the line to drawdrawLeftCorner
- to draw the left cornerdrawRightCorner
- to draw the right corner- Since:
- 1.5
- See Also:
-
drawLineVertical
public static void drawLineVertical(org.eclipse.swt.graphics.GC gc, int x, int y, int height) Draws a vertical line starting at (x, y) and having the given height.Unlike
GC.drawLine(int, int, int, int)
, this method guarantees that the line will always start at the given coordinates and will always have the given height.- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinateheight
- the height of the line to draw- Since:
- 1.5
- See Also:
-
drawLineVertical
public static void drawLineVertical(org.eclipse.swt.graphics.GC gc, int x, int y, int height, boolean drawTopCorner, boolean drawBottomCorner) The difference between this method anddrawLineVertical(GC, int, int, int)
is that the line could be extended to draw top and/or bottom corners (e.g. the corners of a rectangle).- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinateheight
- the height of the line to drawdrawTopCorner
- to draw the top cornerdrawBottomCorner
- to draw the bottom corner- Since:
- 1.5
- See Also:
-
drawLineHorizontalBorderBottom
public static void drawLineHorizontalBorderBottom(org.eclipse.swt.graphics.GC gc, int x, int y, int width) Draws a horizontal line starting at (x, y) and having the given width. The increased thickness resulting fromGC.getLineWidth()
will be strictly drawn below the line.Unlike
GC.drawLine(int, int, int, int)
, this method guarantees that the line will always start at the given coordinates and will always have the given width.- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinatewidth
- the width of the line to draw- Since:
- 1.5
- See Also:
-
drawLineHorizontalBorderBottom
public static void drawLineHorizontalBorderBottom(org.eclipse.swt.graphics.GC gc, int x, int y, int width, boolean drawLeftCorner, boolean drawRightCorner) The difference between this method anddrawLineHorizontalBorderBottom(GC, int, int, int)
is that the line could be extended to draw left and/or right corners (e.g. the corners of a rectangle).- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinatewidth
- the width of the line to drawdrawLeftCorner
- to draw the left cornerdrawRightCorner
- to draw the right corner- Since:
- 1.5
- See Also:
-
drawLineHorizontalBorderTop
public static void drawLineHorizontalBorderTop(org.eclipse.swt.graphics.GC gc, int x, int y, int width) Draws a horizontal line starting at (x, y) and having the given width. The increased thickness resulting fromGC.getLineWidth()
will be strictly drawn above the line.Unlike
GC.drawLine(int, int, int, int)
, this method guarantees that the line will always start at the given coordinates and will always have the given width.- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinatewidth
- the width of the line to draw- Since:
- 1.5
- See Also:
-
drawLineHorizontalBorderTop
public static void drawLineHorizontalBorderTop(org.eclipse.swt.graphics.GC gc, int x, int y, int width, boolean drawLeftCorner, boolean drawRightCorner) The difference between this method anddrawLineHorizontalBorderTop(GC, int, int, int)
is that the line could be extended to draw left and/or right corners (e.g. the corners of a rectangle).- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinatewidth
- the width of the line to drawdrawLeftCorner
- to draw the left cornerdrawRightCorner
- to draw the right corner- Since:
- 1.5
- See Also:
-
drawLineVerticalBorderRight
public static void drawLineVerticalBorderRight(org.eclipse.swt.graphics.GC gc, int x, int y, int height) Draws a vertical line starting at (x, y) and having the given height. The increased thickness resulting fromGC.getLineWidth()
will be strictly drawn to the right of the line.Unlike
GC.drawLine(int, int, int, int)
, this method guarantees that the line will always start at the given coordinates and will always have the given height.- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinateheight
- the height of the line to draw- Since:
- 1.5
- See Also:
-
drawLineVerticalBorderRight
public static void drawLineVerticalBorderRight(org.eclipse.swt.graphics.GC gc, int x, int y, int height, boolean drawTopCorner, boolean drawBottomCorner) The difference between this method anddrawLineVerticalBorderRight(GC, int, int, int)
is that the line could be extended to draw top and/or bottom corners (e.g. the corners of a rectangle).- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinateheight
- the height of the line to drawdrawTopCorner
- to draw the top cornerdrawBottomCorner
- to draw the bottom corner- Since:
- 1.5
- See Also:
-
drawLineVerticalBorderLeft
public static void drawLineVerticalBorderLeft(org.eclipse.swt.graphics.GC gc, int x, int y, int height) Draws a vertical line starting at (x, y) and having the given height. The increased thickness resulting fromGC.getLineWidth()
will be strictly drawn to the left of the line.Unlike
GC.drawLine(int, int, int, int)
, this method guarantees that the line will always start at the given coordinates and will always have the given height.- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinateheight
- the height of the line to draw- Since:
- 1.5
- See Also:
-
drawLineVerticalBorderLeft
public static void drawLineVerticalBorderLeft(org.eclipse.swt.graphics.GC gc, int x, int y, int height, boolean drawTopCorner, boolean drawBottomCorner) The difference between this method anddrawLineVerticalBorderLeft(GC, int, int, int)
is that the line could be extended to draw top and/or bottom corners (e.g. the corners of a rectangle).- Parameters:
gc
- the GC to use to drawx
- the starting point's x coordinatey
- the starting point's y coordinateheight
- the height of the line to drawdrawTopCorner
- to draw the top cornerdrawBottomCorner
- to draw the bottom corner- Since:
- 1.5
- See Also:
-
fillRectangle
public static void fillRectangle(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect) Draws a filled rectangle.Unlike
GC.fillRectangle(Rectangle)
, this method guarantees that the rectangle will always start at the given coordinates even in case of negative width/height.- Parameters:
gc
- the GC to use to drawrect
- the rectangle to draw- Since:
- 1.5
-
drawRectangle
public static void drawRectangle(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect, BorderStyle borderStyle) Draws a rectangle with the given border style.Unlike
GC.drawRectangle(Rectangle)
:- the width and height of the resulting rectangle will be always
exactly
rect.width
andrect.height
- the rectangle will always start at the given coordinates even in case of negative width/height
- Parameters:
gc
- the GC to use to drawrect
- the rectangle to drawborderStyle
- the border style of the rectangle- Since:
- 1.5
- the width and height of the resulting rectangle will be always
exactly
-
drawRectangle
public static void drawRectangle(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect) Draws a rectangle.Unlike
GC.drawRectangle(Rectangle)
:- the width and height of the resulting rectangle will be always
exactly
rect.width
andrect.height
- the rectangle will always start at the given coordinates even in case of negative width/height
- Parameters:
gc
- the GC to use to drawrect
- the rectangle to draw- Since:
- 1.5
- See Also:
- the width and height of the resulting rectangle will be always
exactly
-
drawRectangleBorderInternal
public static void drawRectangleBorderInternal(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect) Draws a rectangle. The increased border thickness resulting fromGC.getLineWidth()
will be strictly drawn inside of the rectangle.Unlike
GC.drawRectangle(Rectangle)
:- the width and height of the resulting rectangle will be always
exactly
rect.width
andrect.height
- the rectangle will always start at the given coordinates even in case of negative width/height
- Parameters:
gc
- the GC to use to drawrect
- the rectangle to draw- Since:
- 1.5
- See Also:
- the width and height of the resulting rectangle will be always
exactly
-
drawRectangleBorderExternal
public static void drawRectangleBorderExternal(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rect) Draws a rectangle. The increased border thickness resulting fromGC.getLineWidth()
will be strictly drawn outside of the rectangle.Unlike
GC.drawRectangle(Rectangle)
:- the width and height of the resulting rectangle will be always
exactly
rect.width
andrect.height
- the rectangle will always start at the given coordinates even in case of negative width/height
- Parameters:
gc
- the GC to use to drawrect
- the rectangle to draw- Since:
- 1.5
- See Also:
- the width and height of the resulting rectangle will be always
exactly
-
getResultingExternalBounds
public static org.eclipse.swt.graphics.Rectangle getResultingExternalBounds(org.eclipse.swt.graphics.Rectangle rectangle, BorderStyle borderStyle) Returns the external bounds of the rectangle that would be obtained by paintingrectangle
withborderStyle
using one of theGraphicsUtils.drawRectangle...
methods.- Parameters:
rectangle
- the rectangle to considerborderStyle
- the border style to consider- Returns:
- the external bounds of what would be the resulting rectangle
- Since:
- 1.5
-