|
Eclipse Rich Ajax Platform | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.rwt.graphics.Graphics
public final class Graphics
This is a helper class for operations with text, fonts, colors and images. As RAP needs to handle with multiple clients simultaneously there are no constructors for these objects to share them between different sessions in order to have a much smaller memory footprint.
Method Summary | |
---|---|
static float |
getAvgCharWidth(Font font)
Returns the average character width of the specified font, measured in pixels. |
static int |
getCharHeight(Font font)
Returns the height of the specified font, measured in pixels. |
static Color |
getColor(int red,
int green,
int blue)
Returns a Color given the
desired red, green and blue values expressed as ints in the range
0 to 255 (where 0 is black and 255 is full brightness). |
static Color |
getColor(RGB rgb)
Returns an instance of Color given an
RGB describing the desired red, green and blue values. |
static Font |
getFont(FontData data)
Returns a new font given a font data which describes the desired font's appearance. |
static Font |
getFont(java.lang.String name,
int height,
int style)
Returns a Font object given a font name, the height of the desired
font in points, and a font style. |
static Image |
getImage(java.lang.String path)
Deprecated. Use getImage(String, ClassLoader) or
getImage(String, InputStream) instead. |
static Image |
getImage(java.lang.String path,
java.lang.ClassLoader imageLoader)
Returns an instance of Image based on the specified image path. |
static Image |
getImage(java.lang.String path,
java.io.InputStream inputStream)
Returns an instance of Image based on the specified image path. |
static Point |
stringExtent(Font font,
java.lang.String string)
Returns the extent of the given string. |
static Point |
textExtent(Font font,
java.lang.String string,
int wrapWidth)
Returns the extent of the given string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Color getColor(RGB rgb)
Color
given an
RGB
describing the desired red, green and blue values.
Note: it is considered an error to attempt to dispose of colors
that were created by this method. An IllegalStateException
is
thrown in this case.
rgb
- the RGB values of the desired color - must not be null
java.lang.IllegalArgumentException
- RGB
,
Device.getSystemColor(int)
public static Color getColor(int red, int green, int blue)
Color
given the
desired red, green and blue values expressed as ints in the range
0 to 255 (where 0 is black and 255 is full brightness).
Note: it is considered an error to attempt to dispose of colors
that were created by this method. An IllegalStateException
is
thrown in this case.
red
- the amount of red in the colorgreen
- the amount of green in the colorblue
- the amount of blue in the color
java.lang.IllegalArgumentException
- public static Font getFont(FontData data)
Note: it is considered an error to attempt to dispose of fonts
that were created by this method. An IllegalStateException
is
thrown in this case.
data
- the FontData
to use - must not be null
java.lang.IllegalArgumentException
- public static Font getFont(java.lang.String name, int height, int style)
Font
object given a font name, the height of the desired
font in points, and a font style.
Note: it is considered an error to attempt to dispose of fonts
that were created by this method. An IllegalStateException
is
thrown in this case.
name
- the name of the font (must not be null)height
- the font height in pointsstyle
- a bit or combination of NORMAL
,
BOLD
, ITALIC
java.lang.IllegalArgumentException
- @Deprecated public static Image getImage(java.lang.String path)
getImage(String, ClassLoader)
or
getImage(String, InputStream)
instead.
Image
based on the specified image path. The
image has to be on the applications class-path.
path
- the path to the image
java.lang.IllegalArgumentException
- java.lang.IllegalArgumentException
- SWTException
- public static Image getImage(java.lang.String path, java.lang.ClassLoader imageLoader)
Image
based on the specified image path. The
image has to be on the applications class-path. Uses the specified
classloader to load the image.
path
- the path to the imageimageLoader
- the classloader to use
java.lang.IllegalArgumentException
- SWTException
- public static Image getImage(java.lang.String path, java.io.InputStream inputStream)
Image
based on the specified image path. The
image will be read from the provided InputStream.
path
- the path the image resource is registered atinputStream
- the input stream for the image
java.lang.IllegalArgumentException
- SWTException
- public static Point textExtent(Font font, java.lang.String string, int wrapWidth)
The extent of a string is the width and height of the rectangular area it would cover if drawn in a particular font.
font
- the font for which the result is validstring
- the string to measurewrapWidth
- the maximum width of the text. The text will be wrapped to
match this width. If set to 0, no wrapping will be performed.
java.lang.IllegalArgumentException
- public static Point stringExtent(Font font, java.lang.String string)
The extent of a string is the width and height of the rectangular area it would cover if drawn in a particular font.
font
- the font for which the result is validstring
- the string to measure
java.lang.IllegalArgumentException
- public static int getCharHeight(Font font)
font
- the font for which the result is valid
java.lang.IllegalArgumentException
- public static float getAvgCharWidth(Font font)
font
- the font for which the result is valid
java.lang.IllegalArgumentException
-
|
Eclipse Rich Ajax Platform | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) EclipseSource and others 2002, 2012. All rights reserved.